org.apache.camel.builder.SimpleBuilder Java Examples
The following examples show how to use
org.apache.camel.builder.SimpleBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MyProcessor.java From camelinaction2 with Apache License 2.0 | 5 votes |
public void process(Exchange exchange) throws Exception { SimpleBuilder simple = new SimpleBuilder( "${body} contains 'Camel'"); if (!simple.matches(exchange)) { throw new Exception("This is NOT a Camel message"); } }
Example #2
Source File: Route.java From container with Apache License 2.0 | 5 votes |
@Override public void configure() throws Exception { final Predicate OK = header(Exchange.HTTP_RESPONSE_CODE).isEqualTo(200); final Predicate PENDING = PredicateBuilder.and(OK, body().isEqualTo(PENDING_STRING)); final Predicate RESULT_RECEIVED = PredicateBuilder.and(OK, PredicateBuilder.not(PENDING)); final SimpleBuilder INVOKE_ENDPOINT = simple("${header." + ApplicationBusConstants.INVOCATION_ENDPOINT_URL.toString() + "}" + APPINVOKER_ENDPOINT_SUFFIX); final SimpleBuilder POLL_ENDPOINT = simple("${header.Location}"); final RequestProcessor requestProcessor = new RequestProcessor(); final ResponseProcessor responseProcessor = new ResponseProcessor(); from(ApplicationBusJsonHttpPluginServiceImpl.ENDPOINT).process(requestProcessor) .setHeader(Exchange.HTTP_METHOD, constant("POST")) .setHeader(Exchange.CONTENT_TYPE, constant("application/json")) .setHeader(Exchange.HTTP_URI, INVOKE_ENDPOINT) .to(DUMMY_ENDPOINT).choice() .when(header(Exchange.HTTP_RESPONSE_CODE).isEqualTo(202)) .setHeader(Exchange.HTTP_URI, POLL_ENDPOINT) .to("direct:polling").endChoice().otherwise() .to("direct:throwException"); from("direct:polling").setHeader(Exchange.HTTP_METHOD, constant("GET")).to(DUMMY_ENDPOINT) .convertBodyTo(String.class).choice().when(PENDING).delay(5000).to("direct:polling") .endChoice().when(RESULT_RECEIVED).process(responseProcessor).endChoice().otherwise() .to("direct:throwException"); from("direct:throwException").process(exchange -> exchange.getIn().setBody(new ApplicationBusExternalException( exchange.getIn().getBody(String.class)))); }
Example #3
Source File: MockReplyRouteTest.java From camel-cookbook-examples with Apache License 2.0 | 5 votes |
@Test public void testReplyingFromMockByExpression() throws InterruptedException { mockReplying.returnReplyBody(SimpleBuilder.simple("Hello ${body}")); mockOut.expectedBodiesReceived("Hello Camel"); in.sendBody("Camel"); assertMockEndpointsSatisfied(); }
Example #4
Source File: SimplePredicateWrapper.java From camel-cookbook-examples with Apache License 2.0 | 4 votes |
public void setSimplePredicate(String expression) { this.predicate = SimpleBuilder.simple(expression, Boolean.class); }