From f16b70b3766b4a3b8af09b941aba04d527ae5d0e Mon Sep 17 00:00:00 2001 From: Falucho <german.faller@pcunix71.fing.edu.uy> Date: Sun, 23 Jun 2019 04:34:53 -0300 Subject: [PATCH] AutoCLose --- .../fing/tse/central/business/mq/MessageConsumer.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/central-ejb/src/main/java/uy/edu/fing/tse/central/business/mq/MessageConsumer.java b/central-ejb/src/main/java/uy/edu/fing/tse/central/business/mq/MessageConsumer.java index e76ecaa..c22e493 100644 --- a/central-ejb/src/main/java/uy/edu/fing/tse/central/business/mq/MessageConsumer.java +++ b/central-ejb/src/main/java/uy/edu/fing/tse/central/business/mq/MessageConsumer.java @@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory; import uy.edu.fing.tse.central.business.BusinessLocal; import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; import javax.ejb.EJB; import javax.ejb.Singleton; import javax.ejb.Startup; @@ -79,4 +80,13 @@ public class MessageConsumer { } }); } + + @PreDestroy + public void stop() { + try { + channel.close(); + } catch (IOException | TimeoutException e) { + throw new RuntimeException("Error al cerrar la coneccion con MQ", e); + } + } } -- GitLab