我在 project-defaults.yml 中拥有这个:
swarm:
resource-adapters:
resource-adapters:
activemq-rar:
archive: activemq-rar.rar
transaction-support: LocalTransaction
config-properties:
ServerUrl:
value: tcp://amq:61616?jms.rmIdFromConnectionId=true
UserName:
value: myuser
Password:
value: mypw
现在,我正在尝试使用环境变量覆盖ServerUrl,UserName和Password,以便能够在不同的环境中运行它。我的第一个测试表明,我需要首先从 project-defaults.yml 中删除属性。我正在设置这些环境变量:
- SWARM_RESOURCE_DASH_ADAPTERS_RESOURCE_DASH_ADAPTERS_ACTIVEMQ_DASH_RAR_CONFIG_DASH_PROPERTIES_SERVERURL_VALUE=tcp://amq:61616?jms.rmIdFromConnectionId=true
- SWARM_RESOURCE_DASH_ADAPTERS_RESOURCE_DASH_ADAPTERS_ACTIVEMQ_DASH_RAR_CONFIG_DASH_PROPERTIES_USERNAME_VALUE=myuser
- SWARM_RESOURCE_DASH_ADAPTERS_RESOURCE_DASH_ADAPTERS_ACTIVEMQ_DASH_RAR_CONFIG_DASH_PROPERTIES_PASSWORD_VALUE=mypw
这适用于密码,但是对于服务器URL,当应用程序尝试启动时,我会收到此信息:
2019-06-05 13:36:57,867 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 15) MSC000001: Failed to start service jboss.ra.deployment."activemq-rar.rar_activemq-rar": org.jboss.msc.service.StartException in service jboss.ra.deployment."activemq-rar.rar_activemq-rar": WFLYJCA0046: Failed to start RA deployment [activemq-rar.rar]
at org.jboss.as.connector@15.0.1.Final//org.jboss.as.connector.services.resourceadapters.deployment.AbstractResourceAdapterDeploymentService$2.run(AbstractResourceAdapterDeploymentService.java:341)
at org.jboss.threads@2.3.2.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads@2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads@2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads@2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads@2.3.2.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485)
Caused by: org.jboss.jca.deployers.common.DeployException: IJ020060: Unable to inject: org.apache.activemq.ra.ActiveMQResourceAdapter property: serverurl value: tcp://amq:61616?jms.rmIdFromConnectionId=true
at org.jboss.ironjacamar.impl@1.4.11.Final//org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.createObjectsAndInjectValue(AbstractResourceAdapterDeployer.java:1267)
at org.jboss.as.connector@15.0.1.Final//org.jboss.as.connector.services.resourceadapters.deployment.ResourceAdapterXmlDeploymentService$WildFlyRaXmlDeployer.doDeploy(ResourceAdapterXmlDeploymentService.java:190)
at org.jboss.as.connector@15.0.1.Final//org.jboss.as.connector.services.resourceadapters.deployment.ResourceAdapterXmlDeploymentService.start(ResourceAdapterXmlDeploymentService.java:128)
at org.jboss.msc@1.4.5.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1738)
at org.jboss.msc@1.4.5.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1700)
at org.jboss.msc@1.4.5.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1558)
at org.jboss.threads@2.3.2.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads@2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads@2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads@2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
at java.base/java.lang.Thread.run(Thread.java:834)
我们可以看到它具有正确的服务器URL值,但无法注入它。我怎样才能解决这个问题?我正在使用Thorntail 2.4.0.Final,并在Docker容器中运行该应用程序。
我可以使用多个yml配置文件,但是使用环境变量会更容易。
编辑:
用户名实际上存在相同的问题,只能设置密码。这听起来像是按设计的方式进行,仅允许使用环境变量设置密码...