I'm fairly new to AMQ, I do understand the concept of making a message, sending it to a queue, and consuming it asynchrnously.
My main Spring configurations are the following
@Bean
public DefaultMessageListenerContainer listenerContainer(
MessageListenerAdapter adapter) {
DefaultMessageListenerContainer dmlc = new DefaultMessageListenerContainer();
dmlc.setConnectionFactory(connectionFactory());
dmlc.setMessageListener(adapter);
dmlc.setDestinationName("myQueue");
dmlc.setConcurrentConsumers(5);
return dmlc;
}
@Bean
MessageListenerAdapter adapter(MyClass myClass) {
MessageListenerAdapter messageListener = new MessageListenerAdapter(
myClass);
messageListener.setDefaultListenerMethod("myMethod");
return messageListener;
}
@Bean
public JmsTemplate jmsTemplate() {
JmsTemplate jt = new JmsTemplate(connectionFactory());
return jt;
}
I have no trouble sending things to the queue with jmsTemplate.convertAndSend() and then recieving them with myClass#myMethod
My Problem: I need the listener to halt consuming messages if an exception is thrown. Usually the exception will tell me the remote site is offline and to try later. If I don't stop it all those messages are mostly lost. Would like to keep the queue full until I'm capable of sending again.
Is it possible?