天道酬勤,学无止境

spring-jms

Properly Shutting Down ActiveMQ and Spring DefaultMessageListenerContainer

Our system will not shutdown when a "Stop" command is issued from the Tomcat Manager. I have determined that it is related to ActiveMQ/Spring. I have even figured out how to get it to shutdown, however my solution is a hack (at least I hope this isn't the "correct" way to do it). I would like to know the proper way to shutdown ActiveMQ so that I can remove my hack. I inherited this component and I have no information about why certain architectural decisions were made, after a lot of digging I think I understand his thoughts, but I could be missing something. In other words, the real problem

2021-06-15 07:52:16    分类:问答    activemq   spring-jms

如何在 Spring Java Config 的单个 MessageListenerContainer 中添加多个 JMS MessageListner(How to add multiple JMS MessageListners in a single MessageListenerContainer for Spring Java Config)

问题 我的 spring-config.xml 中有以下 xml 代码 <jms:listener-container acknowledge="auto" connection-factory="cachedConnectionFactory" container-type="default" error-handler="consumerErrorHandler" concurrency="20-25"> <jms:listener destination="#{TaskFinished.destination}" method="onMessage" ref="taskFinished" /> </jms:listener-container> 现在,我正在将 spring xml 配置文件转换为 Java 配置。 我把它翻译成 @Bean(name = "consumerJmsListenerContainer") public DefaultMessageListenerContainer consumerJmsListenerContainer() { DefaultMessageListenerContainer messageListenerContainer = new DefaultMessageListenerContainer()

2021-06-11 14:06:49    分类:技术分享    java   xml   spring   jms   spring-jms

DefaultMessageListenerContainer 未收到消息(DefaultMessageListenerContainer not receiving messages)

问题 我有一个 DefaultMessageListenerContainer 配置如下: DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); container.setConcurrentConsumers(4); container.setConnectionFactory(connectionFactory); container.setDestinationName(String.format("Consumer.%s.VirtualTopic.%s", group, topic)); container.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE); container.setSessionTransacted(true); container.setMessageListener(new DelegatingMessageListener(listener, messageMapper, event)); container.start(); 消息容器从不接收消息,也从不调用我的消息侦听器。 保持所有其他不变,如果我只是将 DefaultMessageListenerContainer 切换到

2021-06-11 11:12:15    分类:技术分享    spring   jms   activemq   spring-jms

JMS connections exhausted using WebSphere MQ

I have configured CachingConnectionFactory that wraps a MQTopicConnectionFactory and MQQueueConnectionFactory with cache size set to 10 each. These are than used in several jms:outbound-channel-adapter or jms:message-driven-channel-adapter as part of various spring integration workflows that I have in my application. It is noticed that once in a while the connection count on MQ channel reaches maximum allowed (about 1000) when the process stops functioning. This is a serious problem for a production application. Bringing the application down does not reduce the connection count so looks like

2021-06-10 14:17:29    分类:问答    spring-integration   ibm-mq   spring-jms

Does Spring actually start a new transaction with REQUIRES_NEW?

My spring (4.1.1) application is deployed on a JBoss-6.10-final instance, so it uses the container-based transaction manager and data sources. For messaging, I use TIBCO EMS 8.1 with an XA queue connection factory set up. The Java version is 1.8.0_20. All of this is running on my Ubuntu 14.04 laptop. I need to send a request via JMS and then wait for the reply. The bean I’m calling from has transaction propagation set to Propagation.REQUIRED, so I need to send the request in a new transaction and then wait for the reply. This means the request is sent in a separate bean with transaction

2021-06-09 15:11:30    分类:问答    java   jboss   spring-transactions   spring-jms

Spring Boot multiple JMS connections

I'm developing Spring Boot application which must connect to several WebSphere JMS connections with different ports or even ip addresses. I need receive and send messages to different queues. I took example of connection from this source - https://github.com/lzp4ever/IBM_WebSphere_MQ_Spring_Boot_JMS But when i add second connectionFactory Spring Boot failes to start, it just don't know which once to use. My question is How should i configure my config file to listen several queues? Is it good idea connecting SpringBoot app to several different JMS servers?

2021-06-09 13:41:06    分类:问答    java   spring   spring-boot   jms   spring-jms

How to set ActiveMQ port in Spring Boot?

I have two Spring Boot applications running on one server. Both use embedded ActiveMQ JMS. I want to have separate JMS instance for each application. How could I set the port for each of them? Is there any property like spring.activemq.port? When I run second application I get the following expected error: Failed to start JMX connector Cannot bind to URL [rmi://localhost:1099/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]. Will restart management to re-create JMX connector, trying to remedy this issue.

2021-06-09 09:24:35    分类:问答    java   spring   spring-boot   activemq   spring-jms

@JmsListener用于发布-订阅主题(@JmsListener usage for publish-subscribe topic)

问题 我正在尝试基于@JmsListener注释创建发布-订阅示例:https://github.com/lkrnac/book-eiws-code-samples/tree/master/05-jms/0515-publish-subscribe 相关代码段: @Slf4j @SpringBootApplication @EnableScheduling public class JmsPublishSubscribeApplication { public static void main(String[] args) throws InterruptedException { SpringApplication.run(JmsPublishSubscribeApplication.class, args); } @Bean public ActiveMQTopic simpleTopic() { return new ActiveMQTopic("simpleTopic"); } } @Component public class SimpleMessageListener1 { @JmsListener(destination = "simpleTopic") public void readMessage(String message) { //.... } }

2021-06-01 14:15:40    分类:技术分享    spring   spring-jms

JMS 侦听器异常时重新传递 JMS 消息(JMS message redelivery on exception in JMS listener)

问题 org.springframework.jms.listener.AbstractMessageListenerContainer Javadoc 声明,如果 “sessionAcknowledgeMode”设置为“CLIENT_ACKNOWLEDGE”:监听器执行成功后自动确认消息; 在抛出异常的情况下不重新发送。 我想,“在抛出异常的情况下不重新传递”意味着,即使在 jms 侦听器中抛出异常,也不会重新传递该消息(因此,我的猜测,它会被确认)。 但是,好吧,从侦听器抛出的异常意味着对它的调用没有成功,并且由于没有确认而应该重新传递。 问题是: 如果在 jms 侦听器中抛出异常,消息确认实际上应该发生什么? 真正发生的事情,可以从这个堆栈跟踪中看到: at org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:98) at org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter.onMessage(MessagingMessageListenerAdapter.java:66) at org

2021-06-01 10:12:04    分类:技术分享    java   spring   spring-jms

IBM MQManager作为带有Spring-jms和Spring-tx的XA事务管理器(IBM MQManager as XA Transaction Manager with Spring-jms and Spring-tx)

问题 我们正尝试将IBM MQ管理器用作具有spring-jms和spring事务支持的XA事务管理器。 IBM MQ Manager在spring-jta支持方面能否很好地发挥作用? 回答1 您不能将WMQ JMS客户端(spring-jms将使用该客户端)与MQ QueueManager充当XA事务管理器一起使用。 目的是通过JTA实现的事务管理器(即Java EE应用程序服务器)来控制JMS应用程序。 但是,您可以使用WMQ Java客户端(即非JMS),并让MQ QueueManager充当XA事务管理器(非JTA)。 正如@COLINHY所说的,您可以反过来使用它。 Spring事务管理器将是使用JTA的协调器,然后可以使用spring-jms引入WMQ JMS客户端和MQ队列管理器作为事务资源。 回答2 我们以相反的方式使用:使用Spring事务管理作为全局事务管理器,使用MQ XA作为事务分支之一。 工作正常。 回答3 阐明对MQ JMS客户端的支持。 当安装在JavaEE认证的服务器中时,MQ资源适配器(由JMS客户端提供动力)将使MQ QueueManager发挥资源管理器角色的作用,该角色由JavaEE服务器协调。 在JavaEE环境之外,与任何其他JTA提供程序一起使用时,不支持JMS客户端。 (如果对此感兴趣,请提出要求) 使用MQ Java类

2021-05-31 13:24:50    分类:技术分享    ibm-mq   spring-jms   distributed-transactions