Search in sources :

Example 1 with JmsProducer

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

the class ActiveMqJmsPollingConsumerTest method testQueue_ProduceConsume.

@Test
public void testQueue_ProduceConsume() throws Exception {
    int msgCount = 5;
    String rfc6167 = "jms:queue:" + testName.getMethodName();
    final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    final StandaloneConsumer receiver = createStandaloneConsumer(activeMqBroker, testName.getMethodName(), rfc6167);
    try {
        MockMessageListener jms = new MockMessageListener();
        receiver.registerAdaptrisMessageListener(jms);
        // INTERLOK-3329 For coverage so the prepare() warning is executed 2x
        LifecycleHelper.prepare(sender);
        LifecycleHelper.prepare(receiver);
        start(receiver);
        start(sender);
        for (int i = 0; i < msgCount; i++) {
            sender.doService(createMessage());
        }
        waitForMessages(jms, msgCount);
        assertMessages(jms, msgCount);
    } finally {
        shutdownQuietly(sender, receiver);
    }
}
Also used : JmsProducer(com.adaptris.core.jms.JmsProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 2 with JmsProducer

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

the class ActiveMqJmsSyncConsumerTest method testQueue_ProduceConsume.

@Test
public void testQueue_ProduceConsume() throws Exception {
    int msgCount = 5;
    String rfc6167 = "jms:queue:" + testName.getMethodName();
    final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    final StandaloneConsumer receiver = createStandaloneConsumer(activeMqBroker, testName.getMethodName(), rfc6167);
    try {
        MockMessageListener jms = new MockMessageListener();
        receiver.registerAdaptrisMessageListener(jms);
        // INTERLOK-3329 For coverage so the prepare() warning is executed 2x
        LifecycleHelper.prepare(sender);
        LifecycleHelper.prepare(receiver);
        start(receiver);
        start(sender);
        for (int i = 0; i < msgCount; i++) {
            sender.doService(createMessage());
        }
        waitForMessages(jms, msgCount);
        assertMessages(jms, msgCount);
    } finally {
        shutdownQuietly(sender, receiver);
    }
}
Also used : JmsProducer(com.adaptris.core.jms.JmsProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 3 with JmsProducer

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

the class SharedComponentListTest method createAdapter.

private Adapter createAdapter() throws CoreException, PasswordException {
    Adapter adapter = new Adapter();
    adapter.setUniqueId("upbeat_liskov");
    JmsConnection jmsConnection = createPtpConnection("jms-connection");
    adapter.getSharedComponents().addConnection(jmsConnection);
    ServiceList serviceList = new ServiceList();
    serviceList.setUniqueId("shared-service-list");
    serviceList.add(new LogMessageService("log-message-service"));
    adapter.getSharedComponents().addService(serviceList);
    StandardWorkflow wf1 = new StandardWorkflow();
    wf1.setUniqueId("reverent-edison");
    wf1.setConsumer(new FsConsumer().withBaseDirectoryUrl("in-directory"));
    wf1.setProducer(new FsProducer().withBaseDirectoryUrl("out-directory"));
    wf1.getServiceCollection().add(new SharedService("shared-service-list"));
    StandardWorkflow wf = new StandardWorkflow();
    wf.setUniqueId("pedantic_brown");
    wf.setConsumer(new JmsConsumer().withEndpoint("jms:queue:SampleQueue1"));
    wf.setProducer(new NullMessageProducer());
    wf.getServiceCollection().add(new StandaloneProducer(new SharedConnection("jms-connection"), new JmsProducer().withEndpoint("jms:topic:MyTopicName")));
    Channel channel = new Channel();
    channel.setUniqueId("quirky_shannon");
    channel.setConsumeConnection(new SharedConnection("jms-connection"));
    channel.getWorkflowList().add(wf);
    channel.getWorkflowList().add(wf1);
    adapter.getChannelList().add(channel);
    return adapter;
}
Also used : JmsProducer(com.adaptris.core.jms.JmsProducer) LogMessageService(com.adaptris.core.services.LogMessageService) FsProducer(com.adaptris.core.fs.FsProducer) JmsConsumer(com.adaptris.core.jms.JmsConsumer) FsConsumer(com.adaptris.core.fs.FsConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection)

Example 4 with JmsProducer

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

the class ActiveMqJmsPollingConsumerTest method testTopic_ProduceConsume.

@Test
public void testTopic_ProduceConsume() throws Exception {
    int msgCount = 5;
    String rfc6167 = "jms:topic:" + testName.getMethodName() + "?subscriptionId=" + testName.getMethodName();
    final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    Sometime poller = new Sometime();
    JmsPollingConsumer consumer = createConsumer(activeMqBroker, testName.getMethodName(), rfc6167, poller);
    final StandaloneConsumer receiver = new StandaloneConsumer(consumer);
    try {
        MockMessageListener jms = new MockMessageListener();
        receiver.registerAdaptrisMessageListener(jms);
        startAndStop(receiver);
        start(receiver);
        start(sender);
        for (int i = 0; i < msgCount; i++) {
            sender.doService(createMessage());
        }
        waitForMessages(jms, msgCount);
        assertMessages(jms, msgCount);
    } finally {
        shutdownQuietly(sender, receiver);
    }
}
Also used : JmsProducer(com.adaptris.core.jms.JmsProducer) JmsPollingConsumer(com.adaptris.core.jms.JmsPollingConsumer) Sometime(com.adaptris.core.jms.activemq.ActiveMqPasPollingConsumerTest.Sometime) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 5 with JmsProducer

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

the class ActiveMqJmsSyncConsumerTest method testTopic_ProduceConsume.

@Test
public void testTopic_ProduceConsume() throws Exception {
    int msgCount = 5;
    String rfc6167 = "jms:topic:" + testName.getMethodName() + "?subscriptionId=" + testName.getMethodName();
    final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    Sometime poller = new Sometime();
    JmsSyncConsumer consumer = createConsumer(testName.getMethodName(), rfc6167, poller);
    final StandaloneConsumer receiver = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    try {
        MockMessageListener jms = new MockMessageListener();
        receiver.registerAdaptrisMessageListener(jms);
        startAndStop(receiver);
        start(receiver);
        start(sender);
        for (int i = 0; i < msgCount; i++) {
            sender.doService(createMessage());
        }
        waitForMessages(jms, msgCount);
        assertMessages(jms, msgCount);
    } finally {
        shutdownQuietly(sender, receiver);
    }
}
Also used : JmsSyncConsumer(com.adaptris.core.jms.JmsSyncConsumer) JmsProducer(com.adaptris.core.jms.JmsProducer) Sometime(com.adaptris.core.jms.activemq.ActiveMqPasPollingConsumerTest.Sometime) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

JmsProducer (com.adaptris.core.jms.JmsProducer)5 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)4 StandaloneProducer (com.adaptris.core.StandaloneProducer)4 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)4 Test (org.junit.Test)4 Sometime (com.adaptris.core.jms.activemq.ActiveMqPasPollingConsumerTest.Sometime)2 FsConsumer (com.adaptris.core.fs.FsConsumer)1 FsProducer (com.adaptris.core.fs.FsProducer)1 JmsConnection (com.adaptris.core.jms.JmsConnection)1 JmsConsumer (com.adaptris.core.jms.JmsConsumer)1 JmsPollingConsumer (com.adaptris.core.jms.JmsPollingConsumer)1 JmsSyncConsumer (com.adaptris.core.jms.JmsSyncConsumer)1 LogMessageService (com.adaptris.core.services.LogMessageService)1