我试图将TomEE(带有Java EE的Tomcat)配置为使用AMQP有线协议连接到外部代理(Azure服务总线)。默认情况下,JMS Provider看起来像是ActiveMQ。根据文档,ActiveMQ确实支持AMQP协议。我的目标是使用ActiveMQ作为TomEE随附的JMS提供程序。但是,当我部署基本的ear文件时,出现以下错误:
03-Jun-2019 16:43:19.629 WARNING [http-nio-8080-exec-1] org.apache.geronimo.transaction.manager.TransactionImpl.enlistResource Unable to enlist XAResource org.apache.geronimo.transaction.manager.WrapperNamedXAResource@117d2011, errorCode: -7
javax.transaction.xa.XAException: Disposed due to prior exception
at org.apache.activemq.TransactionContext.toXAException(TransactionContext.java:803)
at org.apache.activemq.TransactionContext.setXid(TransactionContext.java:729)
at org.apache.activemq.TransactionContext.start(TransactionContext.java:379)
at org.apache.activemq.ra.LocalAndXATransaction.start(LocalAndXATransaction.java:151)
at org.apache.geronimo.transaction.manager.WrapperNamedXAResource.start(WrapperNamedXAResource.java:111)
at org.apache.geronimo.transaction.manager.TransactionImpl.enlistResource(TransactionImpl.java:209)
at org.apache.geronimo.connector.outbound.TransactionEnlistingInterceptor.getConnection(TransactionEnlistingInterceptor.java:60)
at org.apache.geronimo.connector.outbound.TransactionCachingInterceptor.getConnection(TransactionCachingInterceptor.java:101)
at org.apache.geronimo.connector.outbound.ConnectionHandleInterceptor.getConnection(ConnectionHandleInterceptor.java:43)
at org.apache.geronimo.connector.outbound.TCCLInterceptor.getConnection(TCCLInterceptor.java:39)
at org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.getConnection(ConnectionTrackingInterceptor.java:66)
at org.apache.geronimo.connector.outbound.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:81)
at org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:94)
at org.apache.activemq.ra.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:67)
at local.gerb.HelloImpl.sendJMS(HelloImpl.java:79)
[....]
Caused by: org.apache.activemq.transport.InactivityIOException: Channel was inactive for too (>30000) long: tcp://40.71.10.195:5671
at org.apache.activemq.transport.amqp.AmqpInactivityMonitor$1$1.run(AmqpInactivityMonitor.java:69)
... 3 more
有人将ActiveMQ与AMQP一起使用吗?还是要获得奖励积分,有人能与Azure Service Bus一起使用吗?
我确实尝试了从github:(https://github.com/Azure/azure-service-bus/tree/master/samples/Java/qpid-jms-client/JmsQueueQuickstart)开始的Azure JMS快速入门,并且可以正常运行,因此我确信Service Bus已启动并正在运行。但是,我无法在TomEE中部署JMS应用程序。任何帮助将不胜感激。
更新:我正在使用贾斯汀·贝特拉姆(Justin Bertram)建议的AMPQ资源适配器:https://github.com/amqphub/amqp-10-resource-adapter
我在耳朵文件中包含rar,而TomEE似乎已成功加载资源适配器:
04-Jun-2019 02:21:02.117 INFO [main] org.apache.openejb.config.OutputGeneratedDescriptors.writeRaXml Dumping Generated ra.xml to: /usr/local/tomee/temp/ra-6070887435985632449resource-adapter-1.0.1-SNAPSHOT.rar.xml
04-Jun-2019 02:21:02.140 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureService Configuring Service(id=AmqpResourceAdapter, type=Resource, provider-id=AmqpResourceAdapter)
04-Jun-2019 02:21:02.142 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureService Configuring Service(id=resource-adapter-1.0.1-SNAPSHOT.rar, type=Resource, provider-id=resource-adapter-1.0.1-SNAPSHOT.rar)
04-Jun-2019 02:21:02.142 INFO [main] org.apache.openejb.config.ConfigurationFactory.configureService Configuring Service(id=resource-adapter-1.0.1-SNAPSHOT.rar, type=Container, provider-id=Default MDB Container)
但是它似乎在TomEE的启动过程中失败了。似乎ActiveMQ资源适配器和AMPQ资源适配器相互冲突。现在,我得到javax.naming.NameAlreadyBoundException:
04-Jun-2019 02:21:03.947 SEVERE [main] org.apache.tomee.catalina.ServerListener.lifecycleEvent TomEE Listener can't start OpenEJB
org.apache.openejb.OpenEJBException: Cannot bind Container with id Default MDB Container : ParsedName{path=openejb/Container/Default MDB Container, component=Default MDB Container}
at org.apache.openejb.assembler.classic.Assembler.bindService(Assembler.java:2847)
at org.apache.openejb.assembler.classic.Assembler.createContainer(Assembler.java:2817)
at org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:623)
at org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:487)
at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:150)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:307)
at org.apache.tomee.catalina.TomcatLoader.initialize(TomcatLoader.java:247)
at org.apache.tomee.catalina.ServerListener.lifecycleEvent(ServerListener.java:168)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:395)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:108)
at org.apache.catalina.startup.Catalina.load(Catalina.java:632)
at org.apache.catalina.startup.Catalina.load(Catalina.java:655)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:309)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
Caused by: javax.naming.NameAlreadyBoundException: ParsedName{path=openejb/Container/Default MDB Container, component=Default MDB Container}
at org.apache.openejb.core.ivm.naming.NameNode.bind(NameNode.java:181)
at org.apache.openejb.core.ivm.naming.IvmContext.bind(IvmContext.java:322)
at org.apache.openejb.assembler.classic.Assembler.bindService(Assembler.java:2845)
这似乎是问题所在(我认为):
org.apache.openejb.config.ConfigurationFactory.configureService Configuring Service(id=resource-adapter-1.0.1-SNAPSHOT.rar, type=Container, provider-id=Default MDB Container
ActiveMQ和AMPQ似乎都具有默认MDB容器,这会导致在部署时引发异常。但是,我不确定如何将AMPQ RA配置为使用其他名称。
我找不到有关如何在TomEE中配置RA的大量信息。我唯一遇到的是这份文件:http://tomee.apache.org/changing-jms-implementations.html
但是它似乎在细节上有点浅,因此我对下一步的工作有些迷茫。
我非常感谢大家的帮助。我觉得我已经很接近要开始工作了!
答案 0 :(得分:2)
我认为您在混淆经纪人和客户。我已经将ActiveMQ与AMQP一起使用,但这是一个连接到ActiveMQ代理的AMQP客户端。您正在尝试使用ActiveMQ JCA资源适配器,该适配器旨在使ActiveMQ代理使用OpenWire协议,以使用AMQP连接到Azure Service Bus。这是行不通的,而且从未设计过。
您需要使用可以说AMQP的JCA资源适配器(即不是ActiveMQ JCA RA)。也许看看this generic JMS JCA resource adapter。它被设计用于JBoss AS或Wildfly,但不应有任何其他限制,除非它在TomEE中使用。然后,您可以将Qpid JMS作为客户端插入其中。您可以看到执行此here的另一个组件的示例。