I am using Apache Artemis as the message bus and JMS to listen and send messages to the message bus. I have a use case where I want to listen to all queues that matches a pattern(Eg the topic starts with xxxx). According to what I have explored we can use wildcard routing to do that. http://activemq.apache.org/wildcards.html
I have put the following in my broker.xml
<wildcard-addresses>
<routing-enabled>true</routing-enabled>
</wildcard-addresses>
I am using the following code to send a message to a queue:
@Component
@EnableJms
public class Producer {
@Autowired
JmsTemplate jmsTemplate;
@Value("address.client1")
String destinationQueue;
public void send(String msg){
jmsTemplate.convertAndSend(destinationQueue, msg);
}
}
Below is my Listener that should listen to all the queues that starts with address.
@Component
public class Consumer {
@JmsListener(destination = "address.>")
public void receive(Message message){
if(message.getPayload() instanceof String){
System.out.println("Recieved Message: " + message.getPayload().toString());
}else {
System.err.println("Message Type Unkown !");
}
}
}
But I am not able to receive the message that we sent from the sender to the receiver code. Can anyone help me on this?
<routing-enabled>false</routing-enabled>
– Kayaman