use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testTopicProduceWithPerMessageProperties.
@Test
public void testTopicProduceWithPerMessageProperties() throws Exception {
TopicLoopback echo = new TopicLoopback(activeMqBroker, getName());
try {
echo.start();
PasProducer pasProducer = new PasProducer().withTopic(getName());
pasProducer.setDeliveryMode(String.valueOf(DeliveryMode.PERSISTENT));
pasProducer.setPriority(LOWEST_PRIORITY);
pasProducer.setTtl(0L);
pasProducer.setPerMessageProperties(true);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), pasProducer);
ExampleServiceCase.execute(standaloneProducer, createMessage());
echo.waitFor(DEFAULT_TIMEOUT);
assertNotNull(echo.getLastMessage());
assertEquals(HIGHEST_PRIORITY, echo.getLastMessage().getJMSPriority());
assertEquals(DeliveryMode.NON_PERSISTENT, echo.getLastMessage().getJMSDeliveryMode());
} finally {
echo.stop();
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testTopicProduceAndConsume_DurableSubscriber.
@Test
public // INTERLOK-3537, if subscriptionId != "", then it should be durable.
void testTopicProduceAndConsume_DurableSubscriber() throws Exception {
String subscriptionId = GUID.safeUUID();
String clientId = GUID.safeUUID();
PasConsumer consumer = new PasConsumer().withTopic(getName());
consumer.setSubscriptionId(subscriptionId);
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
JmsConnection conn = activeMqBroker.getJmsConnection(createVendorImpl(), true);
conn.setClientId(clientId);
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(conn, consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
// Start it once to get some durable Action.
start(standaloneConsumer);
stop(standaloneConsumer);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PasProducer().withTopic(getName()));
int count = 10;
for (int i = 0; i < count; i++) {
ExampleServiceCase.execute(standaloneProducer, createMessage());
}
start(standaloneConsumer);
waitForMessages(jms, count);
assertMessages(jms, 10);
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testQueueProduceAndConsume_ResolveableEndpoint.
@Test
public void testQueueProduceAndConsume_ResolveableEndpoint() throws Exception {
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PtpProducer().withQueue("%message{metadataEndpoint}"));
AdaptrisMessage msg = createMessage();
msg.addMessageHeader("metadataEndpoint", getName());
execute(standaloneConsumer, standaloneProducer, msg, jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testQueueProduceAndConsume_WithEncoder.
@Test
public void testQueueProduceAndConsume_WithEncoder() throws Exception {
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setEncoder(new MimeEncoder());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
PtpProducer producer = new PtpProducer().withQueue((getName()));
producer.setEncoder(new MimeEncoder());
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class ActiveMqJmsPollingConsumerTest method testQueue_ProduceConsume.
@Test
public void testQueue_ProduceConsume() throws Exception {
int msgCount = 5;
String rfc6167 = "jms:queue:" + testName.getMethodName();
final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
final StandaloneConsumer receiver = createStandaloneConsumer(activeMqBroker, testName.getMethodName(), rfc6167);
try {
MockMessageListener jms = new MockMessageListener();
receiver.registerAdaptrisMessageListener(jms);
// INTERLOK-3329 For coverage so the prepare() warning is executed 2x
LifecycleHelper.prepare(sender);
LifecycleHelper.prepare(receiver);
start(receiver);
start(sender);
for (int i = 0; i < msgCount; i++) {
sender.doService(createMessage());
}
waitForMessages(jms, msgCount);
assertMessages(jms, msgCount);
} finally {
shutdownQuietly(sender, receiver);
}
}
Aggregations