diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3858b5e2..000f1edd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,9 @@
+## 2.1.1
+- Implemented the changes to log the eventId and HTTPStatus while the level is INFO.
+
## 2.1.0
- Implemented new routing key template for Sepia.
--
+
## 2.0.30
- Upgrading to OpenJDK 17
diff --git a/pom.xml b/pom.xml
index 83d2f9c3..119df0c7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
2.0.12
- 2.1.0
+ 2.1.1
2.3.0
eiffel-remrem-publish
diff --git a/publish-common/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RMQHelper.java b/publish-common/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RMQHelper.java
index 65880e32..9426ea83 100644
--- a/publish-common/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RMQHelper.java
+++ b/publish-common/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RMQHelper.java
@@ -32,6 +32,10 @@
import com.ericsson.eiffel.remrem.publish.config.RabbitMqPropertiesConfig;
import com.ericsson.eiffel.remrem.publish.exception.NackException;
import com.ericsson.eiffel.remrem.publish.exception.RemRemPublishException;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
@@ -40,6 +44,7 @@
private static final String FALSE = "false";
+ private static Gson gson;
@Autowired
RabbitMqPropertiesConfig rabbitMqPropertiesConfig;
@@ -66,6 +71,17 @@ public void init() throws RemRemPublishException {
}
}
+ /**
+ * This method is used to give the Gson object
+ * @return Gson
+ */
+ public static Gson getGson() {
+ if (gson == null) {
+ gson = new GsonBuilder().create();
+ }
+ return gson;
+ }
+
/**
* This method is used to set protocol specific RabbitMQ properties
* @param protocol name
@@ -91,9 +107,10 @@ private void protocolInit(String protocol) throws RemRemPublishException {
public void send(String routingKey, String msg, MsgService msgService) throws IOException, NackException, TimeoutException, RemRemPublishException, IllegalArgumentException {
String protocol = msgService.getServiceName();
+ String eventId = msgService.getEventId(getGson().fromJson(msg, JsonObject.class));
RabbitMqProperties rabbitmqProtocolProperties = rabbitMqPropertiesMap.get(protocol);
if (rabbitmqProtocolProperties != null) {
- rabbitmqProtocolProperties.send(routingKey, msg);
+ rabbitmqProtocolProperties.send(routingKey, msg, eventId);
} else {
log.error("RabbitMq properties not configured for the protocol " + protocol);
}
diff --git a/publish-common/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RabbitMqProperties.java b/publish-common/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RabbitMqProperties.java
index 762ca93b..637d9aa0 100644
--- a/publish-common/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RabbitMqProperties.java
+++ b/publish-common/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RabbitMqProperties.java
@@ -513,7 +513,7 @@ private boolean hasExchange() throws RemRemPublishException {
* @throws TimeoutException
* @throws RemRemPublishException
*/
- public void send(String routingKey, String msg)
+ public void send(String routingKey, String msg, String eventId)
throws IOException, NackException, TimeoutException, RemRemPublishException, IllegalArgumentException {
Channel channel = giveMeRandomChannel();
checkAndCreateExchangeIfNeeded();
@@ -537,7 +537,7 @@ public void shutdownCompleted(ShutdownSignalException cause) {
try {
channel.basicPublish(exchangeName, routingKey, msgProps, msg.getBytes());
- log.info("Published message with size {} bytes on exchange '{}' with routing key '{}'",
+ log.info("Published message {} with size {} bytes on exchange '{}' with routing key '{}'", eventId,
msg.getBytes().length, exchangeName, routingKey);
if (waitForConfirmsTimeOut == null || waitForConfirmsTimeOut == 0) {
waitForConfirmsTimeOut = DEFAULT_WAIT_FOR_CONFIRMS_TIMEOUT;
diff --git a/publish-service/src/main/java/com/ericsson/eiffel/remrem/publish/controller/ProducerController.java b/publish-service/src/main/java/com/ericsson/eiffel/remrem/publish/controller/ProducerController.java
index bda41a3d..d9fc984e 100644
--- a/publish-service/src/main/java/com/ericsson/eiffel/remrem/publish/controller/ProducerController.java
+++ b/publish-service/src/main/java/com/ericsson/eiffel/remrem/publish/controller/ProducerController.java
@@ -113,6 +113,7 @@ public ResponseEntity send(@ApiParam(value = "message protocol", required = true
}
} synchronized(this) {
SendResult result = messageService.send(body, msgService, userDomain, tag, routingKey);
+ log.info("HTTP Status: {}", messageService.getHttpStatus().value());
return new ResponseEntity(result, messageService.getHttpStatus());
}
}
diff --git a/publish-service/src/test/java/com/ericsson/eiffel/remrem/publish/service/MessageServiceRMQImplUnitTest.java b/publish-service/src/test/java/com/ericsson/eiffel/remrem/publish/service/MessageServiceRMQImplUnitTest.java
index 3c574313..153c02fa 100644
--- a/publish-service/src/test/java/com/ericsson/eiffel/remrem/publish/service/MessageServiceRMQImplUnitTest.java
+++ b/publish-service/src/test/java/com/ericsson/eiffel/remrem/publish/service/MessageServiceRMQImplUnitTest.java
@@ -120,10 +120,9 @@ public void testCreateExchangeIfNotExistingDisable() throws RemRemPublishExcepti
}
@Test public void sendNormal() throws Exception {
- Map map = new HashMap();
+ String body = FileUtils.readFileToString(new File("src/test/resources/EiffelActivityFinishedEvent.json"));
MsgService msgService = PublishUtils.getMessageService(protocol, msgServices);
- map.put("test", "test");
- messageService.send(map, map, msgService);
+ rmqHelper.send("eiffelxxx", body, msgService);
}
@Test public void testSingleSuccessfulEvent() throws Exception {
@@ -193,12 +192,13 @@ public void testCreateExchangeIfNotExistingDisable() throws RemRemPublishExcepti
}
@Test
- public void testRabbitMQConnection() throws NackException, TimeoutException, RemRemPublishException {
+ public void testRabbitMQConnection() throws TimeoutException, RemRemPublishException, IOException {
+ String body = FileUtils.readFileToString(new File("src/test/resources/EiffelActivityFinishedEvent.json"));
try {
if(rabbitmqProtocolProperties != null) {
rabbitmqProtocolProperties.createRabbitMqConnection();
MsgService msgService = PublishUtils.getMessageService(protocol, msgServices);
- rmqHelper.send("eiffelxxx", "Test message", msgService);
+ rmqHelper.send("eiffelxxx", body, msgService);
assertTrue(rabbitmqProtocolProperties.getRabbitConnection().isOpen());
}
} catch (IOException e) {