the reply mode of producer and consumer I set is that CLIENT_ACKNOWLEDGE, also sets persistent message and persistent topic,. If the consumer side does not consume the message, the consumer side will not call the acknowledge () method. After testing, it is found that if the consumer goes down, the message will be lost and will not be re-read. What"s going on? The onMessage method of messageListener is as follows:
@Override
public void onMessage(Message message) {
try {
TextMessage text = (TextMessage) message;
String msg = text.getText();
String jmsType = message.getJMSType();
//
for (String organId : WebSocketHandler.webSocketSessionMap.keySet()) {
boolean flag = jmsType.equalsIgnoreCase("ID:" + organId);
if (flag) {
boolean hasConsumed = consumeMsg(String.valueOf(organId), msg);
if (!hasConsumed) {
return;
}
}
}
message.acknowledge();
} catch (JMSException e) {
log.error("activemq convert message fail");
log.error(e.getMessage(), e);
}
}
Thank you, boss!