aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-06-26 15:40:41 +0000
committerliamfallon <liam.fallon@est.tech>2019-06-26 15:40:41 +0000
commitce9d82d2c0e863597d84cc8909955e398405f45a (patch)
tree8ebb853119bdf673cf6f9516d428d4cc00080aeb /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src
parent5f029543f1e673655af2d2974113069df0b6def0 (diff)
Add passthrough properties for APEX engine
APEX event receiver and sender plugins sometimes need to exchange information with tasks, especially in the case of REST communication. This change enables passthrough of Properties from the event carrier technology plugins to APEX task, task selection, and state finalizer logics. Apologies for the size of the review but this change involves passinng the properties through all the APEX components, hence the large number of small changes. Issue-ID: POLICY-1742 Change-Id: I219fd69550f06702ef64adbb165fe7baac422e96 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java33
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java47
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java4
3 files changed, 37 insertions, 47 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);
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
index e981f4158..34ffc4c75 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/test/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducerTest.java
@@ -101,7 +101,7 @@ public class ApexJmsProducerTest {
synchronousEventCache);
ApexEvent apexEvent = new ApexEvent("testEvent", "testVersion", "testNameSpace",
"testSource", "testTarget");
- apexJmsProducer.sendEvent(1000L, "TestApexJmsProducer", apexEvent);
+ apexJmsProducer.sendEvent(1000L, null, "TestApexJmsProducer", apexEvent);
}
@Test(expected = ApexEventRuntimeException.class)
@@ -111,7 +111,7 @@ public class ApexJmsProducerTest {
apexJmsConsumer, apexJmsProducer, DEFAULT_SYNCHRONOUS_EVENT_TIMEOUT);
apexJmsProducer.setPeeredReference(EventHandlerPeeredMode.SYNCHRONOUS,
synchronousEventCache);
- apexJmsProducer.sendEvent(-1L, "TestApexJmsProducer", new ApexJmsProducerTest());
+ apexJmsProducer.sendEvent(-1L, null, "TestApexJmsProducer", new ApexJmsProducerTest());
}
@Test