Search in sources :

Example 21 with BasicActiveMqImplementation

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

the class JmsConnectionErrorHandlerTest method testActiveJmsAllowedInConjunctionWith_NullConnectString.

@Test
public void testActiveJmsAllowedInConjunctionWith_NullConnectString() throws Exception {
    ActiveJmsConnectionErrorHandler jms1 = new ActiveJmsConnectionErrorHandler();
    JmsConnection c = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616"));
    jms1.registerConnection(c);
    ActiveJmsConnectionErrorHandler jms2 = new ActiveJmsConnectionErrorHandler();
    jms2.registerConnection(c);
    assertFalse(jms1.allowedInConjunctionWith(jms2));
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) Test(org.junit.Test)

Example 22 with BasicActiveMqImplementation

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

the class FailoverJmsProducerCase method testBug1012.

@Test
public void testBug1012() throws Exception {
    FailoverJmsConnection connection = new FailoverJmsConnection();
    List<JmsConnection> ptp = new ArrayList<JmsConnection>();
    ptp.add(activeMqBroker.getJmsConnection());
    ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
    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());
    ptp.add(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
    connection.setConnections(ptp);
    LifecycleHelper.init(connection);
    // setting the consume connection no longer sets up the exception handler, so expect 0 here.
    assertEquals(0, connection.currentJmsConnection().retrieveExceptionListeners().size());
    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)

Example 23 with BasicActiveMqImplementation

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

the class FailoverJmsProducerCase method testNeverConnects.

@Test
public void testNeverConnects() throws Exception {
    FailoverJmsConnection connection = new FailoverJmsConnection();
    connection.addConnection(new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:123456")));
    connection.addConnection(new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:123456")));
    connection.setConnectionRetryInterval(new TimeInterval(250L, TimeUnit.MILLISECONDS));
    connection.setConnectionAttempts(1);
    connection.addExceptionListener(new StandaloneConsumer());
    connection.setRegisterOwner(true);
    try {
        LifecycleHelper.initAndStart(connection);
    } catch (CoreException expected) {
    } finally {
        LifecycleHelper.stopAndClose(connection);
    }
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) TimeInterval(com.adaptris.util.TimeInterval) CoreException(com.adaptris.core.CoreException) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) Test(org.junit.Test)

Example 24 with BasicActiveMqImplementation

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

the class AggregatingJmsConsumeServiceTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    AggregatingJmsConsumeService service = null;
    service = new AggregatingJmsConsumeService();
    JmsConnection jmsConnection = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616"));
    jmsConnection.setConnectionAttempts(2);
    jmsConnection.setConnectionRetryInterval(new TimeInterval(3L, "SECONDS"));
    service.setConnection(jmsConnection);
    AggregatingQueueConsumer consumer = new AggregatingQueueConsumer();
    consumer.setEndpoint("Sample.Q1");
    consumer.setFilterExpression("%message{filterSelectorKey}");
    consumer.setMessageAggregator(new ReplaceWithFirstMessage());
    consumer.setMessageTranslator(new TextMessageTranslator());
    service.setJmsConsumer(consumer);
    return service;
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) TimeInterval(com.adaptris.util.TimeInterval) ReplaceWithFirstMessage(com.adaptris.core.services.aggregator.ReplaceWithFirstMessage)

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