Using Generic JMS JCA RA with JBoss 4.3 without MDBs

154 views
Skip to first unread message

Andrzej Majewski

unread,
Dec 13, 2014, 5:02:26 PM12/13/14
to jboss-gene...@googlegroups.com
Hi,

Here is the problem I am struggling since couple of days:

I am trying to connect from JBoss EAP6 to JBoss messaging running on remote JBoss 4.3. I have followed the instructions on connecting to JBoss messaging from github page 
and I believe I was able to install correctly 'Generic JMS JCA Resource Adapter' on EAP6. Now all the examples on 'how to listen for a message' refer to using MDB, at the moment I would prefer not to use the MDB. From the research I did it should be possible to receive messages from remote JBoss messaging server without using MDBs, aka I am using Spring.

Following link provides an approach which suits my needs:


Context context = new InitialContext();

 

// 1) lookup connection factory (local JNDI lookup, no credentials required)

javax.jms.ConnectionFactory cf = (javax.jms.ConnectionFactory)context.lookup("java:/GenericJmsXA");

 

// 2) create a connection to the remote provider

javax.jms.Connection c = cf.createConnection();

// 3) create session session
boolean transacted = true;
javax.jms.Session session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE);
 
// 4) "create" the queue/topic (using the topic name - not JNDI)
javax.jms.Topic topic = session.createTopic("ServerNotificationTopic");
 
// 5) create consumer
javax.jms.MessageConsumer consumer = session.createConsumer(topic); // messageSelector is optional
 
// 6) set listener
consumer.setMessageListener(new javax.jms.MessageListener() {
  public void onMessage(javax.jms.Message message)
  {
    System.out.println("received message: "+message);
  }
});
 
// 7) listen for messages (start the connection)
c.start();



Now the issue I am facing is that resolving of the destination fails
javax.jms.Topic topic = session.createTopic("ServerNotificationTopic");


I believe that is because my Generic JMS RA configuration does not define ServerNotificationTopic.

I think I am missing admin-objects definition:

<subsystem xmlns="urn:JBoss:domain:resource-adapters:1.0">
   <resource-adapters>
       <resource-adapter>
           <archive>
               generic-jms-ra-<VERSION>.rar
           </archive>
           <transaction-support>XATransaction</transaction-support>
           <connection-definitions>
               <connection-definition class-name="org.JBoss.resource.adapter.jms.JmsManagedConnectionFactory" jndi-name="java:/GenericJmsXA" enabled="true" use-java-context="true" pool-name="GenericJmsXA" use-ccm="true">
                   <config-property name="JndiParameters">
                       java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory;java.naming.provider.url=JBM_HOST:1099;java.naming.factory.url.pkgs=org.JBoss.naming:org.jnp.interfaces
                   </config-property>
                   <config-property name="ConnectionFactory">
                       XAConnectionFactory
                   </config-property>
                   <xa-pool>
                       <min-pool-size>0</min-pool-size>
                       <max-pool-size>10</max-pool-size>
                       <prefill>false</prefill>
                       <use-strict-min>false</use-strict-min>
                       <flush-strategy>FailingConnectionOnly</flush-strategy>
                       <pad-xid>false</pad-xid>
                       <wrap-xa-resource>true</wrap-xa-resource>
                   </xa-pool>
                   <security>
                       <application/>
                   </security>
               </connection-definition>
           </connection-definitions>
           <admin-objects/>
           
       </resource-adapter>
   </resource-adapters>
</subsystem>



According to an example I found on ActiveMQ resource adapter configuration

Remote queues and topics should be wrapped in admin-objects as follows:

 <admin-objects>
  <admin-object class-name="org.apache.activemq.command.ActiveMQQueue" jndi-name=" queue/JMSBridgeTargetQ " use-java-context="true" pool-name="target_queue">
     <config-property name="PhysicalName">
       JMSBridgeTargetQ
     </config-property>
  </admin-object>
</admin-objects>


  
Do you know which class can act as proxy for the JBoss Messaging queue and topic, and be defined as admin object?

I would appreciate any feedback.

Regards,
Andrzej

Justin Bertram

unread,
Dec 13, 2014, 10:58:01 PM12/13/14
to jboss-gene...@googlegroups.com
Couple of points:
  • I'm not sure why you're using the generic JMS JCA RA at all since you're using Spring and not Java EE components.  Remember, JCA is a Java EE technology meant to be used by Java EE components for EIS integration.  Why not simply use the traditional JNDI approach to connect your Spring beans to the remote JBoss AS 4.3 instance?
  • If you are dead set on using the generic JMS JCA RA from your Spring beans to consume JMS messages then you'll need to use a bean that's specifically designed for JCA inflow.  You can't simply look-up the "GenericJmsXA" connection factory you've configured and use that for consuming messages because that connection factory is using the outflow adapter.  In other words, it should only be used for sending messages, not consuming them.
  • To my knowledge there is no way to do a generic admin object for JMS destinations as the admin object must know and use the actual implementation of the underlying JMS destination which would defeat the whole generic nature of the admin object.
Reply all
Reply to author
Forward
0 new messages