I am newbie on JMS and ActiveMQ Artemis, and I have the following problem. I put a message in a requests
queue normally from an application producer:
After that from other application consumer I tried to consume that message. That works without problems.
But when I shutdown the application consumer the request
queue was deleted for no reason.
My application consumer was build with Spring Boot as follows:
@SpringBootApplication
public class ProcessorClaimsApplication {
public static void main(String[] args) {
SpringApplication.run(ProcessorClaimsApplication.class, args);
}
}
@EnableJms
@Configuration
public class ProcessorClaimsConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(ProcessorClaimsConfig.class);
private static final String ORDER_ID = "orderId";
private static final String APPROVED = "approved";
private static final String APPROVERS = "approvers";
private static final String APPOVER_INFO_SEPARATOR = ":";
private static final String APPROVERS_SEPARATOR = ";";
@Autowired
private AS2Service as2Service;
@Autowired
private EnsuranceService ensuranceService;
...
@Transactional
@JmsListener(destination = "requests", selector = "JMSType = 'PAYMENTORDERAPPROVALRESPONSE'")
public void processZMessageResponse(MapMessage message) {
try {
LOGGER.debug("Incoming message found JMSCorrelationID {}, orderId {}", message.getJMSCorrelationID(),
message.getStringProperty(ORDER_ID));
boolean approved = (Boolean) message.getObject(APPROVED);
String approvers = (String) message.getObject(APPROVERS);
LOGGER.debug("Sending resolution to Ensurance");
ensuranceService.sendResolution(Long.valueOf(message.getJMSCorrelationID()),
message.getStringProperty(ORDER_ID), approved, approvers);
} catch (Exception e) {
LOGGER.error("The is an error processing the message: {}" + e.getMessage());
e.printStackTrace();
}
}
}
BTW, the original requests
queue was created when the application producer sent the message to ActiveMQ Artemis and this was done with JMSTemplate
as follow:
public void pushResolution(String jmsCorrelationID, final String paymentOrderId,
final String paymentOrderNumber, final String paymentOrderType, Map<String, Object> data) {
this.jmsTemplate.send(requestsQueue, new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
MapMessage message = session.createMapMessage();
for (String key : data.keySet()) {
message.setObject(key, data.get(key));
}
message.setJMSCorrelationID(jmsCorrelationID);
message.setJMSType(MessageTypeEnum.PAYMENTORDERAPPROVALRESPONSE.name());
message.setStringProperty("orderId", paymentOrderId);
message.setStringProperty("orderNumber", paymentOrderNumber);
message.setStringProperty("orderType", paymentOrderType);
return message;
}
});
LOGGER.debug("Pushed Payment Order Response in Queue successfully.");
}
If I shutdown the application producer the requests
queue is not deleted. The queue is only deleted when I shutdown the application consumer using @JMSListener
.
Please help me. Maybe I miss some understanding or parameter?