Search in sources :

Example 1 with DataByteArrayOutputStream

use of org.fusesource.hawtbuf.DataByteArrayOutputStream 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 2 with DataByteArrayOutputStream

use of org.fusesource.hawtbuf.DataByteArrayOutputStream 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)

Example 3 with DataByteArrayOutputStream

use of org.fusesource.hawtbuf.DataByteArrayOutputStream in project camel by apache.

the class HawtDBCamelCodec method marshallKey.

public Buffer marshallKey(String key) throws IOException {
    DataByteArrayOutputStream baos = new DataByteArrayOutputStream();
    keyCodec.encode(key, baos);
    return baos.toBuffer();
}
Also used : DataByteArrayOutputStream(org.fusesource.hawtbuf.DataByteArrayOutputStream)

Example 4 with DataByteArrayOutputStream

use of org.fusesource.hawtbuf.DataByteArrayOutputStream in project camel by apache.

the class LevelDBCamelCodec method marshallKey.

public Buffer marshallKey(String key) throws IOException {
    DataByteArrayOutputStream baos = new DataByteArrayOutputStream();
    keyCodec.encode(key, baos);
    return baos.toBuffer();
}
Also used : DataByteArrayOutputStream(org.fusesource.hawtbuf.DataByteArrayOutputStream)

Aggregations

DataByteArrayOutputStream (org.fusesource.hawtbuf.DataByteArrayOutputStream)4 DefaultExchangeHolder (org.apache.camel.impl.DefaultExchangeHolder)2