'Spring JMSTemplate UncategorizedJmsException with ArtemisMQ

It works normal long time before. this error just happens when I try to loop 10000 items and send one-by-one to jms queue.

I am getting the following error when trying to send message to my JMS queue:

org.springframework.jms.UncategorizedJmsException: Uncategorized exception occurred during JMS processing; nested exception is javax.jms.JMSException: java.lang.InterruptedException at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316) at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169) at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:487) at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:570) at com.shop.my.utility.exception.GlobalExceptionHandler.handleMyException(GlobalExceptionHandler.java:82) at com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.lambda$11(GlobalTimeoutScheduler.java:182) at java.util.ArrayList.forEach(ArrayList.java:1255) at com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.handleMyException(GlobalTimeoutScheduler.java:178) at com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.updateStatusByObjectTypeId(GlobalTimeoutScheduler.java:156) at com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.lambda$5(GlobalTimeoutScheduler.java:103) at java.util.HashMap.forEach(HashMap.java:1289) at com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.processGlobalTimeout(GlobalTimeoutScheduler.java:100) at com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.lambda$0(GlobalTimeoutScheduler.java:70) at java.util.HashMap.forEach(HashMap.java:1289) at com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.scheduleProcessGlobalTimeout(GlobalTimeoutScheduler.java:69) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: javax.jms.JMSException: java.lang.InterruptedException at org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.doSendx(ActiveMQMessageProducer.java:494) at org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:198) at org.springframework.jms.connection.CachedMessageProducer.send(CachedMessageProducer.java:181) at sun.reflect.GeneratedMethodAccessor167.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.jms.connection.CachedMessageProducer$Jms2MessageProducerInvocationHandler.invoke(CachedMessageProducer.java:293) at com.sun.proxy.$Proxy346.send(Unknown Source) at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:626) at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:597) at org.springframework.jms.core.JmsTemplate$4.doInJms(JmsTemplate.java:574) at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:484) ... 25 more Caused by: org.apache.activemq.artemis.api.core.ActiveMQInterruptedException: java.lang.InterruptedException at org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:380) at org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:318) at org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQSessionContext.sendFullMessage(ActiveMQSessionContext.java:418) at org.apache.activemq.artemis.core.client.impl.ClientProducerImpl.sendRegularMessage(ClientProducerImpl.java:287) at org.apache.activemq.artemis.core.client.impl.ClientProducerImpl.doSend(ClientProducerImpl.java:263) at org.apache.activemq.artemis.core.client.impl.ClientProducerImpl.send(ClientProducerImpl.java:126) at org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.doSendx(ActiveMQMessageProducer.java:491) ... 36 more Caused by: java.lang.InterruptedException at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2014) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2173) at org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:378) ... 42 more

My JMSConfig:

@Configuration
public class JMSConfig {
  @Value("${spring.artemis.host}")
  private String artemisHost;
  @Value("${spring.artemis.port}")
  private String artemisPort;
  @Value("${spring.artemis.user}")
  private String artemisUser;
  @Value("${spring.artemis.password}")
  private String artemisPass;
  @Bean
  @Primary
  public CachingConnectionFactory cachingConnectionFactory() {
    StringBuilder artemisURL = new StringBuilder();
    artemisURL.append("tcp://").append(artemisHost).append(":").append(artemisPort).append("?jms.useAsyncSend=true");
    ActiveMQConnectionFactory artemiConnFactory = new ActiveMQConnectionFactory(artemisURL.toString());
    artemiConnFactory.setUser(artemisUser);
    artemiConnFactory.setPassword(artemisPass);
    artemiConnFactory.setConsumerWindowSize(0);
    CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(artemiConnFactory);
    cachingConnectionFactory.setSessionCacheSize(20);
    return cachingConnectionFactory;
  }
  @Bean
  @Primary
  public JmsTemplate jmsTemplate(@Qualifier("cachingConnectionFactory") CachingConnectionFactory connectionFactory) {
    JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
    return jmsTemplate;
  }
}

My class handler help sending message to queue:

@Aspect
@Component
public class MyGlobalExceptionHandler {

  @Autowired
  private JmsTemplate jmsTemplate;
  @Value("${environment}.${errlog.log.queue}")
  private String errorLogQueue;
  @Value("${spring.application.name}")
  private String applicationName;

  @AfterThrowing(
      pointcut = "within(com.my.service..*..*) && (@annotation(org.springframework.web.bind.annotation.RequestMapping) || @annotation(org.springframework.jms.annotation.JmsListener))",
      throwing = "myException")
  public Response<Void> handleException(MyException myException) {
    ErrLogRequest logRequest = LoggerBuilder.build(myException, applicationName);
    jmsTemplate.send(errorLogQueue, session -> session.createTextMessage(logRequest.toString()));
    return Response.<Void>builder().status(myException.errorCode).build();
  }
}


Solution 1:[1]

Caused by: java.lang.InterruptedException at

Something in your application interrupted your thread while it was sending.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gary Russell