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));
}
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;
}
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;
}
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);
}
}
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);
}
}
Aggregations