use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testTopicProduceAndConsumeWrongType.
@Test
public void testTopicProduceAndConsumeWrongType() throws Exception {
PasConsumer consumer = new PasConsumer().withTopic(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
consumer.setMessageTranslator(new BytesMessageTranslator());
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PasProducer().withTopic(getName()));
execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.jms.PasProducer 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.jms.PasProducer 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.jms.PasProducer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testTopicRequestReply_Bug2277.
@Test
public void testTopicRequestReply_Bug2277() throws Exception {
TopicLoopback echo = new TopicLoopback(activeMqBroker, getName());
try {
echo.start();
StandaloneRequestor standaloneProducer = new StandaloneRequestor(activeMqBroker.getJmsConnection(createVendorImpl()), new PasProducer().withTopic(getName()));
AdaptrisMessage msg = createMessage();
msg.addMetadata(JmsConstants.JMS_ASYNC_STATIC_REPLY_TO, getName() + "_reply");
ExampleServiceCase.execute(standaloneProducer, msg);
echo.waitFor(DEFAULT_TIMEOUT);
assertNotNull(echo.getLastMessage());
assertNotNull(echo.getLastMessage().getJMSReplyTo());
assertEquals("topic://" + getName() + "_reply", echo.getLastMessage().getJMSReplyTo().toString());
} finally {
echo.stop();
}
}
use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.
the class JmsConnectionErrorHandlerTest method createProducer.
private StandaloneProducer createProducer(EmbeddedActiveMq mq, String dest) {
JmsConnection conn = mq.getJmsConnection(new BasicActiveMqImplementation(), true);
conn.setConnectionErrorHandler(new JmsConnectionErrorHandler());
PasProducer producer = new PasProducer().withTopic(dest);
return new StandaloneProducer(conn, producer);
}
Aggregations