From b628ba1e7d631abceeff3bd1f37b6e1c9545d13a Mon Sep 17 00:00:00 2001 From: santosh nc <22740255+SantoshNC68@users.noreply.github.com> Date: Fri, 5 Nov 2021 10:48:36 +0530 Subject: [PATCH] RabbitMQ queue bindings missing due to update in spring boot version (#513) * Modified code to support binding key generation to EI queue * Changed logger statement from info to debug * Changed some logger statements * Updated pom.xml for new release Co-authored-by: SANTOSH NC --- pom.xml | 2 +- .../ei/handlers/EventToObjectMapHandler.java | 4 ++-- .../ericsson/ei/handlers/ObjectHandler.java | 2 +- .../com/ericsson/ei/handlers/RMQHandler.java | 20 +++++++++++-------- .../ei/subscription/RunSubscription.java | 4 ++-- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index a24655bc3..1c1dd42ad 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.github.ericsson eiffel-intelligence - 3.2.1 + 3.2.2 war diff --git a/src/main/java/com/ericsson/ei/handlers/EventToObjectMapHandler.java b/src/main/java/com/ericsson/ei/handlers/EventToObjectMapHandler.java index cf2274f33..9ffa29e7e 100644 --- a/src/main/java/com/ericsson/ei/handlers/EventToObjectMapHandler.java +++ b/src/main/java/com/ericsson/ei/handlers/EventToObjectMapHandler.java @@ -183,14 +183,14 @@ public ArrayList getEventToObjectList(String eventId) { public boolean deleteEventObjectMap(String templateName) { String queryString = "{\"objects\": { \"$in\" : [/.*" + templateName + "/]} }"; MongoStringQuery query = new MongoStringQuery(queryString); - LOGGER.info("The JSON query for deleting aggregated object is : {}", query); + LOGGER.debug("The JSON query for deleting aggregated object is : {}", query); return mongodbhandler.dropDocument(databaseName, collectionName, query); } public boolean isEventInEventObjectMap(String eventId) { String condition = "{\"objects\": { \"$in\" : [\"" + eventId + "\"]} }"; MongoStringQuery query = new MongoStringQuery(condition); - LOGGER.info("The JSON query for isEventInEventObjectMap is : {}", query); + LOGGER.debug("The JSON query for isEventInEventObjectMap is : {}", query); List documents = mongodbhandler.find(databaseName, collectionName, query); return !documents.isEmpty(); } diff --git a/src/main/java/com/ericsson/ei/handlers/ObjectHandler.java b/src/main/java/com/ericsson/ei/handlers/ObjectHandler.java index c8ce288b3..6850399fe 100644 --- a/src/main/java/com/ericsson/ei/handlers/ObjectHandler.java +++ b/src/main/java/com/ericsson/ei/handlers/ObjectHandler.java @@ -313,7 +313,7 @@ private boolean isInvalidId(String id) { private void postInsertActions(String aggregatedObject, RulesObject rulesObject, String event, String id) { - LOGGER.info("Updating the event object map with event id: " + id + " event is : " + event); + LOGGER.debug("Updating the event object map with event id: " + id + " event is : " + event); eventToObjectMap.updateEventToObjectMapInMemoryDB(rulesObject, event, id, getTtl()); } diff --git a/src/main/java/com/ericsson/ei/handlers/RMQHandler.java b/src/main/java/com/ericsson/ei/handlers/RMQHandler.java index af07232a8..8887a0774 100644 --- a/src/main/java/com/ericsson/ei/handlers/RMQHandler.java +++ b/src/main/java/com/ericsson/ei/handlers/RMQHandler.java @@ -29,6 +29,8 @@ import org.springframework.amqp.core.Binding; import org.springframework.amqp.core.Binding.DestinationType; import org.springframework.amqp.core.BindingBuilder; +import org.springframework.amqp.core.Declarable; +import org.springframework.amqp.core.Declarables; import org.springframework.amqp.core.Queue; import org.springframework.amqp.core.TopicExchange; import org.springframework.amqp.rabbit.connection.CachingConnectionFactory; @@ -198,14 +200,16 @@ protected Binding binding() { } @Bean - public List bindings() { + public Declarables bindings() { String[] bindingKeysArray = splitBindingKeys(rmqProperties.getBindingKeys()); - List bindingList = new ArrayList(); + List bindingsList = new ArrayList(); + List bindingList = new ArrayList(); for (String bindingKey : bindingKeysArray) { + bindingsList.add(BindingBuilder.bind(externalQueue()).to(exchange()).with(bindingKey)); bindingList.add(BindingBuilder.bind(externalQueue()).to(exchange()).with(bindingKey)); } - deleteBindings(bindingKeysArray,bindingList); - return bindingList; + deleteBindings(bindingKeysArray,bindingsList); + return new Declarables(bindingList); } private boolean isRMQCredentialsSet() { @@ -225,7 +229,7 @@ private String[] splitBindingKeys(String bindingKeys) { * Binding key which is not present in the current AMQPBindingObjectList gets deleted and removed from mongoDB. * @return */ - private void deleteBindings(String[] newBindingKeysArray, List AMQPBindingObjectList) { + private void deleteBindings(String[] newBindingKeysArray, List amqpBindingObjectList) { // Creating BindingKeys Collection in mongoDB ArrayList allDocuments = mongoDBHandler.getAllDocuments(dataBaseName, collectionName); ArrayList existingBindingsData = new ArrayList(); @@ -250,16 +254,16 @@ private void deleteBindings(String[] newBindingKeysArray, List AMQPBind } } // to store the binding keys used for rabbitMQ, in mongo db. - storeNewBindingKeys(existingBindingsData, AMQPBindingObjectList); + storeNewBindingKeys(existingBindingsData, amqpBindingObjectList); } /** * This method is used to store the binding keys used for rabbitMQ, in mongoDB. * @return */ - private void storeNewBindingKeys(ArrayList existingBindingsData, List AMQPBindingObjectList){ + private void storeNewBindingKeys(ArrayList existingBindingsData, List amqpBindingObjectList){ // comparing with the stored key and adding the new binding key into the mongoDB. - for(final Binding bindingKey:AMQPBindingObjectList){ + for(final Binding bindingKey:amqpBindingObjectList){ if(existingBindingsData.contains(bindingKey.getRoutingKey())){ LOGGER.info("Binding already present in mongoDB"); }else{ diff --git a/src/main/java/com/ericsson/ei/subscription/RunSubscription.java b/src/main/java/com/ericsson/ei/subscription/RunSubscription.java index 83c0fde1d..737d6c316 100644 --- a/src/main/java/com/ericsson/ei/subscription/RunSubscription.java +++ b/src/main/java/com/ericsson/ei/subscription/RunSubscription.java @@ -94,7 +94,7 @@ public boolean runSubscriptionOnObject(String aggregatedObject, Iterator