Search in sources :

Example 26 with PtpProducer

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

Example 27 with PtpProducer

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

the class JndiPtpProducerCase method testProduceAndConsume_ExtraConfig.

@Test
public void testProduceAndConsume_ExtraConfig() throws Exception {
    SimpleFactoryConfiguration sfc = new SimpleFactoryConfiguration();
    KeyValuePairSet kvps = new KeyValuePairSet();
    kvps.add(new KeyValuePair("ClientID", "testProduceAndConsume_ExtraConfig"));
    kvps.add(new KeyValuePair("UseCompression", "true"));
    sfc.setProperties(kvps);
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandardJndiImplementation recvVendorImp = createVendorImplementation();
    StandardJndiImplementation sendVendorImp = createVendorImplementation();
    sendVendorImp.setExtraFactoryConfiguration(sfc);
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, false, queueName, topicName), new PtpConsumer().withQueue(queueName));
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, false, queueName, topicName), new PtpProducer().withQueue((queueName)));
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) KeyValuePair(com.adaptris.util.KeyValuePair) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) SimpleFactoryConfiguration(com.adaptris.core.jms.jndi.SimpleFactoryConfiguration) PtpProducer(com.adaptris.core.jms.PtpProducer) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 28 with PtpProducer

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

the class RequestReplyWorkflowTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    Channel c = new Channel();
    try {
        c.setConsumeConnection(new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616")));
        c.setProduceConnection(new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:2506")));
        RequestReplyWorkflow workflow = new RequestReplyWorkflow();
        workflow.getServiceCollection().addService(new Base64DecodeService());
        workflow.setConsumer(new PtpConsumer().withQueue("inputQueue"));
        workflow.setProducer(new PtpProducer().withQueue("outputQueue"));
        workflow.setReplyProducer(new PtpProducer().withQueue("TODO"));
        workflow.getReplyServiceCollection().addService(new Base64EncodeService());
        c.getWorkflowList().add(workflow);
        c.setUniqueId(UUID.randomUUID().toString());
        workflow.setUniqueId(UUID.randomUUID().toString());
    } catch (CoreException e) {
        throw new RuntimeException(e);
    }
    return c;
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) Base64EncodeService(com.adaptris.core.services.Base64EncodeService) BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) MockChannel(com.adaptris.core.stubs.MockChannel) Base64DecodeService(com.adaptris.core.services.Base64DecodeService) JmsConnection(com.adaptris.core.jms.JmsConnection) PtpProducer(com.adaptris.core.jms.PtpProducer)

Example 29 with PtpProducer

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

the class AdapterTest method createRetryingAdapter.

/**
 * <p>
 * Creates a valid Adapter to use in tests. Uese Mock aka Memory MessageConsumer / Producer.
 * </p>
 *
 * @param uniqueId a uniqure identifier for this <code>Adapter</code>
 */
public static Adapter createRetryingAdapter(String uniqueId) throws Exception {
    Adapter result = null;
    AdaptrisConnection consume = new NullConnection();
    JmsConnection produce = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:5000"));
    produce.setConnectionRetryInterval(new TimeInterval(1L, TimeUnit.SECONDS.name()));
    produce.setConnectionAttempts(20);
    AdaptrisMessageProducer producer1 = new PtpProducer().withQueue("dummyQueue");
    StandardWorkflow workflow1 = new StandardWorkflow();
    workflow1.setProducer(producer1);
    WorkflowList workflows = new WorkflowList();
    workflows.add(workflow1);
    Channel channel = new Channel();
    channel.setUniqueId(uniqueId + "_c1");
    channel.setConsumeConnection(consume);
    channel.setProduceConnection(produce);
    channel.setWorkflowList(workflows);
    ChannelList channels = new ChannelList();
    channels.addChannel(channel);
    result = new Adapter();
    result.setChannelList(channels);
    result.setUniqueId(uniqueId);
    return result;
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) TimeInterval(com.adaptris.util.TimeInterval) JmsConnection(com.adaptris.core.jms.JmsConnection) PtpProducer(com.adaptris.core.jms.PtpProducer)

Example 30 with PtpProducer

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

the class ActiveMqJmsTransactedWorkflowTest method testRuntimeException.

@Test
public void testRuntimeException() throws Exception {
    int msgCount = 10;
    String destination = createSafeUniqueId(new Object());
    Channel channel = createStartableChannel(activeMqBroker, true, "testRuntimeException", destination);
    JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
    workflow.setProducer(new MockMessageProducer() {

        @Override
        protected void doProduce(AdaptrisMessage msg, String endpoint) throws ProduceException {
            throw new RuntimeException();
        }
    });
    try {
        channel.requestStart();
        StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
        send(sender, msgCount);
    } finally {
        channel.requestClose();
    }
    assertEquals(msgCount, 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) ProduceException(com.adaptris.core.ProduceException) Test(org.junit.Test)

Aggregations

PtpProducer (com.adaptris.core.jms.PtpProducer)52 StandaloneProducer (com.adaptris.core.StandaloneProducer)46 Test (org.junit.Test)46 PtpConsumer (com.adaptris.core.jms.PtpConsumer)24 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)23 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)23 MockChannel (com.adaptris.core.stubs.MockChannel)14 Channel (com.adaptris.core.Channel)13 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)12 JmsTransactedWorkflow (com.adaptris.core.jms.JmsTransactedWorkflow)12 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)10 JmsConnection (com.adaptris.core.jms.JmsConnection)8 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)6 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)6 ConfiguredException (com.adaptris.core.services.exception.ConfiguredException)5 BytesMessageTranslator (com.adaptris.core.jms.BytesMessageTranslator)4 TimeInterval (com.adaptris.util.TimeInterval)4 ProduceException (com.adaptris.core.ProduceException)3 Service (com.adaptris.core.Service)3 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3