@Override public void configure() throws Exception { Map<StubConfiguration, Collection<Contract>> contracts = batchStubRunner .getContracts(); for (Map.Entry<StubConfiguration, Collection<Contract>> entry : contracts .entrySet()) { Collection<Contract> value = entry.getValue(); MultiValueMap<String, Contract> map = new LinkedMultiValueMap<>(); for (Contract dsl : value) { if (dsl == null) { continue; } if (dsl.getInput() != null && dsl.getInput() .getMessageFrom() != null && StringUtils.hasText( dsl.getInput().getMessageFrom().getClientValue())) { String from = dsl.getInput().getMessageFrom() .getClientValue(); map.add(from, dsl); } } for (Map.Entry<String, List<Contract>> entries : map.entrySet()) { from(entries.getKey()) .filter(new StubRunnerCamelPredicate(entries.getValue())) .process(new StubRunnerCamelProcessor()) .dynamicRouter(header(StubRunnerCamelConfiguration.STUBRUNNER_DESTINATION_URL_HEADER_NAME)); } } } };
@Override public void configure() { // load file orders from src/data into the JMS queue from("file:src/data?noop=true").to("jms:incomingOrders"); // content-based router from("jms:incomingOrders") .choice() .when(header("CamelFileName").endsWith(".xml")) .to("jms:xmlOrders") .when(header("CamelFileName").regex("^.*(csv|csl)$")) .to("jms:csvOrders") .otherwise() .to("jms:badOrders"); // lets filter out the test messages from("jms:xmlOrders").filter(xpath("/order[not(@test)]")) .process(new Processor() { public void process(Exchange exchange) throws Exception { System.out.println("Received XML order: " + exchange.getIn().getHeader("CamelFileName")); } }); } });