SUPPORT-9528: add messageId
This commit is contained in:
parent
d106b37d8e
commit
b96010133f
1 changed files with 10 additions and 1 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
package ru.micord.ervu.audit.service.impl;
|
package ru.micord.ervu.audit.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
|
@ -26,7 +30,12 @@ public class BaseAuditKafkaPublisher implements AuditKafkaPublisher {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void publishEvent(String topic, String message) {
|
public void publishEvent(String topic, String message) {
|
||||||
kafkaTemplate.send(topic, message)
|
String messageId = UUID.randomUUID().toString();
|
||||||
|
ProducerRecord<String, String> record = new ProducerRecord<>(topic, message);
|
||||||
|
record.headers()
|
||||||
|
.add("messageId", messageId.getBytes(StandardCharsets.UTF_8));
|
||||||
|
|
||||||
|
kafkaTemplate.send(record)
|
||||||
.addCallback(
|
.addCallback(
|
||||||
result -> {
|
result -> {
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue