@Override public void process(Exchange exchange) throws Exception { exchange.getIn().setBody(payload); exchange.getIn().setHeaders(headers); } }
@Override public void process(Exchange exchange) throws Exception { exchange.getIn().setBody(payload); exchange.getIn().setHeaders(headers); } }
@Override public void process(Exchange exchange) throws Exception { exchange.getIn().setBody(body); exchange.getIn().setHeaders(headers); } }
public static void storeToCamelMessage(org.springframework.messaging.Message<?> siMessage, org.apache.camel.Message cMessage) { cMessage.setBody(siMessage.getPayload()); cMessage.setHeaders(siMessage.getHeaders()); }
@Override public void onComplete(Object response) { exchange.getOut().setHeaders(exchange.getIn().getHeaders()); if (response == null) { exchange.getOut().setBody(response); } else { exchange.getOut().setBody(response, response.getClass()); } callback.done(false); }
public class CustomService { public List split(Exchange exchange) { List list = new ArrayList(); Map map = exchange.getIn().getBody(Map.class); for (Object value : map.values()) { // either copy or create a new DefaultMessage Message msg = new DefaultMessage(); msg.setBody(value); // we want to copy the existing headers msg.setHeaders(exchange.getIn().getHeaders(); // and then customize the headers msg.setHeader("foo", "bar"); list.add(msg); } return list; } }
public static void setOut(Exchange exchange, Object payload) { if (payload instanceof DefaultExchangeHolder) { DefaultExchangeHolder.unmarshal(exchange, (DefaultExchangeHolder) payload); } else { // normal transfer using the body only and preserve the headers exchange.getOut().setHeaders(exchange.getIn().getHeaders()); exchange.getOut().setBody(payload); } }
public void process(Exchange exchange) throws Exception { String input = exchange.getIn().getBody(String.class); // if the verbose switch is turned on then log to System out if (getEndpoint().isVerbose()) { System.out.println("Calling ERP with: " + input); } // simulate calling ERP system and setting reply on the OUT body exchange.getOut().setBody("Simulated response from ERP"); // support propagating headers (by copying headers from IN -> OUT) exchange.getOut().setHeaders(exchange.getIn().getHeaders()); }
@Override @SuppressWarnings("unchecked") public Exchange aggregate(Exchange oldExchange, Exchange newExchange) { if (oldExchange == null) { oldExchange = new DefaultExchange(newExchange); oldExchange.getIn().setHeaders(newExchange.getIn().getHeaders()); List<Object> body = new ArrayList<Object>(); oldExchange.getIn().setBody(body); oldExchange.getExchangeId(); } oldExchange.getIn().getBody(List.class).add(newExchange.getIn().getBody()); return oldExchange; }
public void process(Exchange exchange) throws Exception { String input = exchange.getIn().getBody(String.class); // if the verbose switch is turned on then log to System out if (getEndpoint().isVerbose()) { System.out.println("Calling ERP with: " + input); } // simulate calling ERP system and setting reply on the OUT body exchange.getOut().setBody("Simulated response from ERP"); // support propagating headers (by copying headers from IN -> OUT) exchange.getOut().setHeaders(exchange.getIn().getHeaders()); }
/** * Propagates (copies) the {@code Body}, the {@code Attachments} and the {@code Headers} of the {@link Message} * from from IN to OUT. * * @param exchange the exchange message */ public static void propagateMessage(Exchange exchange) { Assert.notNull(exchange, "the exchange must not be null"); // copy headers from IN to OUT to propagate them exchange.getOut().setHeaders(exchange.getIn().getHeaders()); // copy attachments from IN to OUT to propagate them exchange.getOut().setAttachments(exchange.getIn().getAttachments()); // copy body from IN to OUT to propagate it exchange.getOut().setBody(exchange.getIn().getBody()); }
@Override public void onResponse(Object response, Map<String, String> responseHeaders) { // producer returns a single response, even for methods with List return types exchange.getOut().setBody(response); // copy headers exchange.getOut().setHeaders(exchange.getIn().getHeaders()); // Add http response headers exchange.getOut().setHeader(Olingo2Constants.PROPERTY_PREFIX + RESPONSE_HTTP_HEADERS, responseHeaders); interceptResult(response, exchange); callback.done(false); }
public static void copyHeaders(Exchange ex) { // get in headers Map<String, Object> headers = ex.getIn().getHeaders(); // DELETE item id if (headers.containsKey(HazelcastConstants.OBJECT_ID)) { headers.remove(HazelcastConstants.OBJECT_ID); } if (headers.containsKey(HazelcastConstants.OPERATION)) { headers.remove(HazelcastConstants.OPERATION); } // propagate headers if OUT message created if (ex.hasOut()) { ex.getOut().setHeaders(headers); } }
private void handleHttpFailure(Exchange exchange) { HttpOperationFailedException e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, HttpOperationFailedException.class); exchange.getOut().setHeaders(exchange.getIn().getHeaders()); exchange.getOut().setBody(String.format(RESPONSE_STRING_FORMAT, String.format("%d %s", e.getStatusCode(), e.getResponseBody()) )); }
private void handleHttpFailure(Exchange exchange) { HttpOperationFailedException e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, HttpOperationFailedException.class); exchange.getOut().setHeaders(exchange.getIn().getHeaders()); exchange.getOut().setBody(String.format(RESPONSE_STRING_FORMAT, String.format("%d %s", e.getStatusCode(), e.getResponseBody()) )); } }
@Override public void onResponse(Object response) { // producer returns a single response, even for methods with List return types exchange.getOut().setBody(response); // copy headers exchange.getOut().setHeaders(exchange.getIn().getHeaders()); interceptResult(response, exchange); callback.done(false); }
/** * Creates an <code>exchange.getOut()</code> message that containing the * access token and the access token secret in the message header. * * @see #GAUTH_ACCESS_TOKEN * @see #GAUTH_ACCESS_TOKEN_SECRET */ public Exchange readResponse(GAuthEndpoint endpoint, Exchange exchange, GoogleOAuthParameters response) throws IOException { exchange.getOut().setHeaders(exchange.getIn().getHeaders()); exchange.getOut().setHeader(GAUTH_ACCESS_TOKEN, canonicalizeToken(response.getOAuthToken())); exchange.getOut().setHeader(GAUTH_ACCESS_TOKEN_SECRET, canonicalizeToken(response.getOAuthTokenSecret())); return exchange; }
protected void readResponseHeaders(GHttpEndpoint endpoint, Exchange exchange, HTTPResponse response) { HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy(); Message in = exchange.getIn(); Message out = exchange.getOut(); out.setHeaders(in.getHeaders()); out.setHeader(Exchange.HTTP_RESPONSE_CODE, response.getResponseCode()); String contentType = getResponseHeader("Content-Type", response); if (contentType != null) { out.setHeader(Exchange.CONTENT_TYPE, contentType); } for (HTTPHeader header : response.getHeaders()) { String name = header.getName(); String value = header.getValue(); if (strategy != null && !strategy.applyFilterToExternalHeaders(name, value, exchange)) { out.setHeader(name, value); } } }
/** * Creates a new {@link Exchange} from <code>packet</code> using the * current {@link CamelContext}. * * @param packet message packet. * @return a new message exchange. */ protected Exchange createExchange(PlatformPacket packet) { DefaultExchange exchange = new DefaultExchange(camelContext); exchange.setUnitOfWork(new DefaultUnitOfWork(exchange)); exchange.setProperties(new HashMap<>(packet.getExchangeProperties())); exchange.getIn().setHeaders(new HashMap<>(packet.getMessageProperties())); setInBody(packet.getMessageBody(), exchange); return exchange; }
/** * Applies the cells to the {@link org.apache.camel.Exchange}. */ public void applyGetResults(Message message, HBaseData data) { message.setHeaders(message.getExchange().getIn().getHeaders()); int index = 1; if (data == null || data.getRows() == null) { return; } for (HBaseRow hRow : data.getRows()) { if (hRow.getId() != null) { Set<HBaseCell> cells = hRow.getCells(); for (HBaseCell cell : cells) { message.setHeader(HBaseAttribute.HBASE_VALUE.asHeader(index++), getValueForColumn(cells, cell.getFamily(), cell.getQualifier())); } } } }