WildFly 使用 JCA 资源适配器与 ActiveMQ 集成

WildFly integration with ActiveMQ using JCA resource adapter

我正在尝试使用 ActiveMQ JCA 资源适配器将 ActiveMQ 5.15.13 与 WildFly 21.0 集成。1.Final。但是,我在执行此操作时遇到错误。我能够将 WildFly 9 与 ActiveMQ 5.10 集成。 我收到以下错误:

2021-01-22 19:20:18,577 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 93) MSC000001: Failed to start service jboss.ra.deployer."activemq-rar-5.15.13.rar": org.jboss.msc.service.StartException in service jboss.ra.deployer."activemq-rar-5.15.13.rar": WFLYJCA0046: Failed to start RA deployment [activemq-rar-5.15.13.rar]
    at org.jboss.as.connector.services.resourceadapters.deployment.ResourceAdapterDeploymentService.run(ResourceAdapterDeploymentService.java:176)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1348)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:513)
Caused by: org.jboss.jca.deployers.common.DeployException: IJ020056: Deployment failed: file:/opt/apps/MerckContivoPilot/wildfly-21.0.1.Final/standalone/deployments/activemq-rar-5.15.13.rar/
    at org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.createObjectsAndInjectValue(AbstractResourceAdapterDeployer.java:2058)
    at org.jboss.as.connector.services.resourceadapters.deployment.ResourceAdapterDeploymentService$WildFLyRaDeployer.doDeploy(ResourceAdapterDeploymentService.java:233)
    at org.jboss.as.connector.services.resourceadapters.deployment.ResourceAdapterDeploymentService.start(ResourceAdapterDeploymentService.java:126)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
    at org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1363)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.jboss.jca.validator.ValidatorException: Severity: WARNING
Section: 20.7
Description: Invalid config-property-type for AdminObject.
Code: Class: org.apache.activemq.pool.XaPooledConnectionFactory Property: tmFromJndi Type: boolean

Severity: ERROR
Section: 13.4.2.2
Description: An ActivationSpec class must implement the ActivationSpec interface
Code: org.apache.activemq.ra.ActiveMQActivationSpec

Severity: ERROR
Section: 5.3.1
Description: A ResourceAdapter must implement the javax.resource.spi.ResourceAdapter interface.
Code: org.apache.activemq.ra.ActiveMQResourceAdapter

Severity: ERROR
Section: 6.5.3.2
Description: The class must implement the javax.resource.spi.ManagedConnectionFactory interface.
Code: org.apache.activemq.ra.ActiveMQManagedConnectionFactory

资源适配器配置

<subsystem xmlns="urn:jboss:domain:resource-adapters:6.0">
    <resource-adapters>
        <resource-adapter id="activemq-ra">
            <archive>activemq-rar-5.15.13.rar</archive>
            <transaction-support>XATransaction</transaction-support>
            <config-property name="ServerUrl">tcp://localhost:61616?soTimeout=20000&amp;connectionTimeout=10000</config-property>
            <config-property name="UserName">defaultUser</config-property>
            <config-property name="UseInboundSession">false</config-property>
            <config-property name="Password">defaultPassword</config-property>
            <connection-definitions>
                <connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:/ActiveMQ/QueueConnectionFactory" enabled="true" use-java-context="true" pool-name="ActiveMQ/QueueConnectionFactory" use-ccm="true">
                    <xa-pool>
                        <min-pool-size>1</min-pool-size>
                        <max-pool-size>200</max-pool-size>
                    </xa-pool>
                    <timeout>
                        <blocking-timeout-millis>30000</blocking-timeout-millis>
                        <idle-timeout-minutes>5</idle-timeout-minutes>
                    </timeout>
                </connection-definition>
            </connection-definitions>
            <admin-objects>
                <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/queue/XMLPublishQueue" enabled="true" use-java-context="true" pool-name="XMLPublishQueue">
                    <config-property name="PhysicalName">XMLPublishQueue</config-property>
                </admin-object>
                <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/queue/SupportTasksQueue" enabled="true" use-java-context="true" pool-name="SupportTasksQueue">
                    <config-property name="PhysicalName">SupportTasksQueue</config-property>
                </admin-object>
            </admin-objects>
        </resource-adapter>
    </resource-adapters>
</subsystem>

已从以下位置下载 rar https://mvnrepository.com/artifact/org.apache.activemq/activemq-rar/5.15.13

按照以下指南尝试了两种方法(更新 rar 和不更新它)

https://access.redhat.com/solutions/1124023

http://www.mastertheboss.com/jboss-server/jboss-jms/integrate-activemq-with-wildfly

更新:当我通过 ee 子系统下的全局模块部分添加第三方 jar 时,问题开始了。我正在添加 java ee api jar

任何help/suggestions将不胜感激。

我将 ActiveMQ 5.13.13 JCA 资源适配器部署到 Wildfly 21.0。1.Final 但我没有看到与您看到的相同的日志记录。一切似乎都运行良好。这是我所做的:

  1. 下载并解压缩 WildFly 21.0.1.Final
  2. 下载 ActiveMQ 5.15.13 JCA RA 并将其复制到 standalone/deployments
  3. 将此添加到 standalone/configuration/standalone-full.xml
    <subsystem xmlns="urn:jboss:domain:resource-adapters:6.0">
        <resource-adapters>
            <resource-adapter id="activemq-ra-5">
                <archive>activemq-rar-5.15.13.rar</archive>
                <transaction-support>XATransaction</transaction-support>
                <config-property name="ServerUrl">tcp://localhost:61616?soTimeout=20000&amp;connectionTimeout=10000</config-property>
                <config-property name="UserName">defaultUser</config-property>
                <config-property name="UseInboundSession">false</config-property>
                <config-property name="Password">defaultPassword</config-property>
                <connection-definitions>
                    <connection-definition class-name="org.apache.activemq.ra.ActiveMQManagedConnectionFactory" jndi-name="java:/ActiveMQ/QueueConnectionFactory" enabled="true" use-java-context="true" pool-name="ActiveMQ/QueueConnectionFactory" use-ccm="true">
                        <xa-pool>
                            <min-pool-size>1</min-pool-size>
                            <max-pool-size>200</max-pool-size>
                        </xa-pool>
                        <timeout>
                            <blocking-timeout-millis>30000</blocking-timeout-millis>
                            <idle-timeout-minutes>5</idle-timeout-minutes>
                        </timeout>
                    </connection-definition>
                </connection-definitions>
                <admin-objects>
                    <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/queue/XMLPublishQueue" enabled="true" use-java-context="true" pool-name="XMLPublishQueue">
                        <config-property name="PhysicalName">XMLPublishQueue</config-property>
                    </admin-object>
                    <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name="java:/queue/SupportTasksQueue" enabled="true" use-java-context="true" pool-name="SupportTasksQueue">
                        <config-property name="PhysicalName">SupportTasksQueue</config-property>
                    </admin-object>
                </admin-objects>
            </resource-adapter>
        </resource-adapters>
    </subsystem>
    
  4. 更新了 ee 子系统 default-bindings 元素中的 jms-connection-factory 属性以使用 java:/ActiveMQ/QueueConnectionFactory
    <default-bindings context-service="java:jboss/ee/concurrency/context/default" datasource="java:jboss/datasources/ExampleDS" jms-connection-factory="java:/ActiveMQ/QueueConnectionFactory" managed-executor-service="java:jboss/ee/concurrency/executor/default" managed-scheduled-executor-service="java:jboss/ee/concurrency/scheduler/default" managed-thread-factory="java:jboss/ee/concurrency/factory/default"/>
    
  5. ejb3 子系统的 mdb/resource-adapter-ref 元素的 resource-adapter-name 属性更新为 ${ejb.resource-adapter-name:activemq-rar-5}
    <resource-adapter-ref resource-adapter-name="${ejb.resource-adapter-name:activemq-rar-5}"/>
    
  6. 开始使用 WildFly ./standalone.sh -c standalone-full.xml

鉴于所有这些都正常工作,我会说你的问题是你的全局模块,特别是因为它包含 Java EE API 类。应用程序 jar 和库 jar 应该 包括 Java/Jakarta EE API 类。 EE 服务器(例如 WildFly)提供所有这些。如果您(或其他人)提供了他们自己的类,那么这将导致类加载问题,而这反过来又会导致许多其他奇怪的问题。重申一下,您绝对没有理由将 Java/Jakarta EE API 类 与部署在服务器上的应用程序或库一起打包。