Skip to content

Commit

Permalink
RabbitMQ queue bindings missing due to update in spring boot version (#…
Browse files Browse the repository at this point in the history
…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 <[email protected]>
  • Loading branch information
SantoshNC68 and SANTOSH NC authored Nov 5, 2021
1 parent 5e0ee5a commit b628ba1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.ericsson</groupId>
<artifactId>eiffel-intelligence</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
<packaging>war</packaging>

<parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ public ArrayList<String> 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<String> documents = mongodbhandler.find(databaseName, collectionName, query);
return !documents.isEmpty();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ericsson/ei/handlers/ObjectHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
20 changes: 12 additions & 8 deletions src/main/java/com/ericsson/ei/handlers/RMQHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -198,14 +200,16 @@ protected Binding binding() {
}

@Bean
public List<Binding> bindings() {
public Declarables bindings() {
String[] bindingKeysArray = splitBindingKeys(rmqProperties.getBindingKeys());
List<Binding> bindingList = new ArrayList<Binding>();
List<Binding> bindingsList = new ArrayList<Binding>();
List<Declarable> bindingList = new ArrayList<Declarable>();
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() {
Expand All @@ -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<Binding> AMQPBindingObjectList) {
private void deleteBindings(String[] newBindingKeysArray, List<Binding> amqpBindingObjectList) {
// Creating BindingKeys Collection in mongoDB
ArrayList<String> allDocuments = mongoDBHandler.getAllDocuments(dataBaseName, collectionName);
ArrayList<String> existingBindingsData = new ArrayList<String>();
Expand All @@ -250,16 +254,16 @@ private void deleteBindings(String[] newBindingKeysArray, List<Binding> 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<String> existingBindingsData, List<Binding> AMQPBindingObjectList){
private void storeNewBindingKeys(ArrayList<String> existingBindingsData, List<Binding> 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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public boolean runSubscriptionOnObject(String aggregatedObject, Iterator<JsonNod

JsonNode requirement = requirementIterator.next();

LOGGER.info("The fulfilled requirement which condition will check is : {}", requirement.toString());
LOGGER.debug("The fulfilled requirement which condition will check is : {}", requirement.toString());
ArrayNode conditions = (ArrayNode) requirement.get("conditions");

count_condition_fulfillment = 0;
Expand Down Expand Up @@ -141,7 +141,7 @@ public boolean runSubscriptionOnObject(String aggregatedObject, Iterator<JsonNod
}

LOGGER.info("The final value of conditionFulfilled is : {} for aggregation object id: {} and Subscription: {}",
conditionFulfilled, id);
conditionFulfilled, id, subscriptionName);

return conditionFulfilled;
}
Expand Down

0 comments on commit b628ba1

Please sign in to comment.