Search in sources :

Example 41 with PtpProducer

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

the class BasicActiveMqProducerTest method testQueueProduceAndConsumeWithSecurity_EncryptedPassword.

@Test
public void testQueueProduceAndConsumeWithSecurity_EncryptedPassword() throws Exception {
    RequiresCredentialsBroker broker = new RequiresCredentialsBroker();
    try {
        broker.start();
        PtpConsumer consumer = new PtpConsumer().withQueue(RequiresCredentialsBroker.DEFAULT_PREFIX + "queue");
        consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
        JmsConnection conn = broker.getJmsConnection(createVendorImpl(), true);
        conn.setUserName(RequiresCredentialsBroker.DEFAULT_USERNAME);
        conn.setPassword(Password.encode(RequiresCredentialsBroker.DEFAULT_PASSWORD, Password.PORTABLE_PASSWORD));
        StandaloneConsumer standaloneConsumer = new StandaloneConsumer(conn, consumer);
        MockMessageListener jms = new MockMessageListener();
        standaloneConsumer.registerAdaptrisMessageListener(jms);
        conn = broker.getJmsConnection(createVendorImpl());
        conn.setUserName(RequiresCredentialsBroker.DEFAULT_USERNAME);
        conn.setPassword(RequiresCredentialsBroker.DEFAULT_PASSWORD);
        StandaloneProducer standaloneProducer = new StandaloneProducer(conn, new PtpProducer().withQueue((RequiresCredentialsBroker.DEFAULT_PREFIX + "queue")));
        execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
        assertMessages(jms, 1);
    } finally {
        broker.destroy();
    }
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection) 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 42 with PtpProducer

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

the class BasicActiveMqProducerTest method testQueueRequestReplyWithMessageWrongType.

@Test
public void testQueueRequestReplyWithMessageWrongType() throws Exception {
    QueueLoopback echo = new QueueLoopback(activeMqBroker, getName(), false);
    try {
        echo.start();
        PtpProducer producer = new PtpProducer().withQueue((getName()));
        producer.setMessageTranslator(new BytesMessageTranslator());
        StandaloneRequestor standaloneProducer = new StandaloneRequestor(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
        AdaptrisMessage msg = createMessage();
        ExampleServiceCase.execute(standaloneProducer, msg);
        echo.waitFor(DEFAULT_TIMEOUT);
        assertNotNull(echo.getLastMessage());
        assertNotNull(echo.getLastMessage().getJMSReplyTo());
        assertEquals(DEFAULT_PAYLOAD.toUpperCase(), msg.getContent());
    } finally {
        echo.stop();
    }
}
Also used : StandaloneRequestor(com.adaptris.core.StandaloneRequestor) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) PtpProducer(com.adaptris.core.jms.PtpProducer) BytesMessageTranslator(com.adaptris.core.jms.BytesMessageTranslator) Test(org.junit.Test)

Example 43 with PtpProducer

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

the class BasicActiveMqProducerTest method testQueueProduceAndConsumeWithSecurity.

@Test
public void testQueueProduceAndConsumeWithSecurity() throws Exception {
    RequiresCredentialsBroker broker = new RequiresCredentialsBroker();
    try {
        broker.start();
        PtpConsumer consumer = new PtpConsumer().withQueue(RequiresCredentialsBroker.DEFAULT_PREFIX + "queue");
        consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
        JmsConnection conn = broker.getJmsConnection(createVendorImpl(), true);
        conn.setUserName(RequiresCredentialsBroker.DEFAULT_USERNAME);
        conn.setPassword(RequiresCredentialsBroker.DEFAULT_PASSWORD);
        StandaloneConsumer standaloneConsumer = new StandaloneConsumer(conn, consumer);
        MockMessageListener jms = new MockMessageListener();
        standaloneConsumer.registerAdaptrisMessageListener(jms);
        conn = broker.getJmsConnection(createVendorImpl());
        conn.setUserName(RequiresCredentialsBroker.DEFAULT_USERNAME);
        conn.setPassword(RequiresCredentialsBroker.DEFAULT_PASSWORD);
        StandaloneProducer standaloneProducer = new StandaloneProducer(conn, new PtpProducer().withQueue((RequiresCredentialsBroker.DEFAULT_PREFIX + "queue")));
        execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
        assertMessages(jms, 1);
    } finally {
        broker.destroy();
    }
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection) 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 44 with PtpProducer

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

the class DestinationCacheJndiPtpProducerTest method testProduceWithCacheExceeded.

@Test
public void testProduceWithCacheExceeded() throws Exception {
    DestinationCachingJndiVendorImpl jv = new DestinationCachingJndiVendorImpl(2);
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    StandaloneProducer sp1 = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(jv, false, queueName, topicName), new PtpProducer().withQueue("%message{testProduceWithCacheExceeded}"));
    jv.setUseJndiForQueues(true);
    jv.getJndiParams().addKeyValuePair(new KeyValuePair("queue.testProduceWithCacheExceeded1", "testProduceWithCacheExceeded1"));
    jv.getJndiParams().addKeyValuePair(new KeyValuePair("queue.testProduceWithCacheExceeded2", "testProduceWithCacheExceeded2"));
    try {
        start(sp1);
        AdaptrisMessage m1 = createMessage(null);
        m1.addMetadata("testProduceWithCacheExceeded", queueName);
        AdaptrisMessage m2 = createMessage(null);
        m2.addMetadata("testProduceWithCacheExceeded", "testProduceWithCacheExceeded2");
        AdaptrisMessage m3 = createMessage(null);
        m3.addMetadata("testProduceWithCacheExceeded", "testProduceWithCacheExceeded1");
        sp1.doService(m1);
        sp1.doService(m2);
        // This 2nd produce will expire get(QUEUE) on a LRU
        sp1.doService(m2);
        // basis.
        sp1.doService(m3);
        assertEquals(2, jv.queueCacheSize());
        assertFalse(jv.queueCache().containsKey(queueName));
        assertTrue(jv.queueCache().containsKey("testProduceWithCacheExceeded1"));
        assertTrue(jv.queueCache().containsKey("testProduceWithCacheExceeded2"));
    } finally {
        stop(sp1);
    }
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 45 with PtpProducer

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

the class BasicActiveMqConsumerTest method testQueueProduceAndConsume.

@Test
public void testQueueProduceAndConsume() throws Exception {
    PtpConsumer consumer = new PtpConsumer().withQueue(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PtpProducer().withQueue((getName())));
    // INTERLOK-3329 For coverage so the prepare() warning is executed 2x
    LifecycleHelper.prepare(standaloneConsumer);
    LifecycleHelper.prepare(standaloneProducer);
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms, 1);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) 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)

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