3

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?

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
Alice
  • 43
  • 7

1 Answers1

2

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.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
  • Removing the connectionFactory line from the properties doesn't seem to help. Weblogic server complains that it can't find the connection factory in question which must be filled in upon bridge creation. – Alice Sep 16 '19 at 06:36
  • I updated my answer (as well as your question) based on your feedback. – Justin Bertram Sep 16 '19 at 13:27
  • Thank you for your reply. Changing the connection factory as suggested plus adapting the JNDI properties as follows has solved my issue. My bridge is active and started with status "forwarding messages" now. I still need to test if it succeeds sending messages. – Alice Sep 17 '19 at 18:16
  • Keeping the JNDI properties for the queue as original ```queue.queues/myqueue=myqueue``` doesn't work. It must be changed to ```dynamicQueues/myQueue```. I am wondering why ... – Alice Sep 17 '19 at 18:21
  • What name are you actually looking up for the queue? If you're using the property `queue.queues/myqueue=myqueue` then your lookup should be using `queues/myqueue`. – Justin Bertram Sep 17 '19 at 19:20
  • in the properties files, I put ```queue.queues/myqueue=myqueue```, and in WL ```myqueue```. I am going to test with your suggested configuration. – Alice Sep 19 '19 at 15:34
  • If you want to use `myqueue` for the actual lookup then your property should be `queue.myqueue=myqueue`. As noted in my answer the syntax for these properties is defined in [the Artemis documentation](http://activemq.apache.org/components/artemis/documentation/latest/using-jms.html). – Justin Bertram Sep 19 '19 at 16:04
  • The following configurations are working for me: ```queue.queues=dynamicQueues/myqueue``` in properties and lookup ```dynamicQueues/myqueue```, ```dynamicQueues/myqueue``` and lookup ```dynamicQueues/myqueue``` and finally ```queue.queues/myqueue=myqueue``` and lookup ```queues/myqueue```. – Alice Sep 20 '19 at 08:03
  • Your JNDI context property definitions involving `dynamicQueues/` are invalid. The whole point of using `dynamicQueues/` in a lookup is so that you *don't* need to define a corresponding property in the JNDI context (hence why it's *dynamic*). The reason the lookups with `dynamicQueues/` work is simply because `myqueue` exists on the broker. Again, the syntax for these lookups and how it works is described in [the documentation](http://activemq.apache.org/components/artemis/documentation/latest/using-jms.html). – Justin Bertram Sep 20 '19 at 13:23
  • Thank you. This makes sense! It is strange that the invalid configuration works. Anyway, I will keep the two working configurations. My preference would go to the ```dynamicQueues``` or ```dynamicTopics``` so that no JNDI configuration must be configured in the ```jndi.properties``` file. – Alice Sep 23 '19 at 08:45
  • To be clear, the invalid configuration itself doesn't actually work. It's being ignored since your lookup is using `dynamicQueues/`. Using `dynamicQueues` bypasses the configuration and just instantiates the destination with the name you provide in the lookup assuming that it exists on the broker. – Justin Bertram Sep 23 '19 at 15:22