Search in sources :

Example 86 with StandaloneProducer

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

Example 87 with StandaloneProducer

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);
}
Also used : PasConsumer(com.adaptris.core.jms.PasConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection) 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 88 with StandaloneProducer

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

Example 89 with StandaloneProducer

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

Example 90 with StandaloneProducer

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

Aggregations

StandaloneProducer (com.adaptris.core.StandaloneProducer)266 Test (org.junit.Test)238 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)125 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)91 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)91 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)68 Channel (com.adaptris.core.Channel)64 PtpProducer (com.adaptris.core.jms.PtpProducer)46 ServiceList (com.adaptris.core.ServiceList)39 PasProducer (com.adaptris.core.jms.PasProducer)34 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)32 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)27 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)23 PtpConsumer (com.adaptris.core.jms.PtpConsumer)23 TimeInterval (com.adaptris.util.TimeInterval)23 MockChannel (com.adaptris.core.stubs.MockChannel)22 ServiceException (com.adaptris.core.ServiceException)20 StandardWorkflow (com.adaptris.core.StandardWorkflow)20 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)20 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)20