Search in sources :

Example 6 with BasicActiveMqImplementation

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

the class FailoverJmsProducerCase method testConnectionEquals.

@Test
public void testConnectionEquals() throws Exception {
    FailoverJmsConnection connection = new FailoverJmsConnection();
    connection.addConnection(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
    connection.addConnection(activeMqBroker.getJmsConnection());
    assertEquals(false, connection.connectionEquals(new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:123456"))));
    try {
        LifecycleHelper.initAndStart(connection);
        assertNotNull(connection.currentJmsConnection());
        assertEquals(true, connection.connectionEquals(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true)));
    } finally {
        LifecycleHelper.stopAndClose(connection);
    }
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) Test(org.junit.Test)

Example 7 with BasicActiveMqImplementation

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

the class FailoverJmsProducerCase method testEventuallyConnects.

@Test
public void testEventuallyConnects() throws Exception {
    FailoverJmsConnection connection = new FailoverJmsConnection();
    connection.addConnection(new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:123456")));
    connection.addConnection(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
    connection.setConnectionRetryInterval(new TimeInterval(250L, TimeUnit.MILLISECONDS));
    connection.addExceptionListener(new StandaloneConsumer());
    connection.setRegisterOwner(true);
    ScheduledExecutorService es = Executors.newSingleThreadScheduledExecutor();
    try {
        es.schedule(new Runnable() {

            @Override
            public void run() {
                try {
                    activeMqBroker.start();
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
        }, 2L, TimeUnit.SECONDS);
        LifecycleHelper.initAndStart(connection);
    } finally {
        LifecycleHelper.stopAndClose(connection);
        es.shutdownNow();
    }
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) TimeInterval(com.adaptris.util.TimeInterval) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 8 with BasicActiveMqImplementation

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

the class FailoverPtpProducerTest method createFailoverConfigExample.

static FailoverJmsConnection createFailoverConfigExample(boolean isPtp) {
    FailoverJmsConnection result = null;
    result = new FailoverJmsConnection(new ArrayList<JmsConnection>(Arrays.asList(new JmsConnection[] { new JmsConnection(new BasicActiveMqImplementation("tcp://SomeUnclusteredBroker:9999")), new JmsConnection(new BasicActiveMqImplementation("tcp://SomeUnclusteredBroker:9998")) })));
    result.setConnectionErrorHandler(new JmsConnectionErrorHandler());
    return result;
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) ArrayList(java.util.ArrayList)

Example 9 with BasicActiveMqImplementation

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

the class BasicPtpConsumerActiveErorHandlerTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    JmsConnection p = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616"));
    ActiveJmsConnectionErrorHandler erHandler = new ActiveJmsConnectionErrorHandler();
    erHandler.setCheckInterval(new TimeInterval(30L, TimeUnit.SECONDS));
    p.setConnectionErrorHandler(erHandler);
    return new StandaloneConsumer(p, new PtpConsumer().withQueue("TheQueueToConsumeFrom"));
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) TimeInterval(com.adaptris.util.TimeInterval) StandaloneConsumer(com.adaptris.core.StandaloneConsumer)

Example 10 with BasicActiveMqImplementation

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

the class PtpConsumerTest method retrieveSampleConfig.

protected StandaloneConsumer retrieveSampleConfig() {
    JmsConnection c = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616"));
    PtpConsumer pc = new PtpConsumer();
    pc.setQueue("destination");
    MetadataCorrelationIdSource mcs = new MetadataCorrelationIdSource();
    mcs.setMetadataKey("MetadataKey");
    pc.setCorrelationIdSource(mcs);
    c.setConnectionErrorHandler(new JmsConnectionErrorHandler());
    StandaloneConsumer result = new StandaloneConsumer();
    result.setConnection(c);
    result.setConsumer(pc);
    return result;
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) StandaloneConsumer(com.adaptris.core.StandaloneConsumer)

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