public Map<String, Object> getProperties() { return exchange.getProperties(); }
public Map<String, Object> getProperties() { return exchange.getProperties(); }
public Map<String, Object> getProperties() { return exchange.getProperties(); }
public void inspectProperties(Exchange exchange){ Map properties = (Map) exchange.getProperties(); Iterator iter = properties.entrySet().iterator(); if (logger.isDebugEnabled()){ logger.debug("WIRETAP: properties size: "+properties.size()); while(iter.hasNext()){ Map.Entry pairs = (Map.Entry)iter.next(); logger.debug("key: "+pairs.getKey()+" value: "+pairs.getValue()); } } } public void inspectBody(Exchange exchange){
public void process(Exchange exchange) throws Exception { try { loadBalancer.process(exchange); } catch (IllegalStateException e){ LOG.error("Unable to find processor for endpoint: [" + exchange.getProperties().get("CamelToEndpoint") + "]"); throw e; } } };
camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").process(new Processor() { @Override public void process(Exchange exchange) throws Exception { exchange.getProperties().put("ADDED","ADDED"); } }); } }); camelContext.start(); camelContext.createProducerTemplate().sendBody("direct:start", "addPropertyToMe");
from("{{ftp.server}}") .to("file:target/download") .log("Downloaded file ${file:name} complete.") .process(new Processor() { public void process(Exchange exchange) throws Exception { boolean isComplete = (Boolean)exchange.getProperties().get("CamelBatchComplete"); });
@Override public void process(Exchange exchange) throws Exception { logger.debug("processing messages for dynamic recipients generation"); Map headers = exchange.getIn().getHeaders(); Map properties = exchange.getProperties(); List<String> ownerApplications = (List<String>)headers.get(WonCamelConstants.OWNER_APPLICATIONS); // String methodName =headers.get("methodName").toString(); logger.debug("number of registered owner applications: {}", ownerApplications == null ? 0 : ownerApplications.size()); List<String> queueNames = convertToQueueName(ownerApplications,"wonMessage",exchange); exchange.getIn().setHeader("ownerApplicationIDs",queueNames); } private List<String> convertToQueueName(List<String> ownerApplications,String methodName,Exchange
@Override @SuppressWarnings("unchecked") protected Map<String, Set<String>> getLabelsBag() { if (!_exchange.getProperties().containsKey(CamelExchange.LABELS)) { _exchange.setProperty(CamelExchange.LABELS, new HashMap<String, Set<String>>()); } return _exchange.getProperty(CamelExchange.LABELS, Map.class); }
@Override @SuppressWarnings("unchecked") protected Map<String, Set<String>> getLabelsBag() { if (!_exchange.getProperties().containsKey(CamelExchange.LABELS)) { _exchange.setProperty(CamelExchange.LABELS, new HashMap<String, Set<String>>()); } return _exchange.getProperty(CamelExchange.LABELS, Map.class); }
private Property getExchangeProperty(String name) { if (_exchange.hasProperties() && _exchange.getProperties().containsKey(name)) { return new CamelExchangeProperty(_exchange, name); } return null; }
private Property getExchangeProperty(String name) { if (_exchange.hasProperties() && _exchange.getProperties().containsKey(name)) { return new CamelExchangeProperty(_exchange, name); } return null; }
private void addData() { Object body; if (data.size() == 0) { body = null; } else if (data.size() == 1) { body = data.get(0); } else { body = data; } if (body instanceof Exchange && !exchange.equals(body)) { // copy into the original Exchange Exchange copy = (Exchange) body; exchange.setException(copy.getException()); exchange.setIn(copy.getIn()); exchange.setOut(copy.getOut()); exchange.getProperties().clear(); exchange.getProperties().putAll(copy.getProperties()); } else { exchange.getOut().setBody(body); } }
/** * Creates new CamelExchange. * * @param dispatch Exchange dispatcher. * @param exchange Camel exchange instance. * @param replyHandler Reply handler. */ public CamelExchange(ExchangeDispatcher dispatch, org.apache.camel.Exchange exchange, ExchangeHandler replyHandler) { _exchange = exchange; Map<String, Object> properties = exchange.getProperties(); if (!properties.containsKey(DISPATCHER)) { _exchange.setProperty(DISPATCHER, dispatch); } if (!properties.containsKey(REPLY_HANDLER)) { _exchange.setProperty(REPLY_HANDLER, replyHandler); } }
/** * Creates new CamelExchange. * * @param dispatch Exchange dispatcher. * @param exchange Camel exchange instance. * @param replyHandler Reply handler. */ public CamelExchange(ExchangeDispatcher dispatch, org.apache.camel.Exchange exchange, ExchangeHandler replyHandler) { _exchange = exchange; Map<String, Object> properties = exchange.getProperties(); if (!properties.containsKey(DISPATCHER)) { _exchange.setProperty(DISPATCHER, dispatch); } if (!properties.containsKey(REPLY_HANDLER)) { _exchange.setProperty(REPLY_HANDLER, replyHandler); } }
public class SchemaErrorHandler implements Processor { private final String STATUS_CODE = "6103"; private final String SEVERITY_CODE = "2"; @Override public void process(Exchange exchange) throws Exception { Map<String, Object> map = exchange.getProperties(); String statusDesc = "Unknown exception"; if (map != null) { SchemaValidationException exception = (SchemaValidationException) map.get("CamelExceptionCaught"); if (exception != null && !CollectionUtils.isEmpty(exception.getErrors())) { StringBuffer buffer = new StringBuffer(); for (SAXParseException e : exception.getErrors()) { statusDesc = e.getMessage(); buffer.append(statusDesc); } statusDesc = buffer.toString(); } } Fault fault = new Fault(new Message(statusDesc, (ResourceBundle) null)); fault.setDetail(ErrorUtils.createDetailSection(STATUS_CODE, statusDesc, exchange, SEVERITY_CODE)); throw fault; } }
private void copyEmptyProperties(Exchange state, Exchange result) { if (state != null) { for (String prop : state.getProperties().keySet()) { if (result.getProperty(prop) == null) { result.setProperty(prop, state.getProperty(prop)); } } } }
private void copyPropertiesFromCamelToJbi(Exchange exchange, MessageExchange messageExchange) { for (String key : exchange.getProperties().keySet()) { if (messageExchange.getProperty(key) == null) { Object value = exchange.getProperty(key); if (!MESSAGE_EXCHANGE.equals(key) && value != null && !strategies.applyFilterToCamelHeaders(key, value, exchange)) { messageExchange.setProperty(key, value); } } } }
@Override public Set<Property> getProperties(Scope scope) { Set<Property> properties = new HashSet<Property>(); switch (scope) { case EXCHANGE: if (_exchange.hasProperties()) { for (String prop : _exchange.getProperties().keySet()) { properties.add(new CamelExchangeProperty(_exchange, prop)); } } break; default: if (_message.hasHeaders()) { for (String prop : _message.getHeaders().keySet()) { properties.add(new CamelMessageProperty(_message, prop)); } } break; } return properties; }
for (Map.Entry<String, Object> property : exchange.getProperties().entrySet()) { message.setHeader(property.getKey(), property.getValue());