Java Code Examples for org.apache.camel.Exchange#getOut()
The following examples show how to use
org.apache.camel.Exchange#getOut() .
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: ResponsePayloadMapper.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Override public Map<String, Object> mapFromResponse(Exchange exchange) { Map<String, Object> results = new HashMap<String, Object>(); if (exchange.hasOut()) { Message out = exchange.getOut(); Object response = out.getBody(); results.put(responseLocation, response); Map<String, Object> headerValues = out.getHeaders(); for (String headerLocation : this.headerLocations) { results.put(headerLocation, headerValues.get(headerLocation)); } } return results; }
Example 2
Source File: DataMapperStepHandler.java From syndesis with Apache License 2.0 | 6 votes |
@Override public void process(Exchange exchange) throws Exception { if (exchange.removeProperty(DATA_MAPPER_AUTO_CONVERSION) != null) { final Message message = exchange.hasOut() ? exchange.getOut() : exchange.getIn(); if (message != null && message.getBody(String.class) != null) { try { JsonNode json = JsonUtils.reader().readTree(message.getBody(String.class)); if (json.isArray()) { message.setBody(JsonUtils.arrayToJsonBeans(json)); } } catch (JsonParseException e) { LOG.warn("Unable to convert json array type String to required format", e); } } } }
Example 3
Source File: AggregateStepHandler.java From syndesis with Apache License 2.0 | 6 votes |
@Override public void process(Exchange exchange) throws Exception { final Message message = exchange.hasOut() ? exchange.getOut() : exchange.getIn(); if (message != null && message.getBody() instanceof List) { try { List<String> unifiedBodies = new ArrayList<>(); List<?> jsonBeans = message.getBody(List.class); for (Object unifiedJsonBean : jsonBeans) { JsonNode unifiedJson = JsonUtils.reader().readTree(String.valueOf(unifiedJsonBean)); if (unifiedJson.isObject()) { JsonNode body = unifiedJson.get("body"); if (body != null) { unifiedBodies.add(JsonUtils.writer().writeValueAsString(body)); } } } message.setBody("{\"body\":" + JsonUtils.jsonBeansToArray(unifiedBodies) + "}"); } catch (JsonParseException e) { LOG.warn("Unable to aggregate unified json array type", e); } } }
Example 4
Source File: OutMessageCaptureProcessor.java From syndesis with Apache License 2.0 | 5 votes |
@Override public void process(Exchange exchange) throws Exception { final Message message = exchange.hasOut() ? exchange.getOut() : exchange.getIn(); final String id = message.getHeader(IntegrationLoggingConstants.STEP_ID, String.class); if (id != null) { Message copy = message.copy(); Map<String, Message> outMessagesMap = getCapturedMessageMap(exchange); if (copy instanceof MessageSupport && copy.getExchange() == null) { ((MessageSupport) copy).setExchange(message.getExchange()); } outMessagesMap.put(id, copy); } }
Example 5
Source File: DataShapeCustomizerTest.java From syndesis with Apache License 2.0 | 5 votes |
@Test public void shouldAllowNullOutput() throws Exception { final ComponentProxyComponent component = setUpComponent("salesforce-create-sobject"); final Exchange exchange = new DefaultExchange(context); final Message out = exchange.getOut(); component.getAfterProducer().process(exchange); Assertions.assertThat(out.getBody()).isNull(); }
Example 6
Source File: DataShapeCustomizerTest.java From syndesis with Apache License 2.0 | 5 votes |
@Test public void shouldNotConvertFailedExchanges() throws Exception { final ComponentProxyComponent component = setUpComponent("salesforce-create-sobject"); final Exchange exchange = new DefaultExchange(context); final Message out = exchange.getOut(); exchange.setException(new Exception()); out.setBody("wat"); component.getAfterProducer().process(exchange); Assertions.assertThat(out.getBody()).isEqualTo("wat"); }
Example 7
Source File: ApacheCamelExample.java From yuzhouwan with Apache License 2.0 | 5 votes |
@Override public void process(Exchange exchange) throws Exception { // 因为很明确消息格式是http的,所以才使用这个类 // 否则还是建议使用org.apache.camel.Message这个抽象接口 HttpMessage message = (HttpMessage) exchange.getIn(); InputStream bodyStream = (InputStream) message.getBody(); String inputContext = this.analysisMessage(bodyStream); bodyStream.close(); // 存入到 exchange的 out区域 if (exchange.getPattern() == ExchangePattern.InOut) { Message outMessage = exchange.getOut(); outMessage.setBody(inputContext + " || out"); } }
Example 8
Source File: CryptoComponentIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testBasicSignatureRoute() throws Exception { CamelContext camelctx = new DefaultCamelContext(new JndiBeanRepository()); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:sign") .to("crypto:sign://basic?privateKey=#myPrivateKey&algorithm=SHA1withDSA&provider=SUN") .to("direct:verify"); from("direct:verify") .to("crypto:verify://basic?publicKey=#myPublicKey&algorithm=SHA1withDSA&provider=SUN") .to("mock:result"); } }); camelctx.start(); try { camelctx.createProducerTemplate().sendBody("direct:sign", PAYLOAD); MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class); Exchange e = mockEndpoint.getExchanges().get(0); Message result = e == null ? null : e.hasOut() ? e.getOut() : e.getIn(); Assert.assertNull(result.getHeader(DigitalSignatureConstants.SIGNATURE)); } finally { camelctx.close(); } }