5 Replies Latest reply on Mar 26, 2009 10:57 AM by Adrian Brock

    Can the Code get a QueueConnection objcect per request

    Ritesh Shetty Newbie

      My Webapplication Code on the JBOSS Appserver accesses the JBOSSMQ.
      My question is Can the Code get a QueueConnection object per request ?
      Or do i still need to maintain some sort of Connection pool to access the JbossMQ knowing that JBOSS MQ had its own connection pool.

        • 1. Re: Can the Code get a QueueConnection objcect per request
          Adrian Brock Master

           

          "shetty_ritesh" wrote:
          My Webapplication Code on the JBOSS Appserver accesses the JBOSSMQ.
          My question is Can the Code get a QueueConnection object per request ?


          You can but its an anti-pattern without a pool


          Or do i still need to maintain some sort of Connection pool


          java:/JmsXA


          to access the JbossMQ knowing that JBOSS MQ had its own connection pool.


          JBossMQ doesn't have a connection pool, JBoss JCA does for the jms resource
          adapter bound at the jndi name I gave above.

          • 2. Re: Can the Code get a QueueConnection objcect per request
            Ritesh Shetty Newbie

            Adrian, thanks for your inputs.
            If i use the following jboss resource adaptor connection pooling mechanism is it correct. We are currently using the jndi name "ConnectionFactory" for looking up the connection . Will this be ok if i get the connection every request and then close it (as i am using the jca resource adaptor)
            Also am a bit conused as to whould i be using "ConnectionFactory" or "java:/JmsXA" to look up for the connection

            Your anwer is greatly appreciated..


            The file is jms-ds.xml*****************

            <!-- The JMS provider loader -->

            DefaultJMSProvider

            org.jboss.jms.jndi.JNDIProviderAdapter

            <!-- The combined connection factory -->
            java:/XAConnectionFactory
            <!-- The queue connection factory -->
            java:/XAConnectionFactory
            <!-- The topic factory -->
            java:/XAConnectionFactory
            <!-- Uncomment to use HAJNDI to access JMS

            java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
            java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
            java.naming.provider.url=localhost:1100

            -->


            <!-- The server session pool for Message Driven Beans -->

            <depends optional-attribute-name="XidFactory">jboss:service=XidFactory
            StdJMSPool

            org.jboss.jms.asf.StdServerSessionPoolFactory



            <!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->
            <tx-connection-factory>
            <jndi-name>JmsXA</jndi-name>
            <xa-transaction/>
            <rar-name>jms-ra.rar</rar-name>
            <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
            <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
            <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>
            <max-pool-size>20</max-pool-size>
            <security-domain-and-application>JmsXARealm</security-domain-and-application>
            </tx-connection-factory>



            Also the uil2-service.xml file has folowing entries (same as per j boss docs)



            <!-- JBossMQ using the Unified Invocation Layer
            All communication uses one socket connection -->



            <!-- The server chain -->
            <depends optional-attribute-name="Invoker">jboss.mq:service=Invoker
            <!-- JNDI binding -->
            ConnectionFactory
            <!-- JNDI binding for XA -->
            XAConnectionFactory
            <!-- The bind address -->
            ${jboss.bind.address}
            <!-- The bind port -->
            8093
            <!-- The ping period in millis -->
            60000
            <!-- Whether tcp/ip does not wait for buffer fills -->
            true
            <!-- Used to disconnect the client on the serverside if there is no activity -->
            <!-- Ensure this is greater than the ping period -->
            120000
            <!-- Used to disconnect the client on the clientside if there is no activity -->
            <!-- Ensure this is greater than the ping period -->
            120000
            <!-- The size of the buffer (in bytes) wrapping the socket -->
            <!-- The buffer is flushed after each request -->
            2048
            <!-- Large messages may block the ping/pong -->
            <!-- A pong is simulated after each chunk (in bytes) for both reading and writing -->
            <!-- It must be larger than the buffer size -->
            1000000


            <!-- Aliases UIL -> UIL2 for backwards compatibility
            the deprecated UIL deployment can be found in docs/examples/jca -->

            UILConnectionFactory
            ConnectionFactory
            jboss:service=Naming


            UILXAConnectionFactory
            XAConnectionFactory
            jboss:service=Naming


            UIL2ConnectionFactory
            ConnectionFactory
            jboss:service=Naming


            UIL2XAConnectionFactory
            XAConnectionFactory
            jboss:service=Naming


            <!--
            Two JNDI bindings that act like jms client connections remotely
            but have j2ee defined semantics inside JBoss
            -->

            QueueConnectionFactory
            ConnectionFactory
            java:/JmsXA
            jboss:service=Naming


            TopicConnectionFactory
            ConnectionFactory
            java:/JmsXA
            jboss:service=Naming

            • 3. Re: Can the Code get a QueueConnection objcect per request
              Adrian Brock Master

              ConnectionFactory is for remote java client style usage.
              java:/JmsXA is for pooled/transactional usage inside the app server.


              • 4. Re: Can the Code get a QueueConnection objcect per request
                vandana awat Newbie

                Hi Adrian
                i had a confusion as you said ConnectionFactory is for remote client connection and java:/JmsXA is for pooled/transacted within container apps.

                does this mean that we cannot leverage JMS connection pooling of JBOSS from standalone Java clients ?

                IS there any way we could have a pooling mechanisms for JMS connections or sessions for standalone java class.

                • 5. Re: Can the Code get a QueueConnection objcect per request
                  Adrian Brock Master

                  Remote access to a pool is an anti-pattern.

                  The serverside JMS semantics are different to client semantics anyway.

                  Either create the pool inside the client (although for a normal java client its better
                  to just create one connection and then create session as required - e.g. per thread)
                  Or use an SLSB to give remote access, there's an old example of such an EJB on the WIKI.