use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testTopicProduceAndConsume_CustomMessageFactory.
@Test
public void testTopicProduceAndConsume_CustomMessageFactory() throws Exception {
PasConsumer consumer = new PasConsumer().withTopic(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
consumer.setMessageFactory(new StubMessageFactory());
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);
assertEquals(AdaptrisMessageStub.class, jms.getMessages().get(0).getClass());
}
use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.
the class BasicActiveMqConsumerTest method testTopicProduceAndConsume.
@Test
public void testTopicProduceAndConsume() throws Exception {
PasConsumer consumer = new PasConsumer().withTopic(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 PasProducer().withTopic(getName()));
// INTERLOK-3329 For coverage so the prepare() warning is executed 2x
LifecycleHelper.prepare(standaloneConsumer);
LifecycleHelper.prepare(standaloneProducer);
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms, 1);
AdaptrisMessage consumed = jms.getMessages().get(0);
// Since it's not a workflow; this will be false.
assertFalse(consumed.headersContainsKey(CoreConstants.MESSAGE_CONSUME_LOCATION));
}
use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.
the class BasicActiveMqConsumerTest method testTopic_ProduceWhenConsumerStopped.
@Test
public void testTopic_ProduceWhenConsumerStopped() throws Exception {
PasConsumer consumer = new PasConsumer().withTopic(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandardWorkflow workflow = new StandardWorkflow();
MockMessageProducer producer = new MockMessageProducer();
workflow.setConsumer(consumer);
workflow.setProducer(producer);
Channel channel = createChannel(activeMqBroker.getJmsConnection(createVendorImpl()), workflow);
try {
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PasProducer().withTopic(getName()));
channel.requestStart();
workflow.requestStop();
start(standaloneProducer);
AdaptrisMessage msg = createMessage(null);
standaloneProducer.produce(msg);
Thread.sleep(250);
assertEquals(0, producer.messageCount());
stop(standaloneProducer);
} finally {
channel.requestClose();
}
}
use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.
the class BasicActiveMqConsumerTest method testTopicProduceAndConsumeWithImplicitFallbackMessageTranslation.
@Test
public void testTopicProduceAndConsumeWithImplicitFallbackMessageTranslation() throws Exception {
PasConsumer consumer = new PasConsumer().withTopic(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
DefinedJmsProducer producer = new PasProducer().withTopic(getName());
producer.setMessageTranslator(new BytesMessageTranslator());
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.
the class JndiImplementationCase method testInitialiseWithTopicConnectionFactoryNotFound.
@Test
public void testInitialiseWithTopicConnectionFactoryNotFound() throws Exception {
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
PasProducer producer = new PasProducer().withTopic(queueName);
StandardJndiImplementation jv = createVendorImplementation();
JmsConnection c = activeMqBroker.getJndiPasConnection(jv, false, queueName, topicName);
c.setConnectionAttempts(1);
c.setConnectionRetryInterval(new TimeInterval(100L, TimeUnit.MILLISECONDS.name()));
jv.setJndiName("testInitialiseWithTopicConnectionFactoryNotFound");
StandaloneProducer standaloneProducer = new StandaloneProducer(c, producer);
try {
LifecycleHelper.init(standaloneProducer);
fail("Should Fail to lookup 'testInitialiseWithTopicConnectionFactoryNotFound'");
} catch (Exception e) {
// expected
}
}
Aggregations