|
@@ -50,6 +50,7 @@ public class MultiResultProducer implements PojoRequestHandler<List<ImageMultiMs
|
|
|
channel = RabbitMQHelper.createPublishChannel(connection, QUEUE_NAME);
|
|
channel = RabbitMQHelper.createPublishChannel(connection, QUEUE_NAME);
|
|
|
|
|
|
|
|
channel.addConfirmListener((seqNo, multiple) -> {
|
|
channel.addConfirmListener((seqNo, multiple) -> {
|
|
|
|
|
+ log.info("收到确认消息,seqNo: {}, multiple: {}", seqNo, multiple);
|
|
|
if (multiple) {
|
|
if (multiple) {
|
|
|
unConfirmMsg.keySet().removeIf(k -> k <= seqNo);
|
|
unConfirmMsg.keySet().removeIf(k -> k <= seqNo);
|
|
|
} else {
|
|
} else {
|
|
@@ -59,20 +60,21 @@ public class MultiResultProducer implements PojoRequestHandler<List<ImageMultiMs
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void rabbitSend(List<ImageMultiMsg> algoBaseInfos) {
|
|
private void rabbitSend(List<ImageMultiMsg> algoBaseInfos) {
|
|
|
- long seq = channel.getNextPublishSeqNo();
|
|
|
|
|
for (ImageMultiMsg algoBaseInfo : algoBaseInfos) {
|
|
for (ImageMultiMsg algoBaseInfo : algoBaseInfos) {
|
|
|
String body = JacksonUtils.toJson(algoBaseInfo);
|
|
String body = JacksonUtils.toJson(algoBaseInfo);
|
|
|
- rabbitSend(body);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ long seq = channel.getNextPublishSeqNo();
|
|
|
|
|
+ rabbitSend(seq, body);
|
|
|
unConfirmMsg.put(seq, body);
|
|
unConfirmMsg.put(seq, body);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void rabbitSend(String json) {
|
|
|
|
|
|
|
+ private void rabbitSend(long seq, String json) {
|
|
|
String messageId = UUID.randomUUID().toString().replaceAll("-", "");
|
|
String messageId = UUID.randomUUID().toString().replaceAll("-", "");
|
|
|
try {
|
|
try {
|
|
|
AMQP.BasicProperties props = new AMQP.BasicProperties.Builder().messageId(messageId).build();
|
|
AMQP.BasicProperties props = new AMQP.BasicProperties.Builder().messageId(messageId).build();
|
|
|
channel.basicPublish(EXCHANGE_NAME, QUEUE_NAME, props, json.getBytes(StandardCharsets.UTF_8));
|
|
channel.basicPublish(EXCHANGE_NAME, QUEUE_NAME, props, json.getBytes(StandardCharsets.UTF_8));
|
|
|
- log.info("消息发送成功,messageId:{}. body:{}", messageId, json);
|
|
|
|
|
|
|
+ log.info("消息发送成功,seq:{}, messageId:{}. body:{}", seq, messageId, json);
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
log.error("消息发送失败: {}", json, e);
|
|
log.error("消息发送失败: {}", json, e);
|
|
|
throw new RuntimeException("消息发送失败: " + e.getMessage(), e);
|
|
throw new RuntimeException("消息发送失败: " + e.getMessage(), e);
|