Search in sources :

Example 61 with StandaloneProducer

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

the class BasicJmsProducerCase method testMessageSizeSession.

@Test
public void testMessageSizeSession() throws Exception {
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    DefinedJmsProducer producer = createProducer(getName());
    MessageSizeProducerSessionFactory psf = new MessageSizeProducerSessionFactory(Integer.valueOf(DEFAULT_PAYLOAD.length() - 1).longValue());
    producer.setSessionFactory(psf);
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    try {
        start(standaloneConsumer, standaloneProducer);
        standaloneProducer.doService(createMessage());
        standaloneProducer.doService(createMessage());
        assertTrue(psf.newSessionRequired());
        // Should create a new Session now.
        standaloneProducer.doService(createMessage());
        waitForMessages(jms, 3);
        assertMessages(jms, 3);
    } finally {
        stop(standaloneProducer, standaloneConsumer);
    }
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 62 with StandaloneProducer

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

the class BasicJmsProducerCase method testMessageCountSession_SessionStillValid.

@Test
public void testMessageCountSession_SessionStillValid() throws Exception {
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    DefinedJmsProducer producer = createProducer(getName());
    MessageCountProducerSessionFactory psf = new MessageCountProducerSessionFactory();
    producer.setSessionFactory(psf);
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    try {
        start(standaloneConsumer, standaloneProducer);
        standaloneProducer.doService(createMessage());
        assertFalse(psf.newSessionRequired());
        standaloneProducer.doService(createMessage());
        waitForMessages(jms, 2);
        assertMessages(jms, 2);
    } finally {
        stop(standaloneProducer, standaloneConsumer);
    }
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 63 with StandaloneProducer

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

the class DestinationCacheJndiPasProducerTest method testProduceAndConsumeWithCache.

@Test
public void testProduceAndConsumeWithCache() throws Exception {
    StandardJndiImplementation recvVendorImp = createVendorImplementation();
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPasConnection(recvVendorImp, false, queueName, topicName), new PasConsumer().withTopic(topicName));
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPasConnection(sendVendorImp, false, queueName, topicName), new PasProducer().withTopic(topicName));
    try {
        start(standaloneConsumer);
        start(standaloneProducer);
        standaloneProducer.doService(createMessage(null));
        standaloneProducer.doService(createMessage(null));
        waitForMessages(jms, 2);
        assertMessages(jms, 2);
    } finally {
        stop(standaloneProducer);
        stop(standaloneConsumer);
    }
}
Also used : PasConsumer(com.adaptris.core.jms.PasConsumer) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) 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 64 with StandaloneProducer

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

the class DestinationCacheJndiPtpProducerTest method testProduceWithCache.

@Test
public void testProduceWithCache() throws Exception {
    DestinationCachingJndiVendorImpl sendVendorImp = new DestinationCachingJndiVendorImpl();
    sendVendorImp.setUseJndiForQueues(true);
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, false, queueName, topicName), new PtpProducer().withQueue((queueName)));
    try {
        start(standaloneProducer);
        standaloneProducer.doService(createMessage(null));
        standaloneProducer.doService(createMessage(null));
        assertEquals(1, sendVendorImp.queueCacheSize());
        assertTrue(sendVendorImp.queueCache().containsKey(queueName));
    } finally {
        stop(standaloneProducer);
    }
}
Also used : PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 65 with StandaloneProducer

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

the class ActiveMqJmsTransactedWorkflowTest method testHandleChannelUnavailable_Bug2343.

@Test
public void testHandleChannelUnavailable_Bug2343() throws Exception {
    int msgCount = 10;
    String destination = createSafeUniqueId(new Object());
    final Channel channel = createStartableChannel(activeMqBroker, true, "testHandleChannelUnavailable_Bug2343", destination);
    JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
    workflow.setChannelUnavailableWaitInterval(new TimeInterval(1L, TimeUnit.SECONDS));
    try {
        channel.requestStart();
        channel.toggleAvailability(false);
        Timer t = new Timer();
        t.schedule(new TimerTask() {

            @Override
            public void run() {
                channel.toggleAvailability(true);
            }
        }, 666);
        StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
        send(sender, msgCount);
        waitForMessages((MockMessageProducer) workflow.getProducer(), msgCount);
        assertEquals(msgCount, ((MockMessageProducer) workflow.getProducer()).getMessages().size());
    } finally {
        channel.requestClose();
    }
    assertEquals(0, activeMqBroker.messagesOnQueue(destination));
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) Timer(java.util.Timer) TimerTask(java.util.TimerTask) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) 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)

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