1 2 3 Previous Next 36 Replies Latest reply on Oct 13, 2009 3:20 PM by nbhatia Go to original post
      • 30. Re: Low memory warning
        nbhatia

        No no - that's not what I meant. The web requests have nothing to do with processing of JMS messages. The web front-end simply allows users to look at the orders that have been received via JMS. Also I am not creating a MessageListener every time a message arrives. I am simply creating a pool of message consumers on application startup so that multiple JMS messages can be serviced simultaneously. So the code below is executed only once when the web application starts up:

        connection = connectionFactory.createConnection();
        
        for (int i=0; i<concurrentConsumers; i++) {
         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
         MessageConsumer messageConsumer = session.createConsumer(destination);
         messageConsumer.setMessageListener(messageListener);
        }
        


        Hope that's clearer.

        Naresh

        • 31. Re: Low memory warning
          timfox

          It seems to me you're just trying to emulate what MDBs were designed for - why re-invent the wheel?

          But I'm not a JEE expert, and to be honest I always try and avoid JEE - it's not my favourite thing. You might get some better advice about JEE application design from the AS/EJB3 guys who are the experts in this area,

          • 32. Re: Low memory warning
            nbhatia

            You are right. I am trying to avoid JEE myself. EAR comes with lot of baggage that I don't need. Also development cycle slows down.

            • 33. Re: Low memory warning
              timfox

              BTW, Hint, if you create your message listeners at startup in your WAR using a connection obtained from a non JCA RA connection (i.e. don't use java:/JmsXA) then it will probably let you do this.

              Although note that would be illegal according to JEE spec, and your WAR will be non portable, and you won't get connection caching etc if you then go on to do other JMS operations in the onMessage method of your listeners.

              • 34. Re: Low memory warning
                nbhatia

                I want to try that anyway - just for my understanding. So how do you get a non JCA RA connection? Using an initial context lookup?

                Couple of follow-up questions:

                1) The InVM instance that I have in my JBoss AS - is it also exposed on a url (such as jnp://localhost:1099)? In other words, can a standalone client access it by looking it up using jndi?

                2) Instead of an InVM instance, if I start HornetQ as a standalone server, can an MDB listen to it? How would a connection factory be configured for this use case?

                Thanks.
                Naresh

                • 35. Re: Low memory warning
                  timfox

                   

                  "nbhatia" wrote:
                  I want to try that anyway - just for my understanding. So how do you get a non JCA RA connection? Using an initial context lookup?


                  Any other lookup than java:/JmsXA - The one at java:/JmsXA is the wrapped JCA JMS connection factory. Other like java:/ConnectionFactory are standard JMS connection factories.

                  Take a look at this wiki page for more info http://www.jboss.org/community/wiki/ShouldIcacheJMSconnectionsandJMSsessions


                  Couple of follow-up questions:

                  1) The InVM instance that I have in my JBoss AS - is it also exposed on a url (such as jnp://localhost:1099)? In other words, can a standalone client access it by looking it up using jndi?


                  You mean is the JNDI - accessible from another machine? That depends how you have configured JBoss AS JNDI - it's not part of HornetQ


                  2) Instead of an InVM instance, if I start HornetQ as a standalone server, can an MDB listen to it? How would a connection factory be configured for this use case?


                  Take a look at the user manual chapter on JCA config for the answer to this


                  • 36. Re: Low memory warning
                    nbhatia

                    Thanks for the pointers Tim. The Wiki article was excellent - clarified bunch of concepts for me.


                    Any other lookup than java:/JmsXA - The one at java:/JmsXA is the wrapped JCA JMS connection factory. Other like java:/ConnectionFactory are standard JMS connection factories.


                    I tried this and it works like a charm! I know it is against the JEE specs, but this is hell of lot better than the Spring container which is polling for JMS messages every second and creating a new connection every time. My GC runs are now less frequent - from about once every 15 seconds down to once every minute!

                    Thanks.
                    Naresh

                    1 2 3 Previous Next