Search in sources :

Example 56 with StandaloneProducer

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

the class FailoverPtpProducerTest method testBug845.

@Test
public void testBug845() throws Exception {
    Object input = retrieveObjectForSampleConfig();
    String xml = defaultMarshaller.marshal(input);
    StandaloneProducer output = (StandaloneProducer) defaultMarshaller.unmarshal(xml);
    FailoverJmsConnection unmarshalled = (FailoverJmsConnection) output.getConnection();
    assertEquals("Connection count == 2", 2, unmarshalled.getConnections().size());
}
Also used : StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 57 with StandaloneProducer

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

the class BasicJmsProducerCase method testProducerSession_Invalided.

// INTERLOK-2121
@Test
public void testProducerSession_Invalided() throws Exception {
    DefinedJmsProducer producer = createProducer(getName());
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    try {
        start(standaloneProducer);
        AdaptrisMessage msg = createMessage();
        standaloneProducer.doService(msg);
        assertNotNull(producer.producerSession());
        stop(standaloneProducer);
        assertNull(producer.producerSession());
    } finally {
        stop(standaloneProducer);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 58 with StandaloneProducer

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

the class BasicJmsProducerCase method testPerMessageSession.

@Test
public void testPerMessageSession() throws Exception {
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    DefinedJmsProducer producer = createProducer(getName());
    producer.setSessionFactory(new PerMessageProducerSessionFactory());
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    try {
        start(standaloneConsumer, standaloneProducer);
        standaloneProducer.doService(createMessage());
        // Should create a new Session now.
        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 59 with StandaloneProducer

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

the class BasicJmsProducerCase method testMessageCountSession.

@Test
public void testMessageCountSession() 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(1);
    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 60 with StandaloneProducer

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

the class BasicJmsProducerCase method testTimedInactivitySession.

@Test
public void testTimedInactivitySession() 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());
    TimedInactivityProducerSessionFactory psf = new TimedInactivityProducerSessionFactory(new TimeInterval(10L, TimeUnit.MILLISECONDS));
    producer.setSessionFactory(psf);
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    try {
        start(standaloneConsumer, standaloneProducer);
        standaloneProducer.doService(createMessage());
        Thread.sleep(200);
        assertTrue(psf.newSessionRequired());
        // Should create a new Session now.
        standaloneProducer.doService(createMessage());
        waitForMessages(jms, 2);
        assertMessages(jms, 2);
    } finally {
        stop(standaloneProducer, standaloneConsumer);
    }
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) 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