Search in sources :

Example 6 with PasProducer

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

Example 7 with PasProducer

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

Example 8 with PasProducer

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);
}
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 9 with PasProducer

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

Example 10 with PasProducer

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

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