@Override public void process(Exchange exchange) throws Exception { // cleanup and remove the headers we used exchange.getMessage().removeHeader(Exchange.HTTP_PATH); exchange.getMessage().removeHeader(Exchange.HTTP_QUERY); }
@Override public boolean matches(Exchange exchange) { Contract contract = getContract(exchange.getMessage()); if (log.isDebugEnabled()) { log.debug("For exchange [" + exchange + "] found contract [" + contract + "]"); } if (contract == null) { return false; } exchange.getIn().setBody(new StubRunnerCamelPayload(contract)); return true; }
@Override public void process(Exchange exchange) throws Exception String body = (String) exchange.getMessage().getBody();
@Override public void process(Exchange exchange) throws Exception String body = (String) exchange.getMessage().getBody();
@Override public void putState(Channel channel, NettyCamelState state) { // grab the correlation id Object body = state.getExchange().getMessage().getBody(); // the correlation id is the first part of the message String cid = getRequestCorrelationId(body); if (ObjectHelper.isEmpty(cid)) { throw new IllegalArgumentException("CorrelationID is missing"); } LOG.debug("putState({}) on channel: {}", cid, channel.id()); map.put(cid, state, timeout); }
@Override public boolean onEviction(String key, NettyCamelState value) { timeoutLogger.log("Timeout of correlation id: " + key); workerPool.submit(() -> { Exchange exchange = value.getExchange(); AsyncCallback callback = value.getCallback(); if (exchange != null && callback != null) { Object timeoutBody = getTimeoutResponse(key, exchange.getMessage().getBody()); if (timeoutBody != null) { exchange.getMessage().setBody(timeoutBody); } else { exchange.setException(new ExchangeTimedOutException(exchange, timeout)); } callback.done(false); } }); return true; } }
@Override public void marshal(Exchange exchange, Object o, OutputStream outputStream) throws Exception { IBaseResource iBaseResource; if (!(o instanceof IBaseResource)) { iBaseResource = exchange.getContext().getTypeConverter().mandatoryConvertTo(IBaseResource.class, exchange, o); } else { iBaseResource = (IBaseResource) o; } IParser parser = getFhirContext().newXmlParser(); configureParser(parser); parser.encodeResourceToWriter(iBaseResource, new OutputStreamWriter(outputStream)); if (isContentTypeHeader()) { exchange.getMessage().setHeader(Exchange.CONTENT_TYPE, parser.getEncoding().getResourceContentTypeNonLegacy()); } }
@Override public void marshal(Exchange exchange, Object o, OutputStream outputStream) throws Exception { IBaseResource iBaseResource; if (!(o instanceof IBaseResource)) { iBaseResource = exchange.getContext().getTypeConverter().mandatoryConvertTo(IBaseResource.class, exchange, o); } else { iBaseResource = (IBaseResource) o; } IParser parser = getFhirContext().newJsonParser(); configureParser(parser); parser.encodeResourceToWriter(iBaseResource, new OutputStreamWriter(outputStream)); if (isContentTypeHeader()) { exchange.getMessage().setHeader(Exchange.CONTENT_TYPE, parser.getEncoding().getResourceContentTypeNonLegacy()); } }