Spring

 JMS Listener not consuming messages from the JMS Queue.

JAGADHISH DADI's profile image
JAGADHISH DADI posted Oct 01, 2019 09:46 PM

JMS Listener not consuming messages from the JMS Queue.

 

Consuming messages stopped working all of sudden, consumer count came to zero not increasing even though messages are being added to the queues.

 

Our Code Snippet:

 

 

```

**Config Class**

@Configuration

@ComponentScan

@EnableSwagger2

@EnableJms

@EnableAutoConfiguration

@EnableCaching

@PropertySource("classpath:application-resources.properties")

@JBossLog

public class MyApp extends SpringBootServletInitializer {

 

 private static Class<MyApp> applicationClass = MyApp.class;

 

 @Override

 protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

  return application.sources(applicationClass);

 }

  

 @Bean

 public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(

   ConnectionFactory connectionFactory, MyAppJmsErrorHandler errorHandler) {

  DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();

  factory.setConnectionFactory(connectionFactory);

  factory.setErrorHandler(errorHandler);

  return factory;

 }

 

 @Service

 public class MyAppJmsErrorHandler implements ErrorHandler {

  @Override

  public void handleError(Throwable t) {

   log.error(t.getStackTrace());

  }

 }

}

 

 

**Listener Class:**

@Component

public class MyListener {

 

 @Autowired

 TestService serviceInstance;

 

 /**

  

  * @param request

  */

 @JmsListener(destination = TEST_QUEUE, concurrency = "100")

 public void onMessage(IncomingRequest request) {

  serviceInstance.callDB();

 }

 

 }

Daniel Mikusa's profile image
Daniel Mikusa

Is this reproducible? Like if you follow a set of steps you can make this happen again with your app? or is this a one-off problem that you encountered where messages stopped but after restarting your app they are fine again? Just trying to understand the situation more. Thanks.

JAGADHISH DADI's profile image
JAGADHISH DADI
It is not reproducible. One off a problem that encountered in production environment. Messages are bring added but not consumed. After restarting everything back to normal. Jagadhish.
Daniel Mikusa's profile image
Daniel Mikusa

OK, that can make it quite hard to really say what was happening at the time. Did you capture logs from the event? Do you have thread dumps of the app at the time of the problem? When an app hangs or stops doing what it should, taking multiple thread dumps is usually a good way to piece together the state of what threads were doing at the time.

 

I guess the other option would be if you had an APM tool enabled on your app at the time and were capturing data with it. That might be enough to discern what happened.

 

If you have logs, thread dumps and/or APM info you can share, I would suggest opening a ticket with Pivotal Support and requesting analysis.

 

https://content.pivotal.io/support/support-quick-links-2

 

Hope that helps!