Search in sources :

Example 1 with DefaultExchangeHolder

use of org.apache.camel.impl.DefaultExchangeHolder in project camel by apache.

the class CassandraCamelCodec method marshallExchange.

public ByteBuffer 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));
    // 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 ByteBuffer.wrap(serialize(pe));
}
Also used : DefaultExchangeHolder(org.apache.camel.impl.DefaultExchangeHolder)

Example 2 with DefaultExchangeHolder

use of org.apache.camel.impl.DefaultExchangeHolder in project camel by apache.

the class EhcacheAggregationRepository method add.

@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);
    final DefaultExchangeHolder oldHolder = cache.get(key);
    final DefaultExchangeHolder newHolder = DefaultExchangeHolder.marshal(exchange, true, allowSerializedHeaders);
    cache.put(key, newHolder);
    return unmarshallExchange(camelContext, oldHolder);
}
Also used : DefaultExchangeHolder(org.apache.camel.impl.DefaultExchangeHolder)

Example 3 with DefaultExchangeHolder

use of org.apache.camel.impl.DefaultExchangeHolder in project camel by apache.

the class HawtDBCamelCodec method marshallExchange.

public Buffer marshallExchange(CamelContext camelContext, Exchange exchange, boolean allowSerializedHeaders) throws IOException {
    DataByteArrayOutputStream baos = new DataByteArrayOutputStream();
    // 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));
    // 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());
    }
    exchangeCodec.encode(pe, baos);
    return baos.toBuffer();
}
Also used : DefaultExchangeHolder(org.apache.camel.impl.DefaultExchangeHolder) DataByteArrayOutputStream(org.fusesource.hawtbuf.DataByteArrayOutputStream)

Example 4 with DefaultExchangeHolder

use of org.apache.camel.impl.DefaultExchangeHolder in project camel by apache.

the class InfinispanRemoteAggregationRepository method add.

@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);
}
Also used : DefaultExchangeHolder(org.apache.camel.impl.DefaultExchangeHolder)

Example 5 with DefaultExchangeHolder

use of org.apache.camel.impl.DefaultExchangeHolder in project camel by apache.

the class LevelDBCamelCodec method marshallExchange.

public Buffer marshallExchange(CamelContext camelContext, Exchange exchange, boolean allowSerializedHeaders) throws IOException {
    DataByteArrayOutputStream baos = new DataByteArrayOutputStream();
    // 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));
    // 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());
    }
    exchangeCodec.encode(pe, baos);
    return baos.toBuffer();
}
Also used : DefaultExchangeHolder(org.apache.camel.impl.DefaultExchangeHolder) DataByteArrayOutputStream(org.fusesource.hawtbuf.DataByteArrayOutputStream)

Aggregations

DefaultExchangeHolder (org.apache.camel.impl.DefaultExchangeHolder)20 Exchange (org.apache.camel.Exchange)6 DefaultExchange (org.apache.camel.impl.DefaultExchange)6 Endpoint (org.apache.camel.Endpoint)4 TransactionContext (com.hazelcast.transaction.TransactionContext)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 BytesMessage (javax.jms.BytesMessage)2 JMSException (javax.jms.JMSException)2 MapMessage (javax.jms.MapMessage)2 ObjectMessage (javax.jms.ObjectMessage)2 StreamMessage (javax.jms.StreamMessage)2 TextMessage (javax.jms.TextMessage)2 RuntimeCamelException (org.apache.camel.RuntimeCamelException)2 DataByteArrayInputStream (org.fusesource.hawtbuf.DataByteArrayInputStream)2 DataByteArrayOutputStream (org.fusesource.hawtbuf.DataByteArrayOutputStream)2 TransactionOptions (com.hazelcast.transaction.TransactionOptions)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 ArrayList (java.util.ArrayList)1