Spring Boot Application deployed as a war with a JMS Listener- Running out of Threads and Memory

379 Views Asked by At

Hello I have a spring boot application deployed as a war in tomcat. I am listening to messages on a jms topic in the application. I have a TIBCO Message Broker and following is a small snippet of code I have for listening to messages-

             @Bean
             public TibjmsConnectionFactory tibjmsconnectionfactory(){

             TibjmsConnectionFactory tibjmsconnectionFactory=new TibjmsConnectionFactory("http://172.16.23.1");
             tibjmsconnectionFactory.setUsername("abcd");
             tibjmsconnectionFactory.setUserPassword("abcd");
             return tibjmsconnectionFactory;

             }

            @Bean
            public DefaultJmsListenerContainerFactory defaultjms(){
            DefaultJmsListenerContainerFactory defaultJmsContainerFactory=new DefaultJmsContainerFactory();
           defaultJmsListenerContainerFactory.setConnectionFactory(tibjmsconnectionFactory());
           return defaultJmsContainerFactory;
        }

I have a method annotated with @JmsListener where I am receiving the incoming message.

                @JmsListener(destination="topic1",selector=MY_SELECTOR)
                public void onMessage(String msg){
                //Do something with message
                }

When there is a lot of traffic present on the topic(hence lot of messages received), The number of threads in the application ramp up, and never come down. Also, occasionally the memory ramps up, and ultimately the application runs out if memory. I have a heap of around 3 GB and the amount of messages received was around 400,000 in about 30-40 minutes.

I wanted to know, if there is anything I am doing wrong with JMS beans I have above, due to which threads are being occupied and never released.

Thank you in advance.

0

There are 0 best solutions below