use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class BasicActiveMqImplementationTest method testRfc6167_WithParams.
@Test
public void testRfc6167_WithParams() throws Exception {
StandaloneProducer producer = null;
try {
BasicActiveMqImplementation vendorImp = create();
PtpProducer ptp = new PtpProducer().withQueue((testName.getMethodName()));
producer = new StandaloneProducer(activeMqBroker.getJmsConnection(vendorImp), ptp);
start(producer);
// Send a message so that the session is correct.
producer.doService(AdaptrisMessageFactory.getDefaultInstance().newMessage("abcde"));
JmsDestination jmsDest = vendorImp.createDestination("jms:queue:MyQueueName?replyToName=StaticReplyTo&priority=1&deliveryMode=NON_PERSISTENT&timeToLive=1000", ptp);
assertNotNull(jmsDest.getDestination());
assertTrue(javax.jms.Queue.class.isAssignableFrom(jmsDest.getDestination().getClass()));
assertNotNull(jmsDest.getReplyToDestination());
assertTrue(javax.jms.Queue.class.isAssignableFrom(jmsDest.getReplyToDestination().getClass()));
assertNotNull(jmsDest.deliveryMode());
assertEquals("NON_PERSISTENT", jmsDest.deliveryMode());
assertNotNull(jmsDest.priority());
assertEquals(Integer.valueOf(1), jmsDest.priority());
assertNotNull(jmsDest.timeToLive());
assertEquals(Long.valueOf(1000), jmsDest.timeToLive());
assertNull(jmsDest.subscriptionId());
assertFalse(jmsDest.noLocal());
} finally {
stop(producer);
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class BasicActiveMqImplementationTest method testRfc6167_Invalid.
@Test
public void testRfc6167_Invalid() throws Exception {
StandaloneProducer producer = null;
try {
BasicActiveMqImplementation vendorImp = create();
PtpProducer ptp = new PtpProducer().withQueue((testName.getMethodName()));
producer = new StandaloneProducer(activeMqBroker.getJmsConnection(vendorImp), ptp);
start(producer);
// Send a message so that the session is correct.
producer.doService(AdaptrisMessageFactory.getDefaultInstance().newMessage("abcde"));
try {
vendorImp.createDestination("hello:queue:myQueueName", ptp);
} catch (JMSException e) {
assertTrue(e.getMessage().startsWith("failed to parse"));
}
try {
vendorImp.createDestination(null, ptp);
} catch (JMSException e) {
assertTrue(e.getMessage().startsWith("failed to parse"));
}
} finally {
stop(producer);
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class PtpProducerTest method retrieveSampleConfig.
private StandaloneProducer retrieveSampleConfig() {
JmsConnection c = configureForExamples(new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616")));
c.setClientId(null);
StandaloneProducer result = new StandaloneProducer(c, configureForExamples(new PtpProducer().withQueue("SampleQ1")));
return result;
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testQueueProduceAndConsumeWrongType.
@Test
public void testQueueProduceAndConsumeWrongType() throws Exception {
PtpConsumer consumer = new PtpConsumer().withQueue(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 PtpProducer().withQueue((getName())));
execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testTopicProduceAndConsume_DurableSubscriber_Legacy.
@Test
public void testTopicProduceAndConsume_DurableSubscriber_Legacy() 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);
}
Aggregations