Search in sources :

Example 1 with BasicActiveMqImplementation

use of com.adaptris.core.jms.activemq.BasicActiveMqImplementation in project interlok by adaptris.

the class JmsConnectionErrorHandlerTest method testComparatorWith2IdenticalConnections.

@Test
public void testComparatorWith2IdenticalConnections() throws Exception {
    JmsConnectionErrorHandler connectionErrorHandler1 = new JmsConnectionErrorHandler();
    JmsConnectionErrorHandler connectionErrorHandler2 = new JmsConnectionErrorHandler();
    JmsConnection connection1 = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616"));
    JmsConnection connection2 = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616"));
    connectionErrorHandler1.registerConnection(connection1);
    connectionErrorHandler2.registerConnection(connection2);
    assertFalse(connectionErrorHandler1.allowedInConjunctionWith(connectionErrorHandler2));
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) Test(org.junit.Test)

Example 2 with BasicActiveMqImplementation

use of com.adaptris.core.jms.activemq.BasicActiveMqImplementation in project interlok by adaptris.

the class JmsConsumerTest method retrieveSampleConfig.

protected StandaloneConsumer retrieveSampleConfig(boolean destQueue) {
    JmsConnection c = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616"));
    String dest = "jms:topic:MyTopicName?subscriptionId=mySubscriptionId";
    if (destQueue) {
        dest = "jms:queue:MyQueueName";
    }
    JmsConsumer pc = new JmsConsumer().withEndpoint(dest);
    c.setConnectionErrorHandler(new JmsConnectionErrorHandler());
    StandaloneConsumer result = new StandaloneConsumer(c, pc);
    return result;
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) StandaloneConsumer(com.adaptris.core.StandaloneConsumer)

Example 3 with BasicActiveMqImplementation

use of com.adaptris.core.jms.activemq.BasicActiveMqImplementation in project interlok by adaptris.

the class AggregatingJmsConsumeServiceTest method createService.

private AggregatingJmsConsumeService createService(EmbeddedActiveMq broker, AggregatingQueueConsumer consumer, String queue) {
    AggregatingJmsConsumeService result = new AggregatingJmsConsumeService();
    result.setConnection(broker.getJmsConnection(new BasicActiveMqImplementation(), true));
    consumer.setFilterExpression("%message{" + DEFAULT_FILTER_KEY + "}");
    consumer.setEndpoint(queue);
    consumer.setTimeout(new TimeInterval(5L, TimeUnit.SECONDS));
    result.setJmsConsumer(consumer);
    return result;
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) TimeInterval(com.adaptris.util.TimeInterval)

Example 4 with BasicActiveMqImplementation

use of com.adaptris.core.jms.activemq.BasicActiveMqImplementation 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 5 with BasicActiveMqImplementation

use of com.adaptris.core.jms.activemq.BasicActiveMqImplementation in project interlok by adaptris.

the class FailoverJmsConsumerCase method testBug1012.

@Test
public void testBug1012() throws Exception {
    FailoverJmsConnection connection = new FailoverJmsConnection();
    try {
        List<JmsConnection> ptp = new ArrayList<JmsConnection>();
        ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
        ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), false));
        connection.setConnections(ptp);
        LifecycleHelper.init(connection);
        assertEquals(1, connection.currentJmsConnection().retrieveExceptionListeners().size());
        AdaptrisComponent owner = (AdaptrisComponent) connection.currentJmsConnection().retrieveExceptionListeners().toArray()[0];
        assertTrue("Owner should be failover connection", connection == owner);
        LifecycleHelper.close(connection);
        Channel channel = new MockChannel();
        connection = new FailoverJmsConnection();
        connection.setRegisterOwner(true);
        channel.setConsumeConnection(connection);
        ptp = new ArrayList<JmsConnection>();
        ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
        ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), false));
        connection.setConnections(ptp);
        connection.setConnectionAttempts(1);
        LifecycleHelper.init(connection);
        assertEquals(0, connection.currentJmsConnection().retrieveExceptionListeners().size());
        LifecycleHelper.close(connection);
    } finally {
        LifecycleHelper.close(connection);
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) ArrayList(java.util.ArrayList) AdaptrisComponent(com.adaptris.core.AdaptrisComponent) Test(org.junit.Test)

Aggregations

BasicActiveMqImplementation (com.adaptris.core.jms.activemq.BasicActiveMqImplementation)24 Test (org.junit.Test)9 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)7 TimeInterval (com.adaptris.util.TimeInterval)7 StandaloneProducer (com.adaptris.core.StandaloneProducer)5 ArrayList (java.util.ArrayList)4 MockChannel (com.adaptris.core.stubs.MockChannel)3 AdaptrisComponent (com.adaptris.core.AdaptrisComponent)2 Channel (com.adaptris.core.Channel)2 CoreException (com.adaptris.core.CoreException)2 JmsConnection (com.adaptris.core.jms.JmsConnection)2 PtpProducer (com.adaptris.core.jms.PtpProducer)2 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)1 PtpConsumer (com.adaptris.core.jms.PtpConsumer)1 Base64DecodeService (com.adaptris.core.services.Base64DecodeService)1 Base64EncodeService (com.adaptris.core.services.Base64EncodeService)1 ReplaceWithFirstMessage (com.adaptris.core.services.aggregator.ReplaceWithFirstMessage)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1