public static Object getOut(NettyEndpoint endpoint, Exchange exchange) { if (endpoint.getConfiguration().isTransferExchange()) { // we should transfer the entire exchange over the wire (includes in/out) return DefaultExchangeHolder.marshal(exchange); } else { // normal transfer using the body only return exchange.getOut().getBody(); } }
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 byte[] marshallExchange(CamelContext camelContext, Exchange exchange) throws IOException { // use DefaultExchangeHolder to marshal to a serialized object DefaultExchangeHolder pe = DefaultExchangeHolder.marshal(exchange, false); // add the aggregated size property as the only property we want to retain DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_SIZE, exchange.getProperty(Exchange.AGGREGATED_SIZE, Integer.class)); // add the aggregated completed by property to retain DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_COMPLETED_BY, exchange.getProperty(Exchange.AGGREGATED_COMPLETED_BY, String.class)); // add the aggregated correlation key property to retain DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_CORRELATION_KEY, exchange.getProperty(Exchange.AGGREGATED_CORRELATION_KEY, String.class)); // persist the from endpoint as well if (exchange.getFromEndpoint() != null) { DefaultExchangeHolder.addProperty(pe, "CamelAggregatedFromEndpoint", exchange.getFromEndpoint().getEndpointUri()); } return encode(pe); }
public static void setIn(Exchange exchange, Object payload) { if (payload instanceof DefaultExchangeHolder) { DefaultExchangeHolder.unmarshal(exchange, (DefaultExchangeHolder) payload); } else if (payload instanceof AddressedEnvelope) { @SuppressWarnings("unchecked") AddressedEnvelope<Object, InetSocketAddress> dp = (AddressedEnvelope<Object, InetSocketAddress>)payload; // need to check if the content is ExchangeHolder if (dp.content() instanceof DefaultExchangeHolder) { DefaultExchangeHolder.unmarshal(exchange, (DefaultExchangeHolder) dp.content()); } else { // need to take out the payload here exchange.getIn().setBody(dp.content()); } // setup the sender address here for sending the response message back exchange.setProperty(NettyConstants.NETTY_REMOTE_ADDRESS, dp.sender()); // setup the remote address to the message header at the same time exchange.getIn().setHeader(NettyConstants.NETTY_REMOTE_ADDRESS, dp.sender()); } else { // normal transfer using the body only exchange.getIn().setBody(payload); } }
public static Object getIn(NettyEndpoint endpoint, Exchange exchange) { if (endpoint.getConfiguration().isTransferExchange()) { // we should transfer the entire exchange over the wire (includes in/out) return DefaultExchangeHolder.marshal(exchange); } else { if (endpoint.getConfiguration().isUseChannelBuffer()) { // The NettyConverter could help us for it return exchange.getIn().getBody(ChannelBuffer.class); } else { // normal transfer using the body only return exchange.getIn().getBody(); } } }
if (payload instanceof DefaultExchangeHolder) { DefaultExchangeHolder holder = (DefaultExchangeHolder) payload; DefaultExchangeHolder.unmarshal(exchange, holder); exchange.getIn().getHeaders().putAll(jmsHeaders); return exchange.getIn().getBody(); } else { return objectMessage.getObject();
DefaultExchangeHolder.unmarshal(exchange, (DefaultExchangeHolder) body); } else { exchange.getIn().setBody(body); if (exchange.getException() != null) { getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
@Override public Exchange add(CamelContext camelContext, String key, Exchange exchange) { if (optimistic) { throw new UnsupportedOperationException(); } LOG.trace("Adding an Exchange with ID {} for key {} in a thread-safe manner.", exchange.getExchangeId(), key); DefaultExchangeHolder newHolder = DefaultExchangeHolder.marshal(exchange, true, allowSerializedHeaders); DefaultExchangeHolder oldHolder = cache.getAndPut(key, newHolder); return unmarshallExchange(camelContext, oldHolder); }
public Exchange unmarshallExchange(CamelContext camelContext, byte[] buffer) throws IOException, ClassNotFoundException { DefaultExchangeHolder pe = decode(buffer); Exchange answer = new DefaultExchange(camelContext); DefaultExchangeHolder.unmarshal(answer, pe); // restore the from endpoint String fromEndpointUri = (String) answer.removeProperty("CamelAggregatedFromEndpoint"); if (fromEndpointUri != null) { Endpoint fromEndpoint = camelContext.hasEndpoint(fromEndpointUri); if (fromEndpoint != null) { answer.setFromEndpoint(fromEndpoint); } } return answer; }
protected Exchange unmarshallExchange(CamelContext camelContext, DefaultExchangeHolder holder) { Exchange exchange = null; if (holder != null) { exchange = new DefaultExchange(camelContext); DefaultExchangeHolder.unmarshal(exchange, holder); } return exchange; } }
Serializable holder = DefaultExchangeHolder.marshal(exchange, true, endpoint.isAllowSerializedHeaders()); Message answer = session.createObjectMessage(holder);
private void checkAndStore(final Exchange exchange) { Object obj; Object body = exchange.getIn().getBody(); final HazelcastSedaEndpoint endpoint = (HazelcastSedaEndpoint) this.getEndpoint(); final HazelcastSedaConfiguration configuration = endpoint.getConfiguration(); if (configuration.isTransferExchange()) { obj = DefaultExchangeHolder.marshal(exchange); } else { // in case body is not serializable convert to byte array if (!(body instanceof Serializable)) { obj = exchange.getIn().getBody(byte[].class); } else { obj = body; } } queue.add(obj); // finally copy headers HazelcastComponentHelper.copyHeaders(exchange); }
@Override public Exchange add(final CamelContext camelContext, final String key, final Exchange exchange) { LOG.trace("Adding an Exchange with ID {} for key {} in a thread-safe manner.", exchange.getExchangeId(), key); DefaultExchangeHolder newHolder = DefaultExchangeHolder.marshal(exchange, true, allowSerializedHeaders); DefaultExchangeHolder oldHolder = cache.put(key, newHolder); return unmarshallExchange(camelContext, oldHolder); }
public Exchange unmarshallExchange(CamelContext camelContext, byte[] buffer) throws IOException, ClassNotFoundException { DefaultExchangeHolder pe = decode(camelContext, buffer); Exchange answer = new DefaultExchange(camelContext); DefaultExchangeHolder.unmarshal(answer, pe); // restore the from endpoint String fromEndpointUri = (String) answer.removeProperty("CamelAggregatedFromEndpoint"); if (fromEndpointUri != null) { Endpoint fromEndpoint = camelContext.hasEndpoint(fromEndpointUri); if (fromEndpoint != null) { answer.setFromEndpoint(fromEndpoint); } } return answer; }
protected Exchange unmarshallExchange(CamelContext camelContext, DefaultExchangeHolder holder) { Exchange exchange = null; if (holder != null) { exchange = new DefaultExchange(camelContext); DefaultExchangeHolder.unmarshal(exchange, holder); } return exchange; }
public static void setOut(Exchange exchange, Object payload) { if (payload instanceof DefaultExchangeHolder) { DefaultExchangeHolder.unmarshal(exchange, (DefaultExchangeHolder) payload); } else if (payload instanceof AddressedEnvelope) { @SuppressWarnings("unchecked") AddressedEnvelope<Object, InetSocketAddress> dp = (AddressedEnvelope<Object, InetSocketAddress>)payload; // need to check if the content is ExchangeHolder if (dp.content() instanceof DefaultExchangeHolder) { DefaultExchangeHolder.unmarshal(exchange, (DefaultExchangeHolder) dp.content()); } else { // need to take out the payload here exchange.getOut().setBody(dp.content()); } // setup the sender address here for sending the response message back exchange.setProperty(NettyConstants.NETTY_REMOTE_ADDRESS, dp.sender()); } else { // normal transfer using the body only and preserve the headers exchange.getOut().setHeaders(exchange.getIn().getHeaders()); exchange.getOut().setBody(payload); } }
public static Object getIn(NettyEndpoint endpoint, Exchange exchange) { if (endpoint.getConfiguration().isTransferExchange()) { // we should transfer the entire exchange over the wire (includes in/out) return DefaultExchangeHolder.marshal(exchange, true, endpoint.getConfiguration().isAllowSerializedHeaders()); } else { if (endpoint.getConfiguration().isUseByteBuf()) { // Just leverage the type converter return exchange.getIn().getBody(ByteBuf.class); } else { // normal transfer using the body only return exchange.getIn().getBody(); } } }
public static Object getOut(NettyEndpoint endpoint, Exchange exchange) { if (endpoint.getConfiguration().isTransferExchange()) { // we should transfer the entire exchange over the wire (includes in/out) return DefaultExchangeHolder.marshal(exchange); } else { // normal transfer using the body only return exchange.getOut().getBody(); } }
public byte[] marshallExchange(CamelContext camelContext, Exchange exchange, boolean allowSerializedHeaders) throws IOException { // use DefaultExchangeHolder to marshal to a serialized object DefaultExchangeHolder pe = DefaultExchangeHolder.marshal(exchange, false, allowSerializedHeaders); // add the aggregated size and timeout property as the only properties we want to retain DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_SIZE, exchange.getProperty(Exchange.AGGREGATED_SIZE, Integer.class)); DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_TIMEOUT, exchange.getProperty(Exchange.AGGREGATED_TIMEOUT, Long.class)); // add the aggregated completed by property to retain DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_COMPLETED_BY, exchange.getProperty(Exchange.AGGREGATED_COMPLETED_BY, String.class)); // add the aggregated correlation key property to retain DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_CORRELATION_KEY, exchange.getProperty(Exchange.AGGREGATED_CORRELATION_KEY, String.class)); DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_CORRELATION_KEY, exchange.getProperty(Exchange.AGGREGATED_CORRELATION_KEY, String.class)); // and a guard property if using the flexible toolbox aggregator DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_COLLECTION_GUARD, exchange.getProperty(Exchange.AGGREGATED_COLLECTION_GUARD, String.class)); // persist the from endpoint as well if (exchange.getFromEndpoint() != null) { DefaultExchangeHolder.addProperty(pe, "CamelAggregatedFromEndpoint", exchange.getFromEndpoint().getEndpointUri()); } return encode(pe); }