/** * Constructs a dispatching interceptor * * @param camelContext Camel context */ public ConsumerDispatchingInterceptor(CamelContext camelContext) { super(); try { camelContext.addStartupListener(this); } catch (Exception e) { throw new RuntimeCamelException(e); } }
/** * Dynamically find all {@link MllpTransactionEndpoint} containing a reference to this instance * and append it to the routeId list * * @param camelContext camel context */ private void collectTransactionTargets(CamelContext camelContext) { for (Route route : camelContext.getRoutes()) { if (route.getEndpoint() instanceof MllpTransactionEndpoint) { MllpTransactionEndpoint<?> endpoint = (MllpTransactionEndpoint<?>) route.getEndpoint(); if (endpoint.getDispatcher() == this) { addTransactionRoutes(route.getId()); } } } }
private boolean addTargets(CamelContext camelContext) throws CamelException { for (String routeId : routeIds) { try { Mina2Consumer consumer = (Mina2Consumer) camelContext.getRoute(routeId).getConsumer(); Hl7v2Interceptor interceptor = (Hl7v2Interceptor) consumer.getProcessor(); while (!(interceptor instanceof ConsumerStringProcessingInterceptor)) { interceptor = (Hl7v2Interceptor) interceptor.getWrappedProcessor(); } LOG.debug("Adding MLLP transaction route {} to dispatcher", routeId); map.put(routeId, (Hl7v2Interceptor) interceptor.getWrappedProcessor()); } catch (NullPointerException e) { throw new CamelException( "Route with ID='" + routeId + "' not found or is not an IPF MLLP route", e); } catch (ClassCastException e) { throw new CamelException("Route with ID='" + routeId + "' is not an IPF MLLP route", e); } } return !map.isEmpty(); }