@Override public ErrorHandlerBuilder create(CreationalContext<ErrorHandlerBuilder> creationalContext) { try { ErrorHandlerBuilder builder = handler.getType().getTypeAsClass().newInstance(); switch (handler.getType()) { case DefaultErrorHandler: case DeadLetterChannel: setProperties((DefaultErrorHandlerBuilder) builder); break; case LoggingErrorHandler: setProperties((LoggingErrorHandlerBuilder) builder); break; case NoErrorHandler: // No configuration required break; case TransactionErrorHandler: break; } return builder; } catch (Exception cause) { throw new CreationException("Error while creating instance for " + this, cause); } }
@Override public ErrorHandlerBuilder create(CreationalContext<ErrorHandlerBuilder> creationalContext) { try { ErrorHandlerBuilder builder = handler.getType().getTypeAsClass().newInstance(); switch (handler.getType()) { case DefaultErrorHandler: case DeadLetterChannel: setProperties((DefaultErrorHandlerBuilder) builder); break; case LoggingErrorHandler: setProperties((LoggingErrorHandlerBuilder) builder); break; case NoErrorHandler: // No configuration required break; case TransactionErrorHandler: break; default: break; } return builder; } catch (Exception cause) { throw new CreationException("Error while creating instance for " + this, cause); } }
public void testDefaultErrorHandler() { DefaultErrorHandlerBuilder errorHandler = ctx.getBean("defaultErrorHandler", DefaultErrorHandlerBuilder.class); assertNotNull(errorHandler); RedeliveryPolicy policy = errorHandler.getRedeliveryPolicy(); assertNotNull(policy); assertEquals("Wrong maximumRedeliveries", 2, policy.getMaximumRedeliveries()); assertEquals("Wrong redeliveryDelay", 0, policy.getRedeliveryDelay()); assertEquals("Wrong logStackTrace", false, policy.isLogStackTrace()); errorHandler = ctx.getBean("errorHandler", DefaultErrorHandlerBuilder.class); assertNotNull(errorHandler); }
@Produces @Named("foobarErrorHandler") public ErrorHandlerBuilder getErrorHandler() { LOG.info("Creating custom ErrorHandler - " + this); return new DefaultErrorHandlerBuilder().disableRedelivery(); }