Search in sources :

Example 31 with PasProducer

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());
}
Also used : PasConsumer(com.adaptris.core.jms.PasConsumer) StubMessageFactory(com.adaptris.core.stubs.StubMessageFactory) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 32 with PasProducer

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));
}
Also used : PasConsumer(com.adaptris.core.jms.PasConsumer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 33 with PasProducer

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();
    }
}
Also used : StandardWorkflow(com.adaptris.core.StandardWorkflow) PasConsumer(com.adaptris.core.jms.PasConsumer) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 34 with PasProducer

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);
}
Also used : DefinedJmsProducer(com.adaptris.core.jms.DefinedJmsProducer) PasConsumer(com.adaptris.core.jms.PasConsumer) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) BytesMessageTranslator(com.adaptris.core.jms.BytesMessageTranslator) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 35 with PasProducer

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
    }
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PasProducer(com.adaptris.core.jms.PasProducer) JmsConnection(com.adaptris.core.jms.JmsConnection) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

PasProducer (com.adaptris.core.jms.PasProducer)37 StandaloneProducer (com.adaptris.core.StandaloneProducer)34 Test (org.junit.Test)34 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)15 PasConsumer (com.adaptris.core.jms.PasConsumer)15 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)15 JmsConnection (com.adaptris.core.jms.JmsConnection)12 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)11 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)7 Channel (com.adaptris.core.Channel)5 MockChannel (com.adaptris.core.stubs.MockChannel)5 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)5 KeyValuePair (com.adaptris.util.KeyValuePair)5 BytesMessageTranslator (com.adaptris.core.jms.BytesMessageTranslator)4 JmsTransactedWorkflow (com.adaptris.core.jms.JmsTransactedWorkflow)4 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3 RequiresCredentialsBroker (com.adaptris.core.jms.activemq.RequiresCredentialsBroker)3 DefinedJmsProducer (com.adaptris.core.jms.DefinedJmsProducer)2 TimeInterval (com.adaptris.util.TimeInterval)2 MimeEncoder (com.adaptris.core.MimeEncoder)1