/** * Get the {@link SequenceBarrier} used by a specific handler. Note that the {@link SequenceBarrier} * may be shared by multiple event handlers. * * @param handler the handler to get the barrier for. * @return the SequenceBarrier used by <i>handler</i>. */ public SequenceBarrier getBarrierFor(final EventHandler<T> handler) { return consumerRepository.getBarrierFor(handler); }
/** * Specify the {@link ExceptionHandler} to use with the event handler. * * @param exceptionHandler the exception handler to use. */ @SuppressWarnings("unchecked") public void with(ExceptionHandler<? super T> exceptionHandler) { final EventProcessor eventProcessor = consumerRepository.getEventProcessorFor(eventHandler); if (eventProcessor instanceof BatchEventProcessor) { ((BatchEventProcessor<T>) eventProcessor).setExceptionHandler(exceptionHandler); consumerRepository.getBarrierFor(eventHandler).alert(); } else { throw new RuntimeException( "EventProcessor: " + eventProcessor + " is not a BatchEventProcessor " + "and does not support exception handlers"); } } }
@Test public void shouldReturnNullForBarrierWhenHandlerIsNotRegistered() throws Exception { assertThat(consumerRepository.getBarrierFor(handler1), is(nullValue())); }
@Test public void shouldGetBarrierByHandler() throws Exception { consumerRepository.add(eventProcessor1, handler1, barrier1); assertThat(consumerRepository.getBarrierFor(handler1), sameInstance(barrier1)); }
/** * Get the {@link SequenceBarrier} used by a specific handler. Note that the {@link SequenceBarrier} * may be shared by multiple event handlers. * * @param handler the handler to get the barrier for. * @return the SequenceBarrier used by <i>handler</i>. */ public SequenceBarrier getBarrierFor(final EventHandler<T> handler) { return consumerRepository.getBarrierFor(handler); }
/** * Specify the {@link ExceptionHandler} to use with the event handler. * * @param exceptionHandler the exception handler to use. */ @SuppressWarnings("unchecked") public void with(ExceptionHandler<? super T> exceptionHandler) { final EventProcessor eventProcessor = consumerRepository.getEventProcessorFor(eventHandler); if (eventProcessor instanceof BatchEventProcessor) { ((BatchEventProcessor<T>) eventProcessor).setExceptionHandler(exceptionHandler); consumerRepository.getBarrierFor(eventHandler).alert(); } else { throw new RuntimeException( "EventProcessor: " + eventProcessor + " is not a BatchEventProcessor " + "and does not support exception handlers"); } } }
/** * Get the {@link SequenceBarrier} used by a specific handler. Note that the {@link SequenceBarrier} * may be shared by multiple event handlers. * * @param handler the handler to get the barrier for. * @return the SequenceBarrier used by <i>handler</i>. */ public SequenceBarrier getBarrierFor(final EventHandler<T> handler) { return consumerRepository.getBarrierFor(handler); }
/** * Get the {@link SequenceBarrier} used by a specific handler. Note that the {@link SequenceBarrier} * may be shared by multiple event handlers. * * @param handler the handler to get the barrier for. * @return the SequenceBarrier used by <i>handler</i>. */ public SequenceBarrier getBarrierFor(final EventHandler<T> handler) { return consumerRepository.getBarrierFor(handler); }
/** * Get the {@link SequenceBarrier} used by a specific handler. Note that the {@link SequenceBarrier} * may be shared by multiple event handlers. * * @param handler the handler to get the barrier for. * @return the SequenceBarrier used by <i>handler</i>. */ public SequenceBarrier getBarrierFor(final EventHandler<T> handler) { return consumerRepository.getBarrierFor(handler); }
/** * Specify the {@link ExceptionHandler} to use with the event handler. * * @param exceptionHandler the exception handler to use. */ public void with(ExceptionHandler<? super T> exceptionHandler) { ((BatchEventProcessor<T>) consumerRepository.getEventProcessorFor(eventHandler)) .setExceptionHandler(exceptionHandler); consumerRepository.getBarrierFor(eventHandler).alert(); } }
/** * Specify the {@link ExceptionHandler} to use with the event handler. * * @param exceptionHandler the exception handler to use. */ public void with(ExceptionHandler exceptionHandler) { ((BatchEventProcessor<?>) consumerRepository.getEventProcessorFor(eventHandler)).setExceptionHandler(exceptionHandler); consumerRepository.getBarrierFor(eventHandler).alert(); } }
/** * Specify the {@link ExceptionHandler} to use with the event handler. * * @param exceptionHandler the exception handler to use. */ @SuppressWarnings("unchecked") public void with(ExceptionHandler<? super T> exceptionHandler) { final EventProcessor eventProcessor = consumerRepository.getEventProcessorFor(eventHandler); if (eventProcessor instanceof BatchEventProcessor) { ((BatchEventProcessor<T>) eventProcessor).setExceptionHandler(exceptionHandler); consumerRepository.getBarrierFor(eventHandler).alert(); } else { throw new RuntimeException( "EventProcessor: " + eventProcessor + " is not a BatchEventProcessor " + "and does not support exception handlers"); } } }