以前正常工作很长时间。当我尝试循环10000个项目并逐个发送到jms队列时,就会发生此错误。
尝试将消息发送到我的JMS队列时出现以下错误:
org.springframework.jms.UncategorizedJmsException:未分类 JMS处理期间发生异常;嵌套异常是 javax.jms.JMSException:java.lang.InterruptedException at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316) 在 org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169) 在 org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:487) 在 org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:570) 在 com.shop.my.utility.exception.GlobalExceptionHandler.handleMyException(GlobalExceptionHandler.java:82) 在 com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.lambda $ 11(GlobalTimeoutScheduler.java:182) 在java.util.ArrayList.forEach(ArrayList.java:1255)at com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.handleMyException(GlobalTimeoutScheduler.java:178) 在 com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.updateStatusByObjectTypeId(GlobalTimeoutScheduler.java:156) 在 com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.lambda $ 5(GlobalTimeoutScheduler.java:103) 在java.util.HashMap.forEach(HashMap.java:1289)at com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.processGlobalTimeout(GlobalTimeoutScheduler.java:100) 在 com.shop.my.myengine.scheduler.GlobalTimeoutScheduler.lambda $ 0(GlobalTimeoutScheduler.java:70) 在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) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498)at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) 在 org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) 在 java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) 在 java.util.concurrent.ScheduledThreadPoolExecutor中的$ ScheduledFutureTask.access $ 301(ScheduledThreadPoolExecutor.java:180) 在 java.util.concurrent.ScheduledThreadPoolExecutor中的$ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 在 java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:624) 在java.lang.Thread.run(Thread.java:748)引起: javax.jms.JMSException:java.lang.InterruptedException at org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.doSendx(ActiveMQMessageProducer.java:494) 在 org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:198) 在 org.springframework.jms.connection.CachedMessageProducer.send(CachedMessageProducer.java:181) 在sun.reflect.GeneratedMethodAccessor167.invoke(未知来源)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:498)at org.springframework.jms.connection.CachedMessageProducer $ Jms2MessageProducerInvocationHandler.invoke(CachedMessageProducer.java:293) 在com.sun.proxy。$ Proxy346.send(未知来源)at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:626) 在 org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:597) 在 org.springframework.jms.core.JmsTemplate $ 4.doInJms(JmsTemplate.java:574) 在 org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:484) ... 25更多引起: org.apache.activemq.artemis.api.core.ActiveMQInterruptedException: java.lang.InterruptedException at org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:380) 在 org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:318) 在 org.apache.activemq.artemis.core.protocol.core.impl.ActiveMQSessionContext.sendFullMessage(ActiveMQSessionContext.java:418) 在 org.apache.activemq.artemis.core.client.impl.ClientProducerImpl.sendRegularMessage(ClientProducerImpl.java:287) 在 org.apache.activemq.artemis.core.client.impl.ClientProducerImpl.doSend(ClientProducerImpl.java:263) 在 org.apache.activemq.artemis.core.client.impl.ClientProducerImpl.send(ClientProducerImpl.java:126) 在 org.apache.activemq.artemis.jms.client.ActiveMQMessageProducer.doSendx(ActiveMQMessageProducer.java:491) ... 36更多引起:java.lang.InterruptedException at java.util.concurrent.locks.AbstractQueuedSynchronizer中的$ ConditionObject.reportInterruptAfterWait(AbstractQueuedSynchronizer.java:2014) 在 java.util.concurrent.locks.AbstractQueuedSynchronizer中的$ ConditionObject.await(AbstractQueuedSynchronizer.java:2173) 在 org.apache.activemq.artemis.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:378) ......还有42个
我的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;
}
}
我的类处理程序帮助将消息发送到队列:
@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();
}
}
答案 0 :(得分:0)
引起:
的java.lang.InterruptedException
应用程序中的某些内容在发送时中断了您的线程。