0 Replies Latest reply on Nov 11, 2010 9:14 PM by Eugene McKissick

    Outbound communication to a remote ActiveMQ server within JBoss AS

    Eugene McKissick Newbie

      All,

       

      I have successfully created an MDB that creates and consumes information on a remote ActiveMQ server using the following link

       

      http://activemq.apache.org/inbound-communication.html and a lot of articles in the JBoss Community.  After creating a standalone client that successfully accesses the ActiveMQ server directly and having my MDB consume the message in JBoss, I began the task of outbound communication with JBoss AS 5.1.0.  I was hoping the following accompanying document on outbound-communication would help http://activemq.apache.org/outbound-communication.html.  Regretfully this requires using another EJB to send the messages.  I attempted to utilize the document to create a Web Service that would do what the EJB in the example does, but I seem to be confused on a step (or two or three)

       

      On the same server I have the activemq-rar-5.2.0, my TestMDB (that monitors ActiveMQ), and my SenderWS which is contained in a war file.  I deployed the following activemq-jms-ds.xml successfully (meaning Factory and outbound queue show up in my JNDIView)

       

      <?xml version="1.0" encoding="UTF-8"?>

       

      <!DOCTYPE connection-factories
          PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
          "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">

       

      <connection-factories>

       


         <tx-connection-factory>
            <jndi-name>activemq/QueueConnectionFactory</jndi-name>
            <xa-transaction/>
            <track-connection-by-tx/>
            <rar-name>activemq-rar-5.2.0.rar</rar-name>
            <connection-definition>javax.jms.QueueConnectionFactory</connection-definition>
            <ServerUrl>tcp:myserver:61616</ServerUrl>
            <!--
            <UserName>sa</UserName>
            <Password></Password>
            -->
            <min-pool-size>1</min-pool-size>
            <max-pool-size>200</max-pool-size>
            <blocking-timeout-millis>30000</blocking-timeout-millis>
            <idle-timeout-minutes>3</idle-timeout-minutes>
         </tx-connection-factory>

       

         <mbean code="org.jboss.resource.deployment.AdminObject" name="activemq.queue:name=outboundQueue">
            <attribute name="JNDIName">activemq/queue/outbound</attribute>
            <depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='activemq-rar-5.2.0.rar'</depends>
            <attribute name="Type">javax.jms.Queue</attribute>
            <attribute name="Properties">PhysicalName=TEST.NOTIFICATION.DEV</attribute>
         </mbean>
      </connection-factories>

       

      My question is, I understand that I now have a QueueConnectionFactory that should connect me to the ActiveMQ server.  This Factory is available via lookup on my servers JNDI.  This gets me to the QueueConnectionFactory, which should give me the QueueSession I need.  I'm unsure how I can successfully perform the lookup of the Queue that was created by my MDB.  I was hoping that I could link the AdminObject  to the actual queue that is created on the ActiveMQ server by tweaking the above AdminObject section and the following code would work

       

       

       

                  InitialContext initCtx = new InitialContext();
                  QueueConnectionFactory qcf = (QueueConnectionFactory) initCtx.lookup("java:activemq/QueueConnectionFactory");
                 
                  QueueConnection qcon = qcf.createQueueConnection();
                  QueueSession qSession = qcon.createQueueSession(true, 0); //seems ok here
                 
                  Queue queue = (Queue) initCtx.lookup("activemq/queue/outbound");

                  TextMessage txtMsg = qSession.createTextMessage("Now is the winter of your discontent");

       

                 
                  // Create the publisher and publish the message
                  QueueSender qSender = qSession.createSender(queue);
                  qSender.send(txtMsg);

       

                  lastMessage = txtMsg;

       

                  log.debug(logHeader() + txtMsg.toString());
                 
                  return txtMsg.getJMSMessageID();

       

      I get no errors from my JNDI lookups, but the Queue registers no new messages in ActiveMQ. In the EJB implementation I see quite a bit of linkages using the jboss.xml

      specifcally this

       

      <assembly-descriptor>
            <message-destination>
               <message-destination-name>LoggingQueue</message-destination-name>
               <jndi-name>activemq/queue/outbound</jndi-name>
            </message-destination>
         </assembly-descriptor>

       

      Is their an equivalent configuration I can use for a JBossWS web service maybe in the jboss-web.xml?  Any help or advice would be appreciated.

       

       

      Thanks