Search in sources :

Example 46 with StandaloneProducer

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

the class AggregatingJmsConsumeServiceTest method sendDataMessage.

private void sendDataMessage(EmbeddedActiveMq broker, String queue) throws Exception {
    PtpProducer producer = new PtpProducer().withQueue(queue);
    MetadataCorrelationIdSource corr = new MetadataCorrelationIdSource();
    corr.setMetadataKey(CORRELATION_ID_KEY);
    producer.setCorrelationIdSource(corr);
    StandaloneProducer sp = new StandaloneProducer(broker.getJmsConnection(new BasicActiveMqImplementation(), true), producer);
    try {
        start(sp);
        AdaptrisMessage msg = new DefaultMessageFactory().newMessage(DATA_PAYLOAD);
        msg.addMetadata(CORRELATION_ID_KEY, "0001");
        sp.doService(msg);
    } finally {
        stop(sp);
    }
}
Also used : DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer)

Example 47 with StandaloneProducer

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

the class JmsProducerTest method testTimedInactivitySession_SessionStillValid.

@Test
public void testTimedInactivitySession_SessionStillValid() throws Exception {
    String rfc6167 = "jms:queue:" + getName() + "";
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    JmsProducer producer = createProducer(rfc6167);
    TimedInactivityProducerSessionFactory psf = new TimedInactivityProducerSessionFactory();
    producer.setSessionFactory(psf);
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    try {
        start(standaloneConsumer, standaloneProducer);
        standaloneProducer.doService(createMessage());
        Thread.sleep(200);
        assertFalse(psf.newSessionRequired());
        // Still should be a valid session; and could produce regardless.
        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 48 with StandaloneProducer

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

the class JmsProducerTest method retrieveObjectsForSampleConfig.

@Override
protected List<Object> retrieveObjectsForSampleConfig() {
    ArrayList<Object> result = new ArrayList<>();
    boolean useQueue = true;
    for (MessageTypeTranslator t : MESSAGE_TRANSLATOR_LIST) {
        StandaloneProducer p = retrieveSampleConfig(useQueue);
        ((JmsProducer) p.getProducer()).setMessageTranslator(t);
        useQueue = !useQueue;
        result.add(p);
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) StandaloneProducer(com.adaptris.core.StandaloneProducer)

Example 49 with StandaloneProducer

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

the class JmsProducerTest method testProduce_CaptureOutgoingMessageDetails.

// @Test
// public void testProduce_JmsReplyToDestination() throws Exception {
// Topic topic = createTopic(activeMqBroker, getName());
// AdaptrisMessage msg = createMessage(topic);
// JmsReplyToDestination d = new JmsReplyToDestination();
// 
// JmsProducer producer = createProducer(d);
// producer.setCaptureOutgoingMessageDetails(true);
// StandaloneProducer sp = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
// 
// ExampleServiceCase.execute(sp, msg);
// Map<Object, Object> objMd = msg.getObjectHeaders();
// String prefix = Message.class.getCanonicalName() + ".";
// assertTrue(objMd.containsKey(prefix + JmsConstants.JMS_MESSAGE_ID));
// assertTrue(objMd.containsKey(prefix + JmsConstants.JMS_DESTINATION));
// assertTrue(objMd.containsKey(prefix + JmsConstants.JMS_PRIORITY));
// assertTrue(objMd.containsKey(prefix + JmsConstants.JMS_TIMESTAMP));
// }
@Test
public void testProduce_CaptureOutgoingMessageDetails() throws Exception {
    String rfc6167 = "jms:queue:" + getName();
    JmsProducer producer = createProducer(rfc6167);
    producer.setCaptureOutgoingMessageDetails(true);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    try {
        AdaptrisMessage msg = createMessage();
        ExampleServiceCase.execute(standaloneProducer, msg);
        Map<Object, Object> objectMetadata = msg.getObjectHeaders();
        assertTrue(objectMetadata.containsKey(Message.class.getCanonicalName() + "." + JmsConstants.JMS_MESSAGE_ID));
        assertTrue(objectMetadata.containsKey(Message.class.getCanonicalName() + "." + JmsConstants.JMS_DESTINATION));
        assertTrue(objectMetadata.containsKey(Message.class.getCanonicalName() + "." + JmsConstants.JMS_PRIORITY));
        assertTrue(objectMetadata.containsKey(Message.class.getCanonicalName() + "." + JmsConstants.JMS_TIMESTAMP));
    } finally {
        stop(standaloneProducer);
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 50 with StandaloneProducer

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

the class JmsProducerTest method testProduceAndConsume_ObjectEndpoint.

@Test
public void testProduceAndConsume_ObjectEndpoint() throws Exception {
    Queue queue = activeMqBroker.createQueue(getName());
    String endpoint = "%messageObject{objectEndpoint}";
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode(String.valueOf(AcknowledgeMode.Mode.AUTO_ACKNOWLEDGE.acknowledgeMode()));
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    JmsProducer producer = createProducer(endpoint);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    AdaptrisMessage msg = createMessage();
    msg.addObjectHeader("objectEndpoint", queue);
    execute(standaloneConsumer, standaloneProducer, msg, jms);
    assertMessages(jms, 1);
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Queue(javax.jms.Queue) 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