public <T> T getProperty(String name, Class<T> type) { return exchange.getProperty(name, type); } }
public Object getProperty(String name) { return exchange.getProperty(name); }
/** * Utility method which checks state of camel exchange used to implement * switchyard flow. * * @param exchange Camel exchange. * @return True if exchange state is fault. */ public static boolean isFault(org.apache.camel.Exchange exchange) { return exchange.getProperty(FAULT, false, Boolean.class); }
public class MyPredicate implements Predicate { public boolean matches(final Exchange exchange) { return (exchange.getIn().getBody(Map.class).get("updateSeq") > (exchange.getProperty("PrevUpdateSeq") + 1)) } }
private void logUnmatched(Exchange exchange, Object message, String serviceName) { LOG.warn("Processing unmatched message for service {}... Message type {} - Endpoint {}", serviceName, (message != null ? message.getClass().getName() : null), exchange.getProperty(CamelConstants.JMS_EXCHANGE_FAILURE_ENDPOINT)); }
@SuppressWarnings("unchecked") public void updateExchange(Exchange groupedExchange) { List<Exchange> exchangeList = groupedExchange.getProperty(Exchange.GROUPED_EXCHANGE, List.class); if (exchangeList.size() == 1) { Exchange orignalBookingExchange = exchangeList.get(0); String federatedQueryGUID = (String) orignalBookingExchange.getIn().getHeader("federatedQueryRequestGUID"); groupedExchange.getIn().setBody(orignalBookingExchange.getIn().getHeader("requestMessageBody")); groupedExchange.getIn().setHeader("federatedQueryRequestGUID", federatedQueryGUID); } }
private String determineIdProperty(final Exchange exchange) throws URISyntaxException { final String uri = exchange.getProperty(Exchange.TO_ENDPOINT, String.class); final Map<String, Object> endpointParameters = URISupport.parseParameters(URI.create(uri)); return (String) endpointParameters.getOrDefault(SalesforceEndpointConfig.SOBJECT_EXT_ID_NAME, "Id"); }
@Override public BaseExchangeContract getContract() { if (_exchange.getProperty(CONTRACT) == null) { _exchange.setProperty(CONTRACT, new BaseExchangeContract()); } return _exchange.getProperty(CONTRACT, BaseExchangeContract.class); }
public void onComplete(Exchange exchange) { try { dataStore.delete(exchange.getProperty(KratiConstants.KEY)); } catch (Exception e) { LOG.warn("Failed to remove from datastore. This exception is ignored.", e); } }
@Converter public static InputStream toInputStream(ClinicalDocument document, Exchange exchange) { Charset charset = Charset.defaultCharset(); if (exchange != null) { String charsetName = exchange.getProperty(Exchange.CHARSET_NAME, String.class); if (charsetName != null) { charset = Charset.forName(charsetName); } } return new ByteArrayInputStream(renderer.render(document, (Object[]) null).getBytes(charset)); }
@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 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 String link(final GroupPatch groupPatch) { PollingConsumer pollingConsumer = getConsumer("direct:linkGroupPort"); sendMessage("direct:linkGroup", groupPatch); Exchange exchange = pollingConsumer.receive(); if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) { throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT); } return exchange.getIn().getBody(GroupPatch.class).getKey(); }
public void process(Exchange exchange) throws Exception { exchange.setPattern( ExchangePattern.InOut ); BindingOperationInfo boi = (BindingOperationInfo) exchange.getProperty( BindingOperationInfo.class.toString() ); if ( boi != null ) { LOG.info( "boi.isUnwrapped" + boi.isUnwrapped() ); } SOAPMessage soapMessage = (SOAPMessage) exchange.getIn().getBody(); exchange.getOut().setBody( soapMessage.getSOAPBody().getTextContent() ); } }
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) { // to contains the endpoint which we send to so we know which system // has returned data back to us String to = newExchange.getProperty(Exchange.TO_ENDPOINT, String.class); if (to.contains("erp")) { return aggregate("ERP", oldExchange, newExchange); } else if (to.contains("crm")) { return aggregate("CRM", oldExchange, newExchange); } else { return aggregate("SHIPPING", oldExchange, newExchange); } }
protected void updateCharactorEncodingInfo(Exchange exchange) { if (exchange.getProperty(Exchange.CHARSET_NAME) == null && encoding != null) { exchange.setProperty(Exchange.CHARSET_NAME, IOHelper.normalizeCharset(encoding)); } }
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 protected CookieManager getCookieManager(Exchange exchange) { Object handlerObj = exchange.getProperty(Exchange.COOKIE_HANDLER); if (handlerObj instanceof java.net.CookieManager) { return (CookieManager)handlerObj; } else { CookieManager handler = new CookieManager(); handler.setCookiePolicy(cookiePolicy); exchange.setProperty(Exchange.COOKIE_HANDLER, handler); return handler; } }
@SuppressWarnings("unchecked") private void setResponseBack(Exchange cxfExchange, org.apache.camel.Exchange camelExchange) { CxfEndpoint endpoint = (CxfEndpoint)getEndpoint(); CxfBinding binding = endpoint.getCxfBinding(); checkFailure(camelExchange, cxfExchange); binding.populateCxfResponseFromExchange(camelExchange, cxfExchange); // check failure again as fault could be discovered by converter checkFailure(camelExchange, cxfExchange); // copy the headers javax.xml.ws header back binding.copyJaxWsContext(cxfExchange, (Map<String, Object>)camelExchange.getProperty(CxfConstants.JAXWS_CONTEXT)); }