spring-jms

JmsTemplate with RECEIVE_TIMEOUT_NO_WAIT doesn't retrieve messages from JMS queue

梦想的初衷 提交于 2019-12-11 15:42:48
问题 Given I have ActiveMQ queue where many messages are already present. When I set receive timeout on JmsTemplate to RECEIVE_TIMEOUT_NO_WAIT which is equal to -1 : jmsTemplate.setReceiveTimeout(JmsTemplate.RECEIVE_TIMEOUT_NO_WAIT); and try to receive one of those messages: Message msg = jmsTemplate.receive(queueName); then msg is null , but it should not be according JavaDoc: /** * Timeout value indicating that a receive operation should * check if a message is immediately available without

Multiple DefaultMessageListenerContainer for external systems

為{幸葍}努か 提交于 2019-12-11 15:30:01
问题 I have my application that should communicate with two external systems A and B. So I am creating actually 2 containers like this: private DefaultMessageListenerContainer createContainer(Conf conf) { DefaultMessageListenerContainer jmsCnr= new DefaultMessageListenerContainer(); jmsCnr.setConnectionFactory(connectionFactoryAdapter); jmsCnr.setDestinationResolver(destinationResolver); jmsCnr.setDestinationName(destinationName); jmsCnr.setMessageListener(MyClass); jmsCnr.initialize(); return

How to set message priority for embedded activeMQ using spring JmsTemplate?

谁说胖子不能爱 提交于 2019-12-11 14:48:43
问题 I am following this guide- https://spring.io/guides/gs/messaging-jms/ I have few messages with higher priority that needs to be sent before any other message. I have already tried following - jmsTemplate.execute(new ProducerCallBack(){ public Object doInJms(Session session,MessageProducer producer){ Message hello1 =session.createTextMessage("Hello1"); producer.send(hello1, DeliveryMode.PERSISTENT,0,0); // <- low priority Message hello2 =session.createTextMessage("Hello2"); producer.send

Can we prioritize ActiveMQ messages based on message properties or headers?

ぐ巨炮叔叔 提交于 2019-12-11 14:17:29
问题 This is followup question on this I am setting few application specific properties on messages and i want the messages to be prioritized based on those specific property values For example : Message message = session.createTextMessage("hello world!"); message.setStringProperty("myProperty","100"); producer.send(message ) Here I want messages to be prioritize based on value of myProperty . Is this possible? 回答1: ActiveMQ doesn't support prioritizing delivery based on arbitrary message headers

How does spring jms distribute messages among durable topic listeners?

自闭症网瘾萝莉.ら 提交于 2019-12-11 10:57:25
问题 raw jms code: TopicSubscriber durSubscriber1 = receiverSession.createDurableSubscriber(topic,"subscription_1"); durSubscriber1.setMessageListener(new MessageListener() { @Override public void onMessage(Message message) { RMQTextMessage rmqTextMessage = ((RMQTextMessage) message); try { System.out.println("sub_1:" + rmqTextMessage.getText()); } catch (JMSException e) { e.printStackTrace(); } } }); TopicSubscriber durSubscriber2 = receiverSession.createDurableSubscriber(topic,"subscription_2");

When is it appropriate to cacheConsumers when using Spring CachingConnectionFactory?

被刻印的时光 ゝ 提交于 2019-12-11 10:20:44
问题 Spring includes a class called CachingConnectionFactory. One variable in this class is a boolean named cacheProducers. By default, this value is true. This variable can be set to false using setCacheProducers(false). When would it be appropriate to set this to false? What are the benefits and drawbacks of setting to false? Background: We are conducting a performance test of our application and use Spring JMS to post thousands of messages a second to JMS. Profiling our code, we see that the

Gracefully stop DefaultMessageListenerContainer having a receiveTimeout = -1

不打扰是莪最后的温柔 提交于 2019-12-11 10:16:00
问题 Can somebody point me to a way to grecefully stop a DefaultMessageListenerContainer in Spring that is defined with a receiveTimeout = -1 (i.e. it is using the blocking version of javax.jms.MessageConsumer#receive) ? Actually, I've tried both stop() and shutdown() methods of DMLC but consumer thread is stuck on the receive() call. "heartBeatContainer-1" prio=6 tid=0x0304d800 nid=0x1d20 in Object.wait() [0x037ef000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait

JMS doesnt work in global transaction with cachingconnectionfactory

时间秒杀一切 提交于 2019-12-11 09:25:31
问题 I am using IBM mq(p800-005-160516.2) and Spring JMS template to post messages to MQ.My application is having one database resource and one MQ resource in global transaction.Problem is that it fails if i configure CachingConnnectionFactory public class Xa { public ConnectionFactory connectionFactory() throws Exception { AtomikosConnectionFactoryBean atomikosConnectionFactoryBean = new AtomikosConnectionFactoryBean(); atomikosConnectionFactoryBean.setUniqueResourceName("pavan"); Properties

How to add different destination dynamically to JMSListener Annotation in Spring boot?

馋奶兔 提交于 2019-12-11 07:55:24
问题 I working on an application which reads message from Azure service bus. This application was created using spring boot, Spring jms and Qpid jms client. I am able to read the message properly from Queue without any issues. PFB My code which I am using to read message. @Service public class QueueReceiver { @JmsListener(destination = "testing") public void onMessage(String message) { if (null != message) { System.out.println("Received message from Queue: " + message); } }} Issue is we have

JMSListener selector not working

可紊 提交于 2019-12-11 07:54:45
问题 I have a JMS producer sending 2 kinds of messages: business logic and heart beat messages. Currently, both are handled by the same receiver, but I am now trying to have dedicated classes for each by using selectors. The problem I have is whenever I add the selector to the receiver, it stops receiving messages. Here is what I have so far. For simplicity, I have only added the code for the heart beat: To send the message, I have this: private void sendHeartBeat() { this.buildTemplate().send(new