Search in sources :

Example 76 with StandaloneProducer

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

Example 77 with StandaloneProducer

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

Example 78 with StandaloneProducer

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

Example 79 with StandaloneProducer

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);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) PtpProducer(com.adaptris.core.jms.PtpProducer) 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 80 with StandaloneProducer

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);
}
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)

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