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:
之后,我尝试从其他应用程序使用者那里使用该消息。这样做没有问题。
But when I shutdown the application consumer the request
queue was deleted for no reason.
我的应用程序消费者是使用 Spring Boot 构建的,如下所示:
@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();
}
}
}
顺便说一句,原来的requests
当应用程序生产者将消息发送到 ActiveMQ Artemis 时创建队列,这是通过JMSTemplate
如下:
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.");
}
如果我关闭应用程序生产者requests
队列没有被删除。仅当我使用关闭应用程序使用者时才会删除队列@JMSListener
.
请帮我。也许我错过了一些理解或参数?