Closed omllobet closed 5 years ago
Hi I think it will be interesting to set the real content type and a corrrelation id in the rabbit headers.
I don't have write permissions so I am just attaching a patch.
Thanks!
From 626f6eae0c1f3713b995c3317c2160882184bb3a Mon Sep 17 00:00:00 2001 From: Oscar Martinez <oscar.martinez@crg.eu> Date: Thu, 28 Mar 2019 19:10:02 +0100 Subject: [PATCH] Add a MessagePostProcessor to set some header properties in rabbit message --- .../se/nbis/lega/inbox/sftp/InboxSftpEventListener.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/se/nbis/lega/inbox/sftp/InboxSftpEventListener.java b/src/main/java/se/nbis/lega/inbox/sftp/InboxSftpEventListener.java index 2b54ea8..05aaf50 100644 --- a/src/main/java/se/nbis/lega/inbox/sftp/InboxSftpEventListener.java +++ b/src/main/java/se/nbis/lega/inbox/sftp/InboxSftpEventListener.java @@ -1,6 +1,7 @@ package se.nbis.lega.inbox.sftp; import com.google.gson.Gson; +import java.util.UUID; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.FileUtils; @@ -244,7 +245,11 @@ public class InboxSftpEventListener implements SftpEventListener { routingKey = routingKeyFiles; } String json = gson.toJson(fileDescriptor); - rabbitTemplate.convertAndSend(exchange, routingKey, json); + rabbitTemplate.convertAndSend(exchange, routingKey, json, m -> { + m.getMessageProperties().setContentType("application/json"); + m.getMessageProperties().setCorrelationId(UUID.randomUUID().toString()); + return m; + }); log.info("Message published to {} exchange with routing key {}: {}", exchange, routingKey, json); } -- 2.17.1
Hi, @omllobet, I added you to collaborators, you may now create a proper PR.
Hi I think it will be interesting to set the real content type and a corrrelation id in the rabbit headers.
I don't have write permissions so I am just attaching a patch.
Thanks!