Refine search
@Override public void process(Exchange exchange) throws Exception { final INDArray arr = (INDArray) exchange.getIn().getBody(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); Nd4j.write(arr, dos); byte[] bytes = bos.toByteArray(); String base64 = Base64.encodeBase64String(bytes); exchange.getIn().setBody(base64, String.class); String id = UUID.randomUUID().toString(); exchange.getIn().setHeader(KafkaConstants.KEY, id); exchange.getIn().setHeader(KafkaConstants.PARTITION_KEY, id); } }).to(kafkaUri);
@Override public void process(Exchange exchange) { logger.debug("Firing CDI event [{}] with {}", event, this); // TODO: leverage Camel type converter mechanism based on the endpoint type // The EventMetadata injection point will be that of the event which is not very useful // for the end user. Using BeanManager.fire would be a way to hide that internal though // it will be necessary to check whether the exchange event type is assignable to the // endpoint event type. event.fire((T) exchange.getIn().getBody()); } }
public Exchange aggregate(String system, Exchange oldExchange, Exchange newExchange) { // the first time oldExchange is null so we got to look out for that Exchange answer = oldExchange == null ? newExchange : oldExchange; // store data temporary in headers so we can combine data later answer.getIn().setHeader(system, newExchange.getIn().getBody()); return answer; }
// Note: Content Type - might need treatment! public class AttachmentAttacher{ public void process(Exchange exchange){ Message in = exchange.getIn(); byte[] file = in.getBody(byte[].class); String fileId = in.getHeader("CamelFileName",String.class); in.addAttachment(fileId, new DataHandler(file,"plain/text")); } }
@Override public void inspectMessage(Exchange exchange) { if (!logger.isDebugEnabled()) { return; } inspectProperties(exchange); inspectHeaders(exchange); if(exchange.getIn().getBody()!=null) { logger.debug(exchange.getIn().getBody().toString()); } } public void inspectProperties(Exchange exchange){
private void beforeProducer(Exchange exchange) { final Message in = exchange.getIn(); final FhirUpdateMessageModel fhirUpdateMessageModel = exchange.getIn().getBody(FhirUpdateMessageModel.class); if (fhirUpdateMessageModel != null && fhirUpdateMessageModel.getResource() != null) { this.resource = fhirUpdateMessageModel.getResource(); } else { this.resource = in.getBody(String.class); } LOG.info("Updating resource" + this.resource); in.setHeader("CamelFhir.resourceAsString", this.resource); } }
protected Map<String, Number> getNumbersFromExchange(Exchange exchange) throws Exception { Map<String, Number> result = null; //try and extract something from the Message to monitor Object payload = exchange.getIn().getBody(); if (payload != null) { result = PropertyUtil.getValues(Number.class, payload); } return result; }