9 Replies Latest reply on Oct 15, 2003 5:03 PM by adrian.brock

    MDB Connecting to remote queues

    p_d_austin

      I have a application with a StatelessSession bean that publishes to a Topic. Both the topic and StatelessSession bean are in the same instance of jboss.

      I have a MessageDriven bean that subscribes to the topic consumes the messages. The MDB is depolyed on one or more instances of jboss.

      If I deploy both the client SLSB and the MDB in the same instance everything works well. If I try to deploy the MDB's on different machines it fails to work.

      The way I think this should work is that in the jboss.xml deployment descriptor you should be able to specify the full jndi name of the topic (i.e. jnp://remotehost:1099/topic/myTopic) and the it looks up the topic on the remote host. Looking at the source code this is not possible as it only looks at the last part of the url after the first /.

      Looking at the old list I managed to find an example that added the following to the or.jboss.jms.jndi.JMSProviderLoade MBean. This also did not work, it did not give any exceptions but the MDB's were not receiving the messages.

      remotehost:1099

      I am trying this on JBoss 2.4.3/Jetty in Windows 2000.

      Any help on how to connect MDB's to remote queues with a working example would be greatly appriciated.

      cheers,
      Paul

        • 1. Re: MDB Connecting to remote queues

          Have you defined a new Provider MBean, with a new name, remoable destinations (not in vm) and a remote ProviderURL and then used the name of that MBean in RemoteJMSProvider in the MDB deployment descriptor?

          //Peter

          • 2. Re: MDB Connecting to remote queues
            rajsaini

            Hi all,

            I have successfully connected to a remote Jboss (jbossMQ) from a MDB (runing on another machine). I would post the details tomorrow. This can be addes a section to the documentation

            • 3. Re: MDB Connecting to remote queues
              rajsaini

              Configure jboss.jcm in the conf/default directory

              The following lines configure the default JMS provider in the jbosss.jcml which is names as DefaultJMSProvider.

              <!-- For Message Driven Beans -->

              DefaultJMSProvider
              org.jboss.jms.jndi.JBossMQProvider
              java:/XAConnectionFactory
              java:/XAConnectionFactory


              to configure a remote JMS provider for MDBs you will need to add one more remote JMS Provider.
              Add the following code in your jboss.jcm file just below the above mentioned lines. Change host name to the actulal name of your host. (In my cse it is tiger)

              <!-- For Message Driven Beans -->
              RemoteJMSProvider
              tiger:1099
              XAConnectionFactory
              XAConnectionFactory
              org.jboss.jms.jndi.JBossMQProvider



              Smple MDB class

              import javax.ejb.MessageDrivenBean;
              import javax.ejb.MessageDrivenContext;
              import javax.ejb.EJBException;

              import javax.jms.MessageListener;
              import javax.jms.Message;

              /**
              * Simple HelloWorld Message Driven Bean. May be bound to both a Topic
              * or a Queue through the deployment descriptor.
              *
              * Created: Thu Jul 26 13:20:32 2001
              *
              * @author Peter Antman
              * @version $Revision: 1.3 $ $Date: 2001/09/27 16:30:27 $
              */
              public class HelloMDB implements MessageDrivenBean, MessageListener {

              private MessageDrivenContext ctx = null;

              public HelloMDB() {

              }

              //--- MessageDrivenBean
              public void setMessageDrivenContext(MessageDrivenContext ctx)
              throws EJBException {

              this.ctx = ctx;

              }

              public void ejbCreate() {}
              public void ejbRemove() {ctx=null;}

              //--- MessageListener
              public void onMessage(Message message) {

              System.err.println("Bean got message" + message.toString());

              }

              } // HelloMDB

              ejb-jar deployment descriptor for the HelloMDB.java
              <?xml version="1.0"?>
              <!DOCTYPE ejb-jar>
              <ejb-jar>
              <enterprise-beans>
              <message-driven>
              <ejb-name>HelloQueueMDB</ejb-name>
              <ejb-class>HelloMDB</ejb-class>
              <message-selector></message-selector>
              <transaction-type>Container</transaction-type>
              <message-driven-destination>
              <destination-type>javax.jms.Queue</destination-type>
              </message-driven-destination>
              </message-driven>
              </enterprise-beans>
              <assembly-descriptor>
              <container-transaction>

              <ejb-name>HelloQueueMDB</ejb-name>
              <method-name>*</method-name>

              <trans-attribute>NotSupported</trans-attribute>
              </container-transaction>
              </assembly-descriptor>
              </ejb-jar>

              Jboss.xml file for the helloMDB.java <?xml version="1.0" encoding="Cp1252"?>

              <enterprise-beans>
              <message-driven>
              <ejb-name>HelloQueueMDB</ejb-name>
              <configuration-name>My Message Driven Config</configuration-name>
              <destination-jndi-name>queue/testQueue</destination-jndi-name>
              </message-driven>
              </enterprise-beans>
              <container-configurations>
              <container-configuration>
              <container-name>My Message Driven Config</container-name>
              <call-logging>false</call-logging>
              <container-invoker>org.jboss.ejb.plugins.jms.JMSContainerInvoker</container-invoker>
              <container-interceptors>
              org.jboss.ejb.plugins.LogInterceptor
              org.jboss.ejb.plugins.SecurityInterceptor
              <!-- CMT -->
              org.jboss.ejb.plugins.TxInterceptorCMT
              org.jboss.ejb.plugins.MetricsInterceptor
              org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor
              <!-- BMT -->
              org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor
              org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT
              org.jboss.ejb.plugins.MetricsInterceptor
              </container-interceptors>
              <instance-pool>org.jboss.ejb.plugins.MessageDrivenInstancePool</instance-pool>
              <instance-cache></instance-cache>
              <persistence-manager></persistence-manager>
              <transaction-manager>org.jboss.tm.TxManager</transaction-manager>
              <container-invoker-conf>
              RemoteJMSProvider
              StdJMSPool
              15
              1
              True
              </container-invoker-conf>
              <container-pool-conf>
              100
              10
              </container-pool-conf>
              </container-configuration>
              </container-configurations>


              I want to add this in the online manual or a kind of HOWTO for connecting to the remote JMS. Does any body knows how to do this?

              mail me at rajbsaini@rediffmail.com if you need further help.

              cheers

              • 4. Re: MDB Connecting to remote queues
                sonwh98

                I am having trouble configuring an MDB to accept messages from a remote queue on jboss3.2.1. I purchased the documentation, but this is not documented

                The remote queue is on machine A and the MDB is on machine B. I added the following to $jbossHome/server/default/deploy/jms/jms-ds.xml on machine B:


                RemoteJMSProvider
                org.jboss.jms.jndi.JBossMQProvider
                cyclop.openbx.net:1099
                XAConnectionFactory
                XAConnectionFactory


                in jboss.xml I have


                <enterprise-beans>

                <message-driven>
                <ejb-name>SaleMessageBean</ejb-name>
                <destination-jndi-name>queue/testQueue</destination-jndi-name>
                </message-driven>

                </enterprise-beans>

                <resource-managers>
                </resource-managers>

                <container-configurations>
                <container-configuration>
                <container-name>My Message Driven Config</container-name>
                <call-logging>false</call-logging>
                <container-invoker>org.jboss.ejb.plugins.jms.JMSContainerInvoker</container-invoker>
                <container-interceptors>
                org.jboss.ejb.plugins.LogInterceptor
                org.jboss.ejb.plugins.SecurityInterceptor
                <!-- CMT -->
                org.jboss.ejb.plugins.TxInterceptorCMT
                org.jboss.ejb.plugins.MetricsInterceptor
                org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor
                <!-- BMT -->
                org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor
                org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT
                org.jboss.ejb.plugins.MetricsInterceptor
                </container-interceptors>

                <instance-pool>org.jboss.ejb.plugins.MessageDrivenInstancePool</instance-pool>
                <instance-cache></instance-cache>
                <persistence-manager></persistence-manager>
                <transaction-manager>org.jboss.tm.TxManager</transaction-manager>
                <container-invoker-conf>
                RemoteJMSProvider
                StdJMSPool
                15
                1
                True
                </container-invoker-conf>
                <container-pool-conf>
                100
                10
                </container-pool-conf>
                </container-configuration>
                </container-configurations>



                I start Jboss on both machine A and machine B. I write a message to queue/testQueue on machine A, but the MDB on machine B does not pick it up. If I write to the queue/TestQueue on machine B, the MDB on machine B does pick it up. What am I doing wrong?

                this is for jboss3.2.1

                thanks for any pointers

                • 5. Re: MDB Connecting to remote queues

                  You are using a 3.0 config in 3.2

                  How come you found a post from last year, but didn't see
                  the example from this week?

                  Always start a new thread rather than saying me too.
                  "Me toos" are normally ignored and just create noisy threads
                  that are difficult to read.

                  Regards,
                  Adrian

                  • 6. Re: MDB Connecting to remote queues
                    sonwh98

                    After reading http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd and some experimenting, I got an MDB configured to read from a remote queue for jboss3.2.1. Hopefully this will help others.

                    first add another JMSProviderLoader to jboss-3.2.1/server/default/deploy/jms-ds.xml:


                    RemoteJMSProvider
                    org.jboss.jms.jndi.JBossMQProvider
                    remoteHost.com:1099
                    XAConnectionFactory
                    XAConnectionFactory


                    don't modify standardjboss.xml as mentioned in previously unless you want all your MDB to read from remoteHost.com.
                    Instead you can specify this for each MDB in jboss.xml

                    for example my jboss.xml looks like:

                    <?xml version="1.0" encoding="UTF-8"?>
                    <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">



                    <enterprise-beans>

                    <!--
                    To add beans that you have deployment descriptor info for, add
                    a file to your XDoclet merge directory called jboss-beans.xml that contains
                    the , and <message-driven></message-driven>
                    markup for those beans.
                    -->

                    <message-driven>
                    <ejb-name>SaleMessageBean</ejb-name>
                    <destination-jndi-name>queue/testQueue</destination-jndi-name>
                    <invoker-bindings>

                    <invoker-proxy-binding-name>foo</invoker-proxy-binding-name> <!-- must match name of invoker-proxy-binding-->

                    </invoker-bindings>
                    </message-driven>

                    </enterprise-beans>

                    <!--copied this from jboss-3.2.1/server/default/conf/standardjboss.xml-->
                    <invoker-proxy-bindings>
                    <invoker-proxy-binding>
                    foo
                    <invoker-mbean/>
                    <proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-factory>
                    <proxy-factory-config>
                    RemoteJMSProvider
                    StdJMSPool
                    15
                    1

                    10

                    queue/DLQ
                    10
                    0


                    </proxy-factory-config>
                    </invoker-proxy-binding>
                    </invoker-proxy-bindings>



                    jar up your MDB with the standard ejb-jar.xml deployment descriptor and with the jboss.xml and deploy. That's all there is to it. I wish this was in the Jboss documentation.

                    • 7. Re: MDB Connecting to remote queues
                      koalajboss

                      I am a fleshman in Jboss.
                      the question is "if the remoteJmsProvider has been shutDown ,what happen in my Jboss!"
                      thx.

                      • 8. Re: MDB Connecting to remote queues
                        koalajboss

                        According UP Config My file and MDB
                        I catch execption details:(why?)

                        15:06:06,609 INFO [DLQHandler] Creating
                        15:06:36,640 INFO [DLQHandler] Created
                        15:06:36,656 INFO [DLQHandler] Starting
                        15:06:36,656 INFO [DLQHandler] Started
                        15:06:36,656 INFO [JMSContainerInvoker] Reconnected to JMS provider
                        15:06:36,656 WARN [NestedThrowable] Duplicate throwable nesting of same base ty
                        pe: class org.jboss.mq.SpyJMSException is assignable from: class org.jboss.mq.Sp
                        yJMSException
                        15:06:36,656 WARN [Connection] Connection failure:
                        org.jboss.mq.SpyJMSException: Could not pong; - nested throwable: (java.rmi.Remo
                        teException: Cannot connect to the ConnectionReceiver/Server)
                        Caused by: java.rmi.RemoteException: Cannot connect to the ConnectionReceiver/Se
                        rver
                        15:06:36,671 WARN [NestedThrowable] Duplicate throwable nesting of same base ty
                        pe: class org.jboss.mq.SpyJMSException is assignable from: class org.jboss.mq.Sp
                        yJMSException
                        15:06:36,671 WARN [JMSContainerInvoker] JMS provider failure detected:
                        org.jboss.mq.SpyJMSException: Could not pong; - nested throwable: (java.rmi.Remo
                        teException: Cannot connect to the ConnectionReceiver/Server)
                        Caused by: java.rmi.RemoteException: Cannot connect to the ConnectionReceiver/Se
                        rver

                        • 9. Re: MDB Connecting to remote queues

                          Your post has been ignored:

                          1) Do not hijack other people's threads, start a new one.
                          You just create noise.
                          2) Use search to find an explanation for "could not pong"

                          Regards,
                          Adrian