API 调用的等效 YAML 配置
Equivalent YAML config for API calls
我一直在使用 API 成功启动我的应用程序,现在由于某些原因我必须使用空心 uberjar 从单独的 WAR 启动应用程序。由于我找不到任何关于如何使用 hollow jar 的自定义 main 方法的参考资料,并且由于 2017.10.1 中关于 main 方法的弃用说明,我决定使用 YAML 配置。我进行了转换,但出现了不同的错误,这些错误至少表明消息传递部分未获取配置。挖掘参考文献也没有帮助。
这是有效的方法:
swarm
// Setup data sources
.fraction(new DatasourcesFraction()
// SWARM BUG: at least one DS without JNDI binding shall be provided ~> https://issues.jboss.org/browse/SWARM-1447
.dataSource("def-ds", ds -> {
ds.driverName("postgresql");
ds.connectionUrl(jdbcUrl);
ds.userName("commons_user");
ds.password("commonsTestDb");
ds.jta(true);
})
.dataSource("common-ds", ds -> {
ds.driverName("postgresql");
ds.connectionUrl(jdbcUrl);
ds.userName("commons_user");
ds.password("commonsTestDb");
ds.jndiName("java:/jdbc/dbpool");
ds.jta(true);
}))
// Setup JMS
.outboundSocketBinding("standard-sockets",
new OutboundSocketBinding("remote-activemq")
.remoteHost("artemis")
.remotePort("61616"))
.fraction(new MessagingFraction()
.defaultServer(server -> {
server.remoteConnector("remote-activemq", connector -> {
connector.socketBinding("remote-activemq");
});
server.pooledConnectionFactory("remote-activemq", factory -> {
factory.connectors("remote-activemq");
factory.entries("java:/jms/remote-mq");
factory.user("artemis_user");
factory.password("artemis_password");
});
server.jmsTopic("domain-events", topic -> {
topic.entries("java:/jms/topic/domain-events");
});
}))
.start();
// deploy JAX-RS resources
swarm.deploy(
ShrinkWrap
.create(JAXRSArchive.class)
.addAllDependencies());
这是不起作用的 YAML 配置:
swarm:
datasources:
data-sources:
# SWARM BUG: at least one DS without JNDI binding shall be provided ~> https://issues.jboss.org/browse/SWARM-1447
CommonDSDef:
driver-name: postgresql
connection-url: "jdbc:postgresql://postgres:5432/commons"
user-name: commons_user
password: commonsTestDb
jta: true
CommonDS:
driver-name: postgresql
connection-url: "jdbc:postgresql://postgres:5432/commons"
user-name: commons_user
password: commonsTestDb
jndi-name: java:/jdbc/dbpool
jta: true
network:
socket-binding-groups:
standard-sockets:
outbound-socket-bindings:
remote-activemq:
remote-host: artemis
remote-port: 61616
messaging:
servers:
default:
remote-connectors:
remote-activemq:
socket-binding: remote-activemq
pooled-connection-factories:
remote-activemq:
connectors: remote-activemq
entries: java:/jms/remote-mq
user: artemis_user
password: artemis_password
jms-topics:
domain-events:
entries: java:/jms/topic/domain-events
deployment:
dummy-app:
jaxrs:
application-path: /
在尝试使用配置时,我在日志中收到以下错误:
2017-10-28 19:36:31,219 ERROR [org.jboss.as.controller.management-operation] (main) WFLYCTL0013: Operation ("add") failed - address: (("deployment" => "commons-mocks-2.0.0-SNAPSHOT.war")) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.ra.remote-activemq"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"commons-mocks-2.0.0-SNAPSHOT.war\".component.DummyDomainEventListener.CREATE is missing [jboss.ra.remote-activemq]"]
}
2017-10-28 19:36:31,221 ERROR [org.jboss.as.server] (main) WFLYSRV0021: Deploy of deployment "commons-mocks-2.0.0-SNAPSHOT.war" was rolled back with the following failure message:
{
"WFLYCTL0412: Required services that are not installed:" => ["jboss.ra.remote-activemq"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"commons-mocks-2.0.0-SNAPSHOT.war\".component.DummyDomainEventListener.CREATE is missing [jboss.ra.remote-activemq]"]
}
之后抛出了一堆其他相关错误,最终服务器停止。
数据源的问题在 https://issues.jboss.org/browse/SWARM-1486 下归档,我在那里添加了解释。
messaging
的问题是文档问题 -- 正确的名称是 messaging-activemq
。这已在文档重构中修复:http://docs.wildfly-swarm.io/2017.11.0-SNAPSHOT/#_messaging
我一直在使用 API 成功启动我的应用程序,现在由于某些原因我必须使用空心 uberjar 从单独的 WAR 启动应用程序。由于我找不到任何关于如何使用 hollow jar 的自定义 main 方法的参考资料,并且由于 2017.10.1 中关于 main 方法的弃用说明,我决定使用 YAML 配置。我进行了转换,但出现了不同的错误,这些错误至少表明消息传递部分未获取配置。挖掘参考文献也没有帮助。
这是有效的方法:
swarm
// Setup data sources
.fraction(new DatasourcesFraction()
// SWARM BUG: at least one DS without JNDI binding shall be provided ~> https://issues.jboss.org/browse/SWARM-1447
.dataSource("def-ds", ds -> {
ds.driverName("postgresql");
ds.connectionUrl(jdbcUrl);
ds.userName("commons_user");
ds.password("commonsTestDb");
ds.jta(true);
})
.dataSource("common-ds", ds -> {
ds.driverName("postgresql");
ds.connectionUrl(jdbcUrl);
ds.userName("commons_user");
ds.password("commonsTestDb");
ds.jndiName("java:/jdbc/dbpool");
ds.jta(true);
}))
// Setup JMS
.outboundSocketBinding("standard-sockets",
new OutboundSocketBinding("remote-activemq")
.remoteHost("artemis")
.remotePort("61616"))
.fraction(new MessagingFraction()
.defaultServer(server -> {
server.remoteConnector("remote-activemq", connector -> {
connector.socketBinding("remote-activemq");
});
server.pooledConnectionFactory("remote-activemq", factory -> {
factory.connectors("remote-activemq");
factory.entries("java:/jms/remote-mq");
factory.user("artemis_user");
factory.password("artemis_password");
});
server.jmsTopic("domain-events", topic -> {
topic.entries("java:/jms/topic/domain-events");
});
}))
.start();
// deploy JAX-RS resources
swarm.deploy(
ShrinkWrap
.create(JAXRSArchive.class)
.addAllDependencies());
这是不起作用的 YAML 配置:
swarm:
datasources:
data-sources:
# SWARM BUG: at least one DS without JNDI binding shall be provided ~> https://issues.jboss.org/browse/SWARM-1447
CommonDSDef:
driver-name: postgresql
connection-url: "jdbc:postgresql://postgres:5432/commons"
user-name: commons_user
password: commonsTestDb
jta: true
CommonDS:
driver-name: postgresql
connection-url: "jdbc:postgresql://postgres:5432/commons"
user-name: commons_user
password: commonsTestDb
jndi-name: java:/jdbc/dbpool
jta: true
network:
socket-binding-groups:
standard-sockets:
outbound-socket-bindings:
remote-activemq:
remote-host: artemis
remote-port: 61616
messaging:
servers:
default:
remote-connectors:
remote-activemq:
socket-binding: remote-activemq
pooled-connection-factories:
remote-activemq:
connectors: remote-activemq
entries: java:/jms/remote-mq
user: artemis_user
password: artemis_password
jms-topics:
domain-events:
entries: java:/jms/topic/domain-events
deployment:
dummy-app:
jaxrs:
application-path: /
在尝试使用配置时,我在日志中收到以下错误:
2017-10-28 19:36:31,219 ERROR [org.jboss.as.controller.management-operation] (main) WFLYCTL0013: Operation ("add") failed - address: (("deployment" => "commons-mocks-2.0.0-SNAPSHOT.war")) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.ra.remote-activemq"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"commons-mocks-2.0.0-SNAPSHOT.war\".component.DummyDomainEventListener.CREATE is missing [jboss.ra.remote-activemq]"]
}
2017-10-28 19:36:31,221 ERROR [org.jboss.as.server] (main) WFLYSRV0021: Deploy of deployment "commons-mocks-2.0.0-SNAPSHOT.war" was rolled back with the following failure message:
{
"WFLYCTL0412: Required services that are not installed:" => ["jboss.ra.remote-activemq"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"commons-mocks-2.0.0-SNAPSHOT.war\".component.DummyDomainEventListener.CREATE is missing [jboss.ra.remote-activemq]"]
}
之后抛出了一堆其他相关错误,最终服务器停止。
数据源的问题在 https://issues.jboss.org/browse/SWARM-1486 下归档,我在那里添加了解释。
messaging
的问题是文档问题 -- 正确的名称是 messaging-activemq
。这已在文档重构中修复:http://docs.wildfly-swarm.io/2017.11.0-SNAPSHOT/#_messaging