use of com.adaptris.core.stubs.FailFirstMockMessageProducer in project interlok by adaptris.
the class DefaultFailedMessageRetrierTest method testRoundTrip_AdapterRetry.
@Test
public void testRoundTrip_AdapterRetry() throws Exception {
AdaptrisMarshaller marshaller = DefaultMarshaller.getDefaultMarshaller();
Adapter adapter = (Adapter) marshaller.unmarshal(marshaller.marshal(createAdapterForRetry(create(), new StandardProcessingExceptionHandler(new StandaloneProducer(new MockMessageProducer())))));
DefaultFailedMessageRetrier retrier = (DefaultFailedMessageRetrier) adapter.getFailedMessageRetrier();
MockMessageProducer errProd = getErrorHandler(adapter);
try {
FailFirstMockMessageProducer workflowProducer = (FailFirstMockMessageProducer) adapter.getChannelList().get(0).getWorkflowList().get(0).getProducer();
MockMessageConsumer consumer = (MockMessageConsumer) adapter.getChannelList().get(0).getWorkflowList().get(0).getConsumer();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("ABCDEF");
start(adapter);
consumer.submitMessage(msg);
// SHould have failed
assertEquals(1, errProd.messageCount());
retrier.onAdaptrisMessage(errProd.getMessages().get(0));
assertTrue(msg.containsKey(CoreConstants.RETRY_COUNT_KEY));
assertEquals("1", msg.getMetadataValue(CoreConstants.RETRY_COUNT_KEY));
assertEquals(1, workflowProducer.getMessages().size());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.stubs.FailFirstMockMessageProducer in project interlok by adaptris.
the class DefaultFailedMessageRetrierTest method createAdapterForRetry.
private Adapter createAdapterForRetry(FailedMessageRetrier retrier, ProcessingExceptionHandler errorHandler) throws Exception {
Adapter adapter = AdapterTest.createAdapter(getName());
adapter.setFailedMessageRetrier(retrier);
adapter.setMessageErrorHandler(errorHandler);
adapter.getChannelList().clear();
Channel c = new Channel();
c.setUniqueId(getName());
StandardWorkflow wf = new StandardWorkflow();
wf.setUniqueId(getName());
wf.setConsumer(new MockMessageConsumer());
wf.setProducer(new FailFirstMockMessageProducer());
c.getWorkflowList().add(wf);
adapter.getChannelList().add(c);
return adapter;
}
use of com.adaptris.core.stubs.FailFirstMockMessageProducer in project interlok by adaptris.
the class StandardWorkflowTest method testOnMessage_ProducerFailsWithRetryHandlerFailureCallback.
@Test
public void testOnMessage_ProducerFailsWithRetryHandlerFailureCallback() throws Exception {
AtomicBoolean onSuccess = new AtomicBoolean(false);
MockChannel channel = createChannel(new FailFirstMockMessageProducer(5), Arrays.asList(new Service[] { new NullService() }));
channel.setMessageErrorHandler(new RetryMessageErrorHandler(4, new TimeInterval(100l, TimeUnit.MILLISECONDS), new NullService()));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1);
StandardWorkflow workflow = (StandardWorkflow) channel.getWorkflowList().get(0);
try {
start(channel);
workflow.onAdaptrisMessage(msg, (m) -> {
onSuccess.set(true);
}, (m) -> {
onSuccess.set(false);
});
assertFalse(onSuccess.get());
} finally {
stop(channel);
}
}
use of com.adaptris.core.stubs.FailFirstMockMessageProducer in project interlok by adaptris.
the class StandardWorkflowTest method testOnMessage_ProducerFailsFailureCallback.
@Test
public void testOnMessage_ProducerFailsFailureCallback() throws Exception {
AtomicBoolean onSuccess = new AtomicBoolean(false);
MockChannel channel = createChannel(new FailFirstMockMessageProducer(1), Arrays.asList(new Service[] { new NullService() }));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1);
StandardWorkflow workflow = (StandardWorkflow) channel.getWorkflowList().get(0);
try {
start(channel);
workflow.onAdaptrisMessage(msg, (m) -> {
onSuccess.set(true);
}, (m) -> {
onSuccess.set(false);
});
assertFalse(onSuccess.get());
} finally {
stop(channel);
}
}
use of com.adaptris.core.stubs.FailFirstMockMessageProducer in project interlok by adaptris.
the class ThreadContextWorkflowTest method testOnMessage_ProducerFailsWithRetryHandlerFailureCallback.
@Test
public void testOnMessage_ProducerFailsWithRetryHandlerFailureCallback() throws Exception {
AtomicBoolean onSuccess = new AtomicBoolean(false);
MockChannel channel = createChannel(new FailFirstMockMessageProducer(5), Arrays.asList(new Service[] { new NullService() }));
channel.setMessageErrorHandler(new RetryMessageErrorHandler(4, new TimeInterval(100l, TimeUnit.MILLISECONDS), new NullService()));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1);
ThreadContextWorkflow workflow = (ThreadContextWorkflow) channel.getWorkflowList().get(0);
try {
start(channel);
workflow.onAdaptrisMessage(msg, (m) -> {
onSuccess.set(true);
}, (m) -> {
onSuccess.set(false);
});
assertFalse(onSuccess.get());
} finally {
stop(channel);
}
}
Aggregations