org.apache.camel.support.processor.DelegateAsyncProcessor Java Examples

The following examples show how to use org.apache.camel.support.processor.DelegateAsyncProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KnativeHttpSupport.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
/**
 * Removes cloud event headers at the end of the processing.
 */
public static Processor withoutCloudEventHeaders(Processor delegate, CloudEvent ce) {
    return new DelegateAsyncProcessor(delegate) {
        @Override
        public boolean process(Exchange exchange, AsyncCallback callback) {
            return processor.process(exchange, doneSync -> {
                final Message message = exchange.getMessage();

                // remove CloudEvent headers
                for (CloudEvent.Attribute attr : ce.attributes()) {
                    message.removeHeader(attr.http());
                }

                callback.done(doneSync);
            });
        }
    };
}
 
Example #2
Source File: KnativeHttpSupport.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
/**
 * Remap camel headers to cloud event http headers.
 */
public static Processor remapCloudEventHeaders(Processor delegate, CloudEvent ce) {
    return new DelegateAsyncProcessor(delegate) {
        @Override
        public boolean process(Exchange exchange, AsyncCallback callback) {
            return processor.process(exchange, doneSync -> {
                final Message message = exchange.getMessage();

                // remap CloudEvent camel --> http
                for (CloudEvent.Attribute attr : ce.attributes()) {
                    Object value = message.getHeader(attr.id());
                    if (value != null) {
                        message.setHeader(attr.http(), value);
                    }
                }

                callback.done(doneSync);
            });
        }
    };
}