Search in sources :

Example 96 with StandaloneProducer

use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.

the class ActiveMqJmsTransactedWorkflowTest method testMessagesOrderedUsingQueue.

@Test
public void testMessagesOrderedUsingQueue() throws Exception {
    int msgCount = 10;
    String destination = createSafeUniqueId(new Object());
    Channel channel = createStartableChannel(activeMqBroker, true, "testMessagesOrderedUsingQueue", destination);
    JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
    workflow.getServiceCollection().addService(new RandomlyFail());
    try {
        channel.requestStart();
        StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
        start(sender);
        for (int i = 0; i < msgCount; i++) {
            sender.doService(AdaptrisMessageFactory.getDefaultInstance().newMessage("" + i));
        }
        stop(sender);
        waitForMessages((MockMessageProducer) workflow.getProducer(), msgCount);
        List<AdaptrisMessage> receivedList = ((MockMessageProducer) workflow.getProducer()).getMessages();
        assertEquals(msgCount, receivedList.size());
        for (int i = 0; i < msgCount; i++) {
            assertEquals(String.valueOf(i), receivedList.get(i).getContent());
        }
    } finally {
        channel.requestClose();
    }
    assertEquals(0, activeMqBroker.messagesOnQueue(destination));
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) JmsTransactedWorkflow(com.adaptris.core.jms.JmsTransactedWorkflow) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 97 with StandaloneProducer

use of com.adaptris.core.StandaloneProducer 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)

Example 98 with StandaloneProducer

use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.

the class JndiPasProducerCase method testProduceJndiOnlyObjectNotFound.

@Test
public void testProduceJndiOnlyObjectNotFound() throws Exception {
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPasConnection(sendVendorImp, true, queueName, topicName), new PasProducer().withTopic(this.getClass().getSimpleName()));
    try {
        start(standaloneProducer);
        standaloneProducer.produce(createMessage(null));
        fail("Expected ProduceException");
    } catch (ProduceException expected) {
    } finally {
        stop(standaloneProducer);
    }
}
Also used : StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) ProduceException(com.adaptris.core.ProduceException) Test(org.junit.Test)

Example 99 with StandaloneProducer

use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.

the class JndiPtpProducerCase method testProduceJndiOnlyObjectNotFound.

@Test
public void testProduceJndiOnlyObjectNotFound() throws Exception {
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, true, queueName, topicName), new PtpProducer().withQueue((this.getClass().getSimpleName())));
    try {
        start(standaloneProducer);
        standaloneProducer.produce(createMessage(null));
        fail("Expected ProduceException");
    } catch (ProduceException expected) {
    } finally {
        stop(standaloneProducer);
    }
}
Also used : StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) ProduceException(com.adaptris.core.ProduceException) Test(org.junit.Test)

Example 100 with StandaloneProducer

use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.

the class JndiPtpProducerCase method testProduceAndConsumeUsingJndiOnly.

@Test
public void testProduceAndConsumeUsingJndiOnly() throws Exception {
    StandardJndiImplementation recvVendorImp = createVendorImplementation();
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, true, queueName, topicName), new PtpConsumer().withQueue(queueName));
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, true, queueName, topicName), new PtpProducer().withQueue((queueName)));
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) 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)

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