Search in sources :

Example 16 with PasProducer

use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.

the class MessageTypeTranslatorCase method createProducer.

private StandaloneProducer createProducer(MessageTypeTranslator mt) throws Exception {
    PasProducer producer = new PasProducer();
    producer.withTopic(testName.getMethodName());
    producer.setMessageTranslator(mt);
    return new StandaloneProducer(new JmsConnection(), producer);
}
Also used : PasProducer(com.adaptris.core.jms.PasProducer) JmsConnection(com.adaptris.core.jms.JmsConnection) StandaloneProducer(com.adaptris.core.StandaloneProducer)

Example 17 with PasProducer

use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.

the class ActiveMqJmsTransactedWorkflowTest method testMessagesCommittedUsingTopic.

@Test
public void testMessagesCommittedUsingTopic() throws Exception {
    int msgCount = 10;
    String destination = createSafeUniqueId(new Object());
    Channel channel = createStartableChannel(activeMqBroker, false, "testMessagesCommittedUsingTopic", destination);
    JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
    try {
        channel.requestStart();
        StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PasProducer().withTopic(destination));
        send(sender, msgCount);
        waitForMessages((MockMessageProducer) workflow.getProducer(), msgCount);
        assertEquals(msgCount, ((MockMessageProducer) workflow.getProducer()).getMessages().size());
    } finally {
        channel.requestClose();
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) JmsTransactedWorkflow(com.adaptris.core.jms.JmsTransactedWorkflow) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 18 with PasProducer

use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.

the class ActiveMqJmsTransactedWorkflowTest method testWorkflowWithInterceptor.

@Test
public void testWorkflowWithInterceptor() throws Exception {
    int msgCount = 10;
    String destination = createSafeUniqueId(new Object());
    Channel channel = createStartableChannel(activeMqBroker, false, "testMessagesCommittedUsingTopic", destination);
    JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
    MockWorkflowInterceptor interceptor = new MockWorkflowInterceptor();
    workflow.addInterceptor(interceptor);
    try {
        channel.requestStart();
        StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PasProducer().withTopic(destination));
        send(sender, msgCount);
        waitForMessages((MockMessageProducer) workflow.getProducer(), msgCount);
        assertEquals(msgCount, ((MockMessageProducer) workflow.getProducer()).getMessages().size());
        assertEquals(msgCount, interceptor.messageCount());
    } finally {
        channel.requestClose();
    }
}
Also used : MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) JmsTransactedWorkflow(com.adaptris.core.jms.JmsTransactedWorkflow) PasProducer(com.adaptris.core.jms.PasProducer) MockWorkflowInterceptor(com.adaptris.core.stubs.MockWorkflowInterceptor) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 19 with PasProducer

use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.

the class ActiveMqJmsTransactedWorkflowTest method testMessagesOrderedUsingTopic.

@Test
public void testMessagesOrderedUsingTopic() throws Exception {
    int msgCount = 10;
    String destination = createSafeUniqueId(new Object());
    Channel channel = createStartableChannel(activeMqBroker, false, "testMessagesOrderedUsingTopic", destination);
    JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
    workflow.getServiceCollection().addService(new RandomlyFail());
    try {
        channel.requestStart();
        StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PasProducer().withTopic(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();
    }
}
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) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 20 with PasProducer

use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.

the class FailoverPasProducerTest method testProduceAndConsume.

@Test
public void testProduceAndConsume() throws Exception {
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getFailoverJmsConnection(false), new PasConsumer().withTopic(testName.getMethodName()));
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getFailoverJmsConnection(false), new PasProducer().withTopic(testName.getMethodName()));
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms, 1);
}
Also used : PasConsumer(com.adaptris.core.jms.PasConsumer) 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

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