如何为 Artemis 配置 WebLogic JMS 消息传递桥

How to configure WebLogic JMS Messaging Bridge to Artemis

我正在尝试设置连接到 Artemis 的 WLS (12.1.3) 网桥,但在使其正常工作时遇到问题。我认为我的问题可能出在我在 WebLogic 中配置网桥目标的方式上,但无法弄清楚!

问题 非常相似。他们似乎已经设法让它工作了,但我想我遗漏了一些关键细节!

到目前为止我所做的是:

java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
connectionFactory.ConnectionFactory=tcp://myArtemisServer:61616?type=XA_CF
<jms-bridge-destination>
    <name>artemis_endpoint</name>
    <adapter-jndi-name>eis.jms.WLSConnectionFactoryJNDIXA</adapter-jndi-name>
    <user-name>myUser</user-name>
    <user-password-encrypted>XXXXXXXXXXXXXXXXXXXXXX</user-password-encrypted>
    <connection-factory-jndi-name>ConnectionFactory</connection-factory-jndi-name>
    <initial-context-factory>org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory</initial-context-factory>
    <connection-url>tcp://myArtemisServer:61616?type=XA_CF</connection-url>
    <destination-jndi-name>MY.ADDRESS::my/queue/jndi/name</destination-jndi-name>
</jms-bridge-destination>
####<13-Aug-2020 12:56:46 o'clock IST> <Debug> <MessagingBridgeRuntime> <localhost> <AdminServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1597319806108> <BEA-000000> <Bridge  Getting target connection> 
####<13-Aug-2020 12:56:46 o'clock IST> <Debug> <MessagingBridgeRuntimeVerbose> <localhost> <AdminServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1597319806115> <BEA-000000> <Exception:
javax.naming.NameNotFoundException: ConnectionFactory
    at org.apache.activemq.artemis.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:236)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at weblogic.jms.adapter.JMSBaseConnection.run(JMSBaseConnection.java:301)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.jms.adapter.JMSBaseConnection.startInternal(JMSBaseConnection.java:299)
    at weblogic.jms.adapter.JMSBaseConnection.start(JMSBaseConnection.java:256)
    at weblogic.jms.adapter.JMSManagedConnectionFactory.createManagedConnection(JMSManagedConnectionFactory.java:192)
    at weblogic.connector.security.layer.AdapterLayer.createManagedConnection(AdapterLayer.java:843)
    at weblogic.connector.outbound.ConnectionFactory.createResource(ConnectionFactory.java:91)
    at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1331)
    at weblogic.common.resourcepool.ResourcePoolImpl.reserveResourceInternal(ResourcePoolImpl.java:425)
    at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:344)
    at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:324)
    at weblogic.connector.outbound.ConnectionPool.reserveResource(ConnectionPool.java:705)
    at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:318)
    at weblogic.connector.outbound.ConnectionManagerImpl.getConnectionInfo(ConnectionManagerImpl.java:409)
    at weblogic.connector.outbound.ConnectionManagerImpl.getConnection(ConnectionManagerImpl.java:343)
    at weblogic.connector.outbound.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:134)
    at weblogic.jms.adapter.JMSBaseConnectionFactory.getTargetConnection(JMSBaseConnectionFactory.java:123)
    at weblogic.jms.bridge.internal.MessagingBridge.getConnections(MessagingBridge.java:880)
    at weblogic.jms.bridge.internal.MessagingBridge.run(MessagingBridge.java:1079)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:553)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)

****************** 更新 *************

删除 jndi.properties 并将网桥配置更改为

之后

<connection-factory-jndi-name>XAConnectionFactory</connection-factory-jndi-name>

新错误,完整堆栈跟踪是

javax.naming.NamingException: scheme MY.ADDRESS not recognized
    at org.apache.activemq.artemis.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:222)
    at javax.naming.InitialContext.lookup(InitialContext.java:417)
    at weblogic.jms.adapter.JMSBaseConnection.run(JMSBaseConnection.java:326)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.jms.adapter.JMSBaseConnection.startInternal(JMSBaseConnection.java:324)
    at weblogic.jms.adapter.JMSBaseConnection.start(JMSBaseConnection.java:256)
    at weblogic.jms.adapter.JMSManagedConnectionFactory.createManagedConnection(JMSManagedConnectionFactory.java:192)
    at weblogic.connector.security.layer.AdapterLayer.createManagedConnection(AdapterLayer.java:843)
    at weblogic.connector.outbound.ConnectionFactory.createResource(ConnectionFactory.java:91)
    at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1331)
    at weblogic.common.resourcepool.ResourcePoolImpl.reserveResourceInternal(ResourcePoolImpl.java:425)
    at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:344)
    at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:324)
    at weblogic.connector.outbound.ConnectionPool.reserveResource(ConnectionPool.java:705)
    at weblogic.common.resourcepool.ResourcePoolImpl.reserveResource(ResourcePoolImpl.java:318)
    at weblogic.connector.outbound.ConnectionManagerImpl.getConnectionInfo(ConnectionManagerImpl.java:409)
    at weblogic.connector.outbound.ConnectionManagerImpl.getConnection(ConnectionManagerImpl.java:343)
    at weblogic.connector.outbound.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:134)
    at weblogic.jms.adapter.JMSBaseConnectionFactory.getTargetConnection(JMSBaseConnectionFactory.java:123)
    at weblogic.jms.bridge.internal.MessagingBridge.getConnections(MessagingBridge.java:880)
    at weblogic.jms.bridge.internal.MessagingBridge.run(MessagingBridge.java:1079)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:553)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
> 

像这样在 Artemis 中定义队列:

<address name="MY.ADDRESS">
   <anycast>
       <queue name="my/queue/jndi/name" />
   </anycast>
</address>

由于您在 connection-url 中使用 type=XA_CF,因此您应该使用 XAConnectionFactory 作为 connection-factory-jndi-name

关于 destination-jndi-nameNamingException,您使用 fully-qualified-queue 名称(即 <address>::<queue>)是否有特定原因?正如 the documentation typically you'd configure the queue name and address name to be the same for JMS clients so that the producer consumer could use the same value which is generally less confusing for application developers. The FQQN is generally reserved for special use-cases. Furthermore, FQQN syntax wasn't supported for JNDI lookups until 2.15.0 (see ARTEMIS-2880 中所讨论的那样)。因此,我建议您在 Artemis 中使用类似的东西 broker.xml:

<address name="myJmsDestination">
   <anycast>
       <queue name="myJmsDestination" />
   </anycast>
</address>

此外,由于您没有在 JNDI 环境属性中配置 JMS 目标的选项,因此您应该使用 dynamicQueues/ 前缀,如 the documentation.

中所述

最终您的配置将如下所示:

<jms-bridge-destination>
    <name>artemis_endpoint</name>
    <adapter-jndi-name>eis.jms.WLSConnectionFactoryJNDIXA</adapter-jndi-name>
    <user-name>myUser</user-name>
    <user-password-encrypted>XXXXXXXXXXXXXXXXXXXXXX</user-password-encrypted>
    <connection-factory-jndi-name>XAConnectionFactory</connection-factory-jndi-name>
    <initial-context-factory>org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory</initial-context-factory>
    <connection-url>tcp://myArtemisServer:61616?type=XA_CF</connection-url>
    <destination-jndi-name>dynamicQueues/myJmsDestination</destination-jndi-name>
</jms-bridge-destination>

最后,我认为您实际上不需要 jndi.properties 文件。所有必要的属性都可以直接在 jms-bridge-destination.

中定义