Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ActiveMQ Artemis Topic listener not able to recieve the message using Spring @JmsListener

I have a topic created using the configuration

@Bean
public ActiveMQTopic sampleTopic(){
    return new org.apache.activemq.artemis.jms.client.ActiveMQTopic("topic1");
}

The listener configuration is like this:

@Bean   
public JmsListenerContainerFactory<DefaultMessageListenerContainer> topicJmsListenerContainerFactory(ConnectionFactory connectionFactory) {
    DefaultJmsListenerContainerFactory returnValue = new DefaultJmsListenerContainerFactory();
    returnValue.setConnectionFactory(connectionFactory);
    returnValue.setSubscriptionShared(true);
    returnValue.setSubscriptionDurable(true);
    returnValue.setPubSubDomain(Boolean.TRUE);
    return returnValue;
}

I am sending a message to this topic. The sender looks like this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

jmsTemplate.convertAndSend(sampleTopic, jsonMessage, m -> {
    m.setStringProperty("typ", "new");
    m.setStringProperty("sender", "abc");

    return m;
});

It works fine. I could see the message in Artemis console.

I configured the listener like this.

public class TopicReceiver {
    @JmsListener(destination = "topic1",
                 containerFactory = "topicJmsListenerContainerFactory",
                 subscription = "sub _new",
                 selector = "type = 'new' and sender = 'abc'")
    @Transactional
    public void onMessageKundeAbholauftragNew(String payload) {
        System.out.println(payload);
    }
}

But the message is not being received in the listener. Can anyone help? Do I need to configure anything else?

Also, I noted that the messages is present under the anycast-> topic1. The subscriptions "new" under multicast says have zero messages. So I guess somehow the message is not routed to the subscription? Or Is it something else?

>Solution :

You’re sending the message with the property typ with the value new, but your selector is looking for type.

Also, the subscription parameter for your @JmsListener is sub _new. This almost certainly shouldn’t have a space in it, but should rather be sub_new.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading