use of com.adaptris.core.Channel in project interlok by adaptris.
the class BasicActiveMqConsumerTest method createDurableSubsAdapter.
private Adapter createDurableSubsAdapter(String adapterName, EmbeddedActiveMq activeMqBroker) throws Exception {
Adapter adapter = new Adapter();
adapter.setUniqueId(adapterName);
Channel c = new Channel();
JmsConnection conn = activeMqBroker.getJmsConnection(createVendorImpl());
conn.setClientId(MY_CLIENT_ID);
c.setConsumeConnection(conn);
StandardWorkflow swf = new StandardWorkflow();
PasConsumer pasConsumer = new PasConsumer().withTopic(new GuidGenerator().safeUUID());
pasConsumer.setSubscriptionId(MY_SUBSCRIPTION_ID);
swf.setConsumer(pasConsumer);
c.getWorkflowList().add(swf);
ChannelList cl = new ChannelList();
cl.addChannel(c);
adapter.setChannelList(cl);
return adapter;
}
use of com.adaptris.core.Channel in project interlok by adaptris.
the class BasicActiveMqConsumerTest method testStartWithDurableSubscribers_WithNonBlockingChannelStrategy.
@Test
public void testStartWithDurableSubscribers_WithNonBlockingChannelStrategy() throws Exception {
Adapter adapter = createDurableSubsAdapter(getName(), activeMqBroker);
adapter.requestStart();
assertEquals(StartedState.getInstance(), adapter.retrieveComponentState());
adapter.requestClose();
assertEquals(ClosedState.getInstance(), adapter.retrieveComponentState());
adapter.getChannelList().setLifecycleStrategy(new NonBlockingChannelStartStrategy());
adapter.requestStart();
// Thread.sleep(1000);
Channel c = adapter.getChannelList().getChannel(0);
int maxAttempts = 100;
int attempts = 0;
while (attempts < maxAttempts && c.retrieveComponentState() != StartedState.getInstance()) {
Thread.sleep(500);
attempts++;
}
assertEquals(StartedState.getInstance(), c.retrieveComponentState());
adapter.requestClose();
}
use of com.adaptris.core.Channel in project interlok by adaptris.
the class BasicActiveMqConsumerTest method testQueue_ProduceWhenConsumerStopped.
@Test
public void testQueue_ProduceWhenConsumerStopped() throws Exception {
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandardWorkflow workflow = new StandardWorkflow();
MockMessageProducer producer = new MockMessageProducer();
workflow.setConsumer(consumer);
workflow.setProducer(producer);
Channel channel = createChannel(activeMqBroker.getJmsConnection(createVendorImpl()), workflow);
try {
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PtpProducer().withQueue((getName())));
channel.requestStart();
workflow.requestStop();
start(standaloneProducer);
AdaptrisMessage msg = createMessage(null);
standaloneProducer.produce(msg);
Thread.sleep(250);
assertEquals(0, producer.messageCount());
stop(standaloneProducer);
} finally {
channel.requestClose();
}
}
use of com.adaptris.core.Channel in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testMessagesRolledBackUsingQueue.
@Test
public void testMessagesRolledBackUsingQueue() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
Channel channel = createStartableChannel(activeMqBroker, true, "testMessagesRolledBackUsingQueue", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
workflow.getServiceCollection().addService(new ThrowExceptionService(new ConfiguredException("Fail")));
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
send(sender, msgCount);
} finally {
channel.requestClose();
}
assertEquals(msgCount, activeMqBroker.messagesOnQueue(destination));
}
use of com.adaptris.core.Channel in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testMessagesCommittedUsingQueue.
@Test
public void testMessagesCommittedUsingQueue() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
Channel channel = createStartableChannel(activeMqBroker, true, "testMessagesCommittedUsingQueue", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue(destination));
send(sender, msgCount);
waitForMessages((MockMessageProducer) workflow.getProducer(), msgCount);
assertEquals(msgCount, ((MockMessageProducer) workflow.getProducer()).getMessages().size());
} finally {
channel.requestClose();
}
assertEquals(0, activeMqBroker.messagesOnQueue(destination));
}
Aggregations