我正在丢失重启服务器时已经在进行中的消息。 我希望在退回或重新启动服务器时确认消息并移回队列正在处理的消息。以下是我的代码。有人可以帮我解决这个问题吗?
@Bean
public JmsListenerContainerFactory<DefaultMessageListenerContainer> responseMessageFactory() {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactory());
factory.setConcurrency(concurrency);
factory.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
return factory;
}
@JmsListener(destination = "${myProj.consumerQueueName}", containerFactory = "messageFactory")
public void recieveMessage(byte[] message) {
String msg = new String(message);
try {
MdcTranIdUtil.generateTranId(message, counter);
List<String> myXmlList = null;
logger.debug("Consumer receives Message: {}" + msg );
if (msg.length() > 0) {
xmlMy = receiver.transfer(msg);
for ( String xml : xmlMy ) {
responsePublisher.sendIt(xml, receiver.getMessageProps());
}
}
}
catch ( Exception e ) {
errorPublish.send(msg);
logger.error( "RESPONSE CONSUMER EXCEPTION" + e );
}