Error “Invalid broker URL” while bridging ActiveMQ Artemis 7.4 with Weblogic 12.x

别等时光非礼了梦想. 提交于 2021-02-10 06:20:08

问题


I am trying to create bridge between Oracle 12.x and Redhat ActiveMQ Artemis 7.4. This is what has been done to set up the bridge:

  1. Set artemis-jms-client-all-2.9.0.redhat-00005.jar to WL classpath
  2. Set the following properties to WL classpath:
java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
connectionFactory.ConnectionFactory=amq.xaqcf.myqueue
queue.queues/myqueue=myqueue

However, I get the following error:

java.lang.Exception: javax.resource.ResourceException: ConnectionFactory: failed to get initial context (InitialContextFactory =org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory, url = tcp://brokername:61616?type=XA_CF, user name = amq)
        at weblogic.jms.adapter.JMSBaseConnection.throwResourceException(JMSBaseConnection.java:1750)
        at weblogic.jms.adapter.JMSBaseConnection.startInternal(JMSBaseConnection.java:538)
        at weblogic.jms.adapter.JMSBaseConnection.start(JMSBaseConnection.java:264)
        at 
...
-------------- Linked Exception ------------
javax.naming.NamingException: Invalid broker URL
        at org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory.getInitialContext(ActiveMQInitialContextFactory.java:85)

According to ActiveMQInitialContextFactory.java, it is due to the following block:

for (Map.Entry<?, ?> entry : environment.entrySet()) {
    String key = entry.getKey().toString();
    if (key.startsWith(connectionFactoryPrefix)) {
        String jndiName = key.substring(connectionFactoryPrefix.length());
        try {
            data.put(jndiName, createConnectionFactory((String) environment.get(key), jndiName));
        } catch (Exception e) {
            e.printStackTrace();
            throw new NamingException("Invalid broker URL");
        }
    }
}

Here's the exception from e.printStackTrace():

Exception: javax.naming.NameNotFoundException: amq.xaqcf.myqueue
        at org.apache.activemq.artemis.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:236) 
        at javax.naming.InitialContext.lookup(InitialContext.java:417)

I have no issue bridging between Oracle Weblogic 12.x with ActiveMQ 6.3. A similar issue was raised here Is there a Java 1.7 compatible Artemis JMS client? but it is for Oracle SOA 10.x which uses java 1.7.

How can I make it work? Should ActiveMQInitialContextFactory.java be adapted?


回答1:


Your problem is coming from the fact that you're attempting to look-up the connection factory amq.xaqcf.myqueue, but you haven't actually defined that connection factory in your JNDI properties. Instead you have this line:

connectionFactory.ConnectionFactory=amq.xaqcf.myqueue

This line actually defines a connection factory called ConnectionFactory with the URL amq.xaqcf.myqueue which is invalid. Try this instead:

connectionFactory.amq.xaqcf.myqueue=tcp://brokername:61616?type=XA_CF

The syntax for these properties is defined in the Artemis documentation.



来源:https://stackoverflow.com/questions/57924183/error-invalid-broker-url-while-bridging-activemq-artemis-7-4-with-weblogic-12

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!