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:
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?
You're sending the message with the property
typwith the valuenew, but your selector is looking fortype.Also, the
subscriptionparameter for your@JmsListenerissub _new. This almost certainly shouldn't have a space in it, but should rather besub_new.