@Override @Test public void testServiceException() throws Exception { MockMessageProducer producer = new MockMessageProducer(); MockMessageProducer meh = new MockMessageProducer(); MockChannel channel = createChannel(producer, Arrays.asList(new Service[] { new AddMetadataService(Arrays.asList(new MetadataElement[] { new MetadataElement(METADATA_KEY, METADATA_VALUE) })), new PayloadFromMetadataService(PAYLOAD_2), new ThrowExceptionService(new ConfiguredException("Fail")) })); try { LargeMessageWorkflow workflow = (LargeMessageWorkflow) channel.getWorkflowList().get(0); channel.setMessageErrorHandler(new StandardProcessingExceptionHandler( new ServiceList(new ArrayList<Service>(Arrays.asList(new Service[] { new StandaloneProducer(meh) }))))); channel.prepare(); AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1); start(channel); workflow.onAdaptrisMessage(msg); assertEquals("Make none produced", 0, producer.getMessages().size()); assertEquals(1, meh.getMessages().size()); for (AdaptrisMessage m : meh.getMessages()) { assertEquals(PAYLOAD_2, m.getContent()); assertTrue("Contains correct metadata key", m.containsKey(METADATA_KEY)); assertEquals(METADATA_VALUE, m.getMetadataValue(METADATA_KEY)); assertNotNull(m.getObjectHeaders().get(CoreConstants.OBJ_METADATA_EXCEPTION)); assertNotNull(m.getObjectHeaders().get(CoreConstants.OBJ_METADATA_EXCEPTION_CAUSE)); assertEquals(ThrowExceptionService.class.getSimpleName(), m.getObjectHeaders().get(CoreConstants.OBJ_METADATA_EXCEPTION_CAUSE)); } } finally { stop(channel); } }
@Override public synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure) { ListenerCallbackHelper.prepare(msg, success, failure); if (!obtainChannel().isAvailable()) { handleChannelUnavailable(msg); } else { handleMessage(msg, false); } }
LargeMessageWorkflow extends StandardWorkflow { @Override public synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure) { ListenerCallbackHelper.prepare(msg, success, failure); if (!obtainChannel().isAvailable()) { handleChannelUnavailable(msg); } else { handleMessage(msg, false); } } }
LargeMessageWorkflow extends StandardWorkflow { @Override public synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure) { ListenerCallbackHelper.prepare(msg, success, failure); if (!obtainChannel().isAvailable()) { handleChannelUnavailable(msg); } else { handleMessage(msg, false); } } LargeMessageWorkflow(); }
LargeMessageWorkflow extends StandardWorkflow { @Override public synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure) { ListenerCallbackHelper.prepare(msg, success, failure); if (!obtainChannel().isAvailable()) { handleChannelUnavailable(msg); } else { handleMessage(msg, false); } } LargeMessageWorkflow(); @Override synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure); }
LargeMessageWorkflow extends StandardWorkflow { @Override public synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure) { ListenerCallbackHelper.prepare(msg, success, failure); if (!obtainChannel().isAvailable()) { handleChannelUnavailable(msg); } else { handleMessage(msg, false); } } LargeMessageWorkflow(); @Override synchronized void onAdaptrisMessage(AdaptrisMessage msg, Consumer<AdaptrisMessage> success, Consumer<AdaptrisMessage> failure);  }