From bf49cf5d70526ee96ac19c3cd3f0cfc38fb372ae Mon Sep 17 00:00:00 2001 From: ramverma Date: Mon, 2 Jul 2018 17:03:37 +0100 Subject: Fix the apex-pdp build issue Change-Id: I50532314948d16432065dacbadb9d69d8ca49084 Issue-ID: POLICY-865 Signed-off-by: ramverma --- .../apex/plugins/event/carrier/jms/ApexJMSConsumer.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main') diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java index a96517510..878882d6b 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java @@ -196,7 +196,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn @Override public void run() { // JMS session and message consumer for receiving messages - try (Session jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) { + try (final Session jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) { // Create a message consumer for reception of messages and set this class as a message listener createMessageConsumer(jmsSession); } catch (final Exception e) { @@ -209,20 +209,21 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn LOGGER.debug("event receiver " + this.getClass().getName() + ":" + this.name + " subscribed to JMS topic: " + jmsConsumerProperties.getConsumerTopic()); } - // The endless loop that receives events over JMS - while (consumerThread.isAlive() && !stopOrderedFlag) { - ThreadUtilities.sleep(jmsConsumerProperties.getConsumerWaitTime()); - } } /** * The helper function to create a message consumer from a given JMS session - * + * * @param jmsSession a JMS session */ - private void createMessageConsumer(Session jmsSession) { - try (MessageConsumer messageConsumer = jmsSession.createConsumer(jmsIncomingTopic)) { + private void createMessageConsumer(final Session jmsSession) { + try (final MessageConsumer messageConsumer = jmsSession.createConsumer(jmsIncomingTopic)) { messageConsumer.setMessageListener(this); + + // The endless loop that receives events over JMS + while (consumerThread.isAlive() && !stopOrderedFlag) { + ThreadUtilities.sleep(jmsConsumerProperties.getConsumerWaitTime()); + } } catch (final Exception e) { final String errorMessage = "failed to create a JMS message consumer for receiving messages"; LOGGER.warn(errorMessage, e); -- cgit 1.2.3-korg