首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >弹簧JMSTemplate UncategorizedJmsException和ArtemisMQ

弹簧JMSTemplate UncategorizedJmsException和ArtemisMQ
EN

Stack Overflow用户
提问于 2018-04-25 01:06:20
回答 1查看 2.3K关注 0票数 0

很久以前就正常工作了。当我试图循环10000项并将一个接一个地发送到jms队列时,就会发生此错误。

当试图向JMS队列发送消息时,我会收到以下错误:

org.springframework.jms.UncategorizedJmsException:处理过程中出现未分类异常;嵌套的例外是org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316):java.lang.InterruptedException 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(( 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) )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)在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) atjava.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)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) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang。org.springframework.jms.connection.CachedMessageProducer$Jms2MessageProducerInvocationHandler.invoke(CachedMessageProducer.java:293)的reflect.Method.invoke(Method.java:498)在com.sun.Proxy。$Proxy346。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) 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( 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) ) .doSendx(ActiveMQMessageProducer.java:491) .又增加了36人

我的JMSConfig:

代码语言:javascript
复制
@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;
  }
}

我的类处理程序帮助将消息发送到队列:

代码语言:javascript
复制
@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();
  }
}
EN

回答 1

Stack Overflow用户

发布于 2018-04-25 12:58:07

致因: java.lang.InterruptedException at

应用程序中的某些内容在线程发送时中断了您的线程。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50012650

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档