use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class AggregatingJmsConsumeServiceTest method sendDataMessage.
private void sendDataMessage(EmbeddedActiveMq broker, String queue) throws Exception {
PtpProducer producer = new PtpProducer().withQueue(queue);
MetadataCorrelationIdSource corr = new MetadataCorrelationIdSource();
corr.setMetadataKey(CORRELATION_ID_KEY);
producer.setCorrelationIdSource(corr);
StandaloneProducer sp = new StandaloneProducer(broker.getJmsConnection(new BasicActiveMqImplementation(), true), producer);
try {
start(sp);
AdaptrisMessage msg = new DefaultMessageFactory().newMessage(DATA_PAYLOAD);
msg.addMetadata(CORRELATION_ID_KEY, "0001");
sp.doService(msg);
} finally {
stop(sp);
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class JmsProducerTest method testTimedInactivitySession_SessionStillValid.
@Test
public void testTimedInactivitySession_SessionStillValid() throws Exception {
String rfc6167 = "jms:queue:" + getName() + "";
JmsConsumerImpl consumer = createConsumer(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
MockMessageListener jms = new MockMessageListener();
JmsProducer producer = createProducer(rfc6167);
TimedInactivityProducerSessionFactory psf = new TimedInactivityProducerSessionFactory();
producer.setSessionFactory(psf);
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
try {
start(standaloneConsumer, standaloneProducer);
standaloneProducer.doService(createMessage());
Thread.sleep(200);
assertFalse(psf.newSessionRequired());
// Still should be a valid session; and could produce regardless.
standaloneProducer.doService(createMessage());
waitForMessages(jms, 2);
assertMessages(jms, 2);
} finally {
stop(standaloneProducer, standaloneConsumer);
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class JmsProducerTest method retrieveObjectsForSampleConfig.
@Override
protected List<Object> retrieveObjectsForSampleConfig() {
ArrayList<Object> result = new ArrayList<>();
boolean useQueue = true;
for (MessageTypeTranslator t : MESSAGE_TRANSLATOR_LIST) {
StandaloneProducer p = retrieveSampleConfig(useQueue);
((JmsProducer) p.getProducer()).setMessageTranslator(t);
useQueue = !useQueue;
result.add(p);
}
return result;
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class JmsProducerTest method testProduce_CaptureOutgoingMessageDetails.
// @Test
// public void testProduce_JmsReplyToDestination() throws Exception {
// Topic topic = createTopic(activeMqBroker, getName());
// AdaptrisMessage msg = createMessage(topic);
// JmsReplyToDestination d = new JmsReplyToDestination();
//
// JmsProducer producer = createProducer(d);
// producer.setCaptureOutgoingMessageDetails(true);
// StandaloneProducer sp = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
//
// ExampleServiceCase.execute(sp, msg);
// Map<Object, Object> objMd = msg.getObjectHeaders();
// String prefix = Message.class.getCanonicalName() + ".";
// assertTrue(objMd.containsKey(prefix + JmsConstants.JMS_MESSAGE_ID));
// assertTrue(objMd.containsKey(prefix + JmsConstants.JMS_DESTINATION));
// assertTrue(objMd.containsKey(prefix + JmsConstants.JMS_PRIORITY));
// assertTrue(objMd.containsKey(prefix + JmsConstants.JMS_TIMESTAMP));
// }
@Test
public void testProduce_CaptureOutgoingMessageDetails() throws Exception {
String rfc6167 = "jms:queue:" + getName();
JmsProducer producer = createProducer(rfc6167);
producer.setCaptureOutgoingMessageDetails(true);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
try {
AdaptrisMessage msg = createMessage();
ExampleServiceCase.execute(standaloneProducer, msg);
Map<Object, Object> objectMetadata = msg.getObjectHeaders();
assertTrue(objectMetadata.containsKey(Message.class.getCanonicalName() + "." + JmsConstants.JMS_MESSAGE_ID));
assertTrue(objectMetadata.containsKey(Message.class.getCanonicalName() + "." + JmsConstants.JMS_DESTINATION));
assertTrue(objectMetadata.containsKey(Message.class.getCanonicalName() + "." + JmsConstants.JMS_PRIORITY));
assertTrue(objectMetadata.containsKey(Message.class.getCanonicalName() + "." + JmsConstants.JMS_TIMESTAMP));
} finally {
stop(standaloneProducer);
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class JmsProducerTest method testProduceAndConsume_ObjectEndpoint.
@Test
public void testProduceAndConsume_ObjectEndpoint() throws Exception {
Queue queue = activeMqBroker.createQueue(getName());
String endpoint = "%messageObject{objectEndpoint}";
JmsConsumerImpl consumer = createConsumer(getName());
consumer.setAcknowledgeMode(String.valueOf(AcknowledgeMode.Mode.AUTO_ACKNOWLEDGE.acknowledgeMode()));
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
JmsProducer producer = createProducer(endpoint);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
AdaptrisMessage msg = createMessage();
msg.addObjectHeader("objectEndpoint", queue);
execute(standaloneConsumer, standaloneProducer, msg, jms);
assertMessages(jms, 1);
}
Aggregations