diff options
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main')
2 files changed, 35 insertions, 45 deletions
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 303165558..3fd39eedf 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 @@ -142,10 +142,8 @@ public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runn } } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#start() + /** + * {@inheritDoc} */ @Override public void start() { @@ -156,21 +154,16 @@ public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runn consumerThread.start(); } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#getName() + /** + * {@inheritDoc} */ @Override public String getName() { return name; } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.service.engine.event.ApexEventConsumer#getPeeredReference(org.onap.policy.apex.service. - * parameters. eventhandler.EventHandlerPeeredMode) + /** + * {@inheritDoc} */ @Override public PeeredReference getPeeredReference(final EventHandlerPeeredMode peeredMode) { @@ -231,10 +224,8 @@ public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runn } } - /* - * (non-Javadoc) - * - * @see javax.jms.MessageListener#onMessage(javax.jms.Message) + /** + * {@inheritDoc} */ @Override public void onMessage(final Message jmsMessage) { @@ -245,7 +236,7 @@ public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runn jmsMessage.getJMSType()); } - eventReceiver.receiveEvent(jmsMessage); + eventReceiver.receiveEvent(null, jmsMessage); } catch (final Exception e) { final String errorMessage = "failed to receive message from JMS"; LOGGER.warn(errorMessage, e); @@ -253,10 +244,8 @@ public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runn } } - /* - * (non-Javadoc) - * - * @see org.onap.policy.apex.apps.uservice.producer.ApexEventProducer#stop() + /** + * {@inheritDoc} */ @Override public void stop() { diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java index 4dcbf80c8..e98ee8ff8 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java @@ -23,6 +23,7 @@ package org.onap.policy.apex.plugins.event.carrier.jms; import java.io.Serializable; import java.util.EnumMap; import java.util.Map; +import java.util.Properties; import javax.jms.Connection; import javax.jms.ConnectionFactory; @@ -82,13 +83,13 @@ public class ApexJmsProducer implements ApexEventProducer { */ @Override public void init(final String producerName, final EventHandlerParameters producerParameters) - throws ApexEventException { + throws ApexEventException { this.name = producerName; // Check and get the JMS Properties if (!(producerParameters.getCarrierTechnologyParameters() instanceof JmsCarrierTechnologyParameters)) { - final String errorMessage = "specified producer properties are not applicable to a JMS producer (" - + this.name + ")"; + final String errorMessage = + "specified producer properties are not applicable to a JMS producer (" + this.name + ")"; LOGGER.warn(errorMessage); throw new ApexEventException(errorMessage); } @@ -104,13 +105,13 @@ public class ApexJmsProducer implements ApexEventProducer { // Check if we actually got a connection factory if (connectionFactory == null) { throw new IllegalArgumentException( - "JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory() - + "\" returned null for producer (" + this.name + ")"); + "JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory() + + "\" returned null for producer (" + this.name + ")"); } } catch (final Exception e) { final String errorMessage = "lookup of JMS connection factory \"" - + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \"" - + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")"; + + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \"" + + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")"; LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -123,12 +124,12 @@ public class ApexJmsProducer implements ApexEventProducer { // Check if we actually got a topic if (jmsOutgoingTopic == null) { throw new IllegalArgumentException("JMS context lookup of \"" + jmsProducerProperties.getProducerTopic() - + "\" returned null for producer (" + this.name + ")"); + + "\" returned null for producer (" + this.name + ")"); } } catch (final Exception e) { final String errorMessage = "lookup of JMS topic \"" + jmsProducerProperties.getProducerTopic() - + "\" failed for JMS producer properties \"" - + jmsProducerProperties.getJmsProducerProperties() + FOR_PRODUCER_TAG + this.name + ")"; + + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJmsProducerProperties() + + FOR_PRODUCER_TAG + this.name + ")"; LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -136,11 +137,11 @@ public class ApexJmsProducer implements ApexEventProducer { // Create and start a connection to the JMS server try { connection = connectionFactory.createConnection(jmsProducerProperties.getSecurityPrincipal(), - jmsProducerProperties.getSecurityCredentials()); + jmsProducerProperties.getSecurityCredentials()); connection.start(); } catch (final Exception e) { final String errorMessage = "connection to JMS server failed for JMS properties \"" - + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")"; + + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")"; LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -150,7 +151,7 @@ public class ApexJmsProducer implements ApexEventProducer { jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); } catch (final Exception e) { final String errorMessage = "creation of session to JMS server failed for JMS properties \"" - + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")"; + + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")"; LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); } @@ -159,8 +160,8 @@ public class ApexJmsProducer implements ApexEventProducer { try { messageProducer = jmsSession.createProducer(jmsOutgoingTopic); } catch (final Exception e) { - final String errorMessage = "creation of producer for sending events " - + "to JMS server failed for JMS properties \"" + final String errorMessage = + "creation of producer for sending events " + "to JMS server failed for JMS properties \"" + jmsProducerProperties.getJmsConsumerProperties() + "\""; LOGGER.warn(errorMessage, e); throw new ApexEventException(errorMessage, e); @@ -206,10 +207,11 @@ public class ApexJmsProducer implements ApexEventProducer { * java.lang.Object) */ @Override - public void sendEvent(final long executionId, final String eventname, final Object eventObject) { + public void sendEvent(final long executionId, final Properties executionProperties, final String eventname, + final Object eventObject) { // Check if this is a synchronized event, if so we have received a reply - final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap - .get(EventHandlerPeeredMode.SYNCHRONOUS); + final SynchronousEventCache synchronousEventCache = + (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS); if (synchronousEventCache != null) { synchronousEventCache.removeCachedEventToApexIfExists(executionId); } @@ -217,8 +219,7 @@ public class ApexJmsProducer implements ApexEventProducer { // Check if the object to be sent is serializable if (!Serializable.class.isAssignableFrom(eventObject.getClass())) { final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name - + ", object of type \"" + eventObject.getClass().getCanonicalName() - + "\" is not serializable"; + + ", object of type \"" + eventObject.getClass().getCanonicalName() + "\" is not serializable"; LOGGER.warn(errorMessage); throw new ApexEventRuntimeException(errorMessage); } @@ -233,7 +234,7 @@ public class ApexJmsProducer implements ApexEventProducer { jmsMessage = jmsSession.createObjectMessage((Serializable) eventObject); } catch (final Exception e) { final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name - + ", could not create JMS Object Message for object \"" + eventObject; + + ", could not create JMS Object Message for object \"" + eventObject; LOGGER.warn(errorMessage, e); throw new ApexEventRuntimeException(errorMessage); } @@ -243,7 +244,7 @@ public class ApexJmsProducer implements ApexEventProducer { jmsMessage = jmsSession.createTextMessage(eventObject.toString()); } catch (final Exception e) { final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name - + ", could not create JMS Text Message for object \"" + eventObject; + + ", could not create JMS Text Message for object \"" + eventObject; LOGGER.warn(errorMessage, e); throw new ApexEventRuntimeException(errorMessage); } @@ -253,7 +254,7 @@ public class ApexJmsProducer implements ApexEventProducer { messageProducer.send(jmsMessage); } catch (final Exception e) { final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name - + ", send failed for object \"" + eventObject; + + ", send failed for object \"" + eventObject; LOGGER.warn(errorMessage, e); throw new ApexEventRuntimeException(errorMessage); } |