diff --git a/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RMQHelper.java b/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RMQHelper.java index 7f8f1dd7..5001b0e0 100644 --- a/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RMQHelper.java +++ b/src/main/java/com/ericsson/eiffel/remrem/publish/helper/RMQHelper.java @@ -10,6 +10,7 @@ import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -41,6 +42,17 @@ } } + @PreDestroy + public void cleanUp() throws IOException { + log.info("RMQHelper cleanUp ..."); + if (rabbitConnection!=null){ + rabbitConnection.close(); + rabbitConnection = null; + } else { + log.warn("rabbitConnection is null when cleanUp"); + } + } + public void send(String routingKey, String msg) throws IOException { giveMeRandomChannel() .basicPublish(exchangeName, routingKey, MessageProperties.BASIC, msg.getBytes());