You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/05/05 11:10:24 UTC

[3/9] camel git commit: CAMEL-10807: Create camel-reactor component

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/support/ReactiveStreamsTestServiceFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/support/ReactiveStreamsTestServiceFactory.java b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/support/ReactiveStreamsTestServiceFactory.java
new file mode 100644
index 0000000..ddc362b
--- /dev/null
+++ b/components/camel-reactive-streams/src/test/java/org/apache/camel/component/reactive/streams/support/ReactiveStreamsTestServiceFactory.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.reactive.streams.support;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService;
+import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsServiceFactory;
+import org.apache.camel.component.reactive.streams.engine.ReactiveStreamsEngineConfiguration;
+
+public class ReactiveStreamsTestServiceFactory implements CamelReactiveStreamsServiceFactory {
+    /**
+     * Creates a new instance of the {@link ReactiveStreamsEngineConfiguration}
+     *
+     * @param context       the Camel context
+     * @param configuration the ReactiveStreams engine configuration
+     * @return the ReactiveStreams service
+     */
+    @Override
+    public CamelReactiveStreamsService newInstance(CamelContext context, ReactiveStreamsEngineConfiguration configuration) {
+        return new ReactiveStreamsTestService("test-service");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactive-streams/src/test/resources/META-INF/services/org/apache/camel/reactive-streams/test-service
----------------------------------------------------------------------
diff --git a/components/camel-reactive-streams/src/test/resources/META-INF/services/org/apache/camel/reactive-streams/test-service b/components/camel-reactive-streams/src/test/resources/META-INF/services/org/apache/camel/reactive-streams/test-service
index 03f7827..c4fa071 100644
--- a/components/camel-reactive-streams/src/test/resources/META-INF/services/org/apache/camel/reactive-streams/test-service
+++ b/components/camel-reactive-streams/src/test/resources/META-INF/services/org/apache/camel/reactive-streams/test-service
@@ -15,4 +15,4 @@
 # limitations under the License.
 #
 
-class=org.apache.camel.component.reactive.streams.support.ReactiveStreamsTestService
+class=org.apache.camel.component.reactive.streams.support.ReactiveStreamsTestServiceFactory

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-reactor/pom.xml b/components/camel-reactor/pom.xml
new file mode 100644
index 0000000..3eac932
--- /dev/null
+++ b/components/camel-reactor/pom.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>components</artifactId>
+        <version>2.20.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-reactor</artifactId>
+    <packaging>jar</packaging>
+    <name>Camel :: Reactor</name>
+    <description>Camel Reactor  Component</description>
+
+    <properties>
+        <camel.osgi.export.pkg>org.apache.camel.component.reactor.*</camel.osgi.export.pkg>
+        <!--
+        <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=reactor</camel.osgi.export.service>
+        -->
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-reactive-streams</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.reactivestreams</groupId>
+            <artifactId>reactive-streams</artifactId>
+            <version>${reactive-streams-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.projectreactor</groupId>
+            <artifactId>reactor-core</artifactId>
+            <version>${reactor-version}</version>
+        </dependency>
+
+        <!-- test dependencies -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-slf4j-impl</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>${mockito-version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorCamelProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorCamelProcessor.java b/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorCamelProcessor.java
new file mode 100644
index 0000000..35d2bdd
--- /dev/null
+++ b/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorCamelProcessor.java
@@ -0,0 +1,127 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.reactor.engine;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.reactive.streams.ReactiveStreamsBackpressureStrategy;
+import org.apache.camel.component.reactive.streams.ReactiveStreamsDiscardedException;
+import org.apache.camel.component.reactive.streams.ReactiveStreamsHelper;
+import org.apache.camel.component.reactive.streams.ReactiveStreamsProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.reactivestreams.Publisher;
+import reactor.core.publisher.DirectProcessor;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.FluxProcessor;
+import reactor.core.publisher.FluxSink;
+import reactor.core.publisher.SynchronousSink;
+import reactor.util.concurrent.QueueSupplier;
+
+final class ReactorCamelProcessor implements Closeable {
+    private final String name;
+    private final FluxProcessor<Exchange, Exchange> processor;
+    private final Flux<Exchange> processorFlux;
+    private final AtomicReference<FluxSink<Exchange>> camelSink;
+
+    private final ReactorStreamsService service;
+    private ReactiveStreamsProducer camelProducer;
+
+    ReactorCamelProcessor(ReactorStreamsService service, String name) {
+        this.service = service;
+        this.name = name;
+
+        this.camelProducer = null;
+        this.camelSink = new AtomicReference<>();
+
+        this.processor = DirectProcessor.create();
+
+        // As the processor can be shared among a number of subscribers we need
+        // to make it shared we can multicast events.
+        this.processorFlux = this.processor.handle(this::onItemEmitted).share();
+    }
+
+    @Override
+    public void close() throws IOException {
+    }
+
+    Publisher<Exchange> getPublisher() {
+        return processorFlux;
+    }
+
+    synchronized void attach(ReactiveStreamsProducer producer) {
+        Objects.requireNonNull(producer, "producer cannot be null, use the detach method");
+
+        if (this.camelProducer != null) {
+            throw new IllegalStateException("A producer is already attached to the stream '" + name + "'");
+        }
+
+        if (this.camelProducer != producer) {
+            detach();
+
+            ReactiveStreamsBackpressureStrategy strategy = producer.getEndpoint().getBackpressureStrategy();
+            Flux<Exchange> flux = Flux.create(camelSink::set);
+
+            if (ObjectHelper.equal(strategy, ReactiveStreamsBackpressureStrategy.OLDEST)) {
+                flux = flux.onBackpressureDrop(this::onBackPressure);
+            } else if (ObjectHelper.equal(strategy, ReactiveStreamsBackpressureStrategy.LATEST)) {
+                flux = flux.onBackpressureLatest();
+            } else {
+                // Default strategy is BUFFER
+                flux = flux.onBackpressureBuffer(QueueSupplier.SMALL_BUFFER_SIZE, this::onBackPressure);
+            }
+
+            flux.subscribe(this.processor);
+
+            camelProducer = producer;
+        }
+    }
+
+    synchronized void detach() {
+
+        this.camelProducer = null;
+        this.camelSink.set(null);
+    }
+
+    void send(Exchange exchange) {
+        if (service.isRunAllowed()) {
+            FluxSink<Exchange> sink = ObjectHelper.notNull(camelSink.get(), "FluxSink");
+            sink.next(exchange);
+        }
+    }
+
+    // **************************************
+    // Helpers
+    // **************************************
+
+    private void onItemEmitted(Exchange exchange, SynchronousSink<Exchange> sink) {
+        if (service.isRunAllowed()) {
+            sink.next(exchange);
+            ReactiveStreamsHelper.invokeDispatchCallback(exchange);
+        }
+    }
+
+    private void onBackPressure(Exchange exchange) {
+        ReactiveStreamsHelper.invokeDispatchCallback(
+            exchange,
+            new ReactiveStreamsDiscardedException("Discarded by back pressure strategy", exchange, name)
+        );
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorStreamsConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorStreamsConstants.java b/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorStreamsConstants.java
new file mode 100644
index 0000000..f301b87
--- /dev/null
+++ b/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorStreamsConstants.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.reactor.engine;
+
+import org.apache.camel.AsyncCallback;
+
+/**
+ * Useful constants used in the Camel Reactive Streams component.
+ */
+public final class ReactorStreamsConstants {
+    public static final String SERVICE_NAME =  "reactor";
+
+    /**
+     * An implementation of the {@link AsyncCallback} that does nothing.
+     */
+    public static final AsyncCallback EMPTY_ASYNC_CALLBACK = new AsyncCallback() {
+        @Override
+        public void done(boolean doneSync) {
+        }
+    };
+
+    private ReactorStreamsConstants() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorStreamsService.java
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorStreamsService.java b/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorStreamsService.java
new file mode 100644
index 0000000..6303c42
--- /dev/null
+++ b/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorStreamsService.java
@@ -0,0 +1,357 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.reactor.engine;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.reactive.streams.ReactiveStreamsConsumer;
+import org.apache.camel.component.reactive.streams.ReactiveStreamsHelper;
+import org.apache.camel.component.reactive.streams.ReactiveStreamsProducer;
+import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService;
+import org.apache.camel.component.reactive.streams.engine.CamelSubscriber;
+import org.apache.camel.component.reactive.streams.engine.ReactiveStreamsEngineConfiguration;
+import org.apache.camel.component.reactive.streams.util.BodyConverter;
+import org.apache.camel.component.reactive.streams.util.ConvertingPublisher;
+import org.apache.camel.component.reactive.streams.util.ConvertingSubscriber;
+import org.apache.camel.component.reactive.streams.util.UnwrapStreamProcessor;
+import org.apache.camel.spi.Synchronization;
+import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.function.Suppliers;
+import org.reactivestreams.Publisher;
+import org.reactivestreams.Subscriber;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+final class ReactorStreamsService extends ServiceSupport implements CamelReactiveStreamsService {
+    private final CamelContext context;
+    private final ReactiveStreamsEngineConfiguration configuration;
+    private final Supplier<UnwrapStreamProcessor> unwrapStreamProcessorSupplier;
+    private final ConcurrentMap<String, ReactorCamelProcessor> publishers;
+    private final ConcurrentMap<String, CamelSubscriber> subscribers;
+    private final ConcurrentMap<String, String> publishedUriToStream;
+    private final ConcurrentMap<String, String> requestedUriToStream;
+
+    private ExecutorService workerPool;
+
+    ReactorStreamsService(CamelContext context, ReactiveStreamsEngineConfiguration configuration) {
+        this.context = context;
+        this.configuration = configuration;
+        this.publishers = new ConcurrentHashMap<>();
+        this.subscribers = new ConcurrentHashMap<>();
+        this.publishedUriToStream = new ConcurrentHashMap<>();
+        this.requestedUriToStream = new ConcurrentHashMap<>();
+        this.unwrapStreamProcessorSupplier = Suppliers.memorize(UnwrapStreamProcessor::new);
+    }
+
+    @Override
+    public String getId() {
+        return ReactorStreamsConstants.SERVICE_NAME;
+    }
+
+    // ******************************************
+    // Lifecycle
+    // ******************************************
+
+    @Override
+    public void doStart() throws Exception {
+        this.workerPool = context.getExecutorServiceManager().newThreadPool(
+            this,
+            configuration.getThreadPoolName(),
+            configuration.getThreadPoolMinSize(),
+            configuration.getThreadPoolMaxSize()
+        );
+    }
+
+    @Override
+    public void doStop() throws Exception {
+        for (ReactorCamelProcessor processor : publishers.values()) {
+            processor.close();
+        }
+        for (CamelSubscriber subscriber : subscribers.values()) {
+            subscriber.close();
+        }
+
+        if (this.workerPool != null) {
+            this.context.getExecutorServiceManager().shutdownNow(this.workerPool);
+            this.workerPool = null;
+        }
+    }
+
+    // ******************************************
+    //
+    // ******************************************
+
+    @Override
+    public Publisher<Exchange> fromStream(String name) {
+        return getCamelProcessor(name).getPublisher();
+    }
+
+    @Override
+    public <T> Publisher<T> fromStream(String name, Class<T> type) {
+        final Publisher<Exchange> publisher = fromStream(name);
+
+        if (Exchange.class.isAssignableFrom(type)) {
+            return Publisher.class.cast(publisher);
+        }
+
+        return Flux.from(publisher).map(BodyConverter.forType(type));
+    }
+
+    @Override
+    public CamelSubscriber streamSubscriber(String name) {
+        return subscribers.computeIfAbsent(name, n -> new CamelSubscriber(name));
+    }
+
+    @SuppressWarnings("unchecked")
+    public <T> Subscriber<T> streamSubscriber(String name, Class<T> type) {
+        final Subscriber<Exchange> subscriber = streamSubscriber(name);
+
+        if (Exchange.class.equals(type)) {
+            return Subscriber.class.cast(subscriber);
+        }
+
+        return new ConvertingSubscriber<>(subscriber, context);
+    }
+
+    @Override
+    public Publisher<Exchange> toStream(String name, Object data) {
+        return doRequest(
+            name,
+            ReactiveStreamsHelper.convertToExchange(context, data)
+        );
+    }
+
+    @Override
+    public Function<?, ? extends Publisher<Exchange>> toStream(String name) {
+        return data -> toStream(name, data);
+    }
+
+    @Override
+    public <T> Publisher<T> toStream(String name, Object data, Class<T> type) {
+        return new ConvertingPublisher<>(toStream(name, data), type);
+    }
+
+    @Override
+    public <T> Function<Object, Publisher<T>> toStream(String name, Class<T> type) {
+        return data -> toStream(name, data, type);
+    }
+
+    @Override
+    public Publisher<Exchange> from(String uri) {
+        final String name = publishedUriToStream.computeIfAbsent(uri, camelUri -> {
+            try {
+                String uuid = context.getUuidGenerator().generateUuid();
+
+                context.addRoutes(new RouteBuilder() {
+                    @Override
+                    public void configure() throws Exception {
+                        from(camelUri).to("reactive-streams:" + uuid);
+                    }
+                });
+
+                return uuid;
+            } catch (Exception e) {
+                throw new IllegalStateException("Unable to create source reactive stream from direct URI: " + uri, e);
+            }
+        });
+
+        return fromStream(name);
+    }
+
+    @Override
+    public <T> Publisher<T> from(String name, Class<T> type) {
+        final Publisher<Exchange> publisher = from(name);
+
+        if (Exchange.class.isAssignableFrom(type)) {
+            return Publisher.class.cast(publisher);
+        }
+
+        return Flux.from(publisher).map(BodyConverter.forType(type));
+    }
+
+    @Override
+    public Subscriber<Exchange> subscriber(String uri) {
+        try {
+            String uuid = context.getUuidGenerator().generateUuid();
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    from("reactive-streams:" + uuid)
+                        .to(uri);
+                }
+            });
+
+            return streamSubscriber(uuid);
+        } catch (Exception e) {
+            throw new IllegalStateException("Unable to create source reactive stream towards direct URI: " + uri, e);
+        }
+    }
+
+    @Override
+    public <T> Subscriber<T> subscriber(String uri, Class<T> type) {
+        return new ConvertingSubscriber<>(subscriber(uri), context);
+    }
+
+    @Override
+    public Publisher<Exchange> to(String uri, Object data) {
+        String streamName = requestedUriToStream.computeIfAbsent(uri, camelUri -> {
+            try {
+                String uuid = context.getUuidGenerator().generateUuid();
+                context.addRoutes(new RouteBuilder() {
+                    @Override
+                    public void configure() throws Exception {
+                        from("reactive-streams:" + uuid)
+                            .to(camelUri);
+                    }
+                });
+
+                return uuid;
+            } catch (Exception e) {
+                throw new IllegalStateException("Unable to create requested reactive stream from direct URI: " + uri, e);
+            }
+        });
+
+        return toStream(streamName, data);
+    }
+
+    @Override
+    public Function<Object, Publisher<Exchange>> to(String uri) {
+        return data -> to(uri, data);
+    }
+
+    @Override
+    public <T> Publisher<T> to(String uri, Object data, Class<T> type) {
+        Publisher<Exchange> publisher = to(uri, data);
+
+        return Flux.from(publisher).map(BodyConverter.forType(type));
+    }
+
+    @Override
+    public <T> Function<Object, Publisher<T>> to(String uri, Class<T> type) {
+        return data -> to(uri, data, type);
+    }
+
+    @Override
+    public void process(String uri, Function<? super Publisher<Exchange>, ?> processor) {
+        try {
+            context.addRoutes(new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    from(uri)
+                        .process(exchange -> {
+                            Exchange copy = exchange.copy();
+                            Object result = processor.apply(Mono.just(copy));
+                            exchange.getIn().setBody(result);
+                        })
+                        .process(unwrapStreamProcessorSupplier.get());
+                }
+            });
+        } catch (Exception e) {
+            throw new IllegalStateException("Unable to add reactive stream processor to the direct URI: " + uri, e);
+        }
+    }
+
+    @Override
+    public <T> void process(String uri, Class<T> type, Function<? super Publisher<T>, ?> processor) {
+        process(
+            uri,
+            publisher -> processor.apply(
+                Flux.from(publisher).map(BodyConverter.forType(type))
+            )
+        );
+    }
+
+    // ******************************************
+    // Producer
+    // ******************************************
+
+    @Override
+    public void attachCamelProducer(String name, ReactiveStreamsProducer producer) {
+        getCamelProcessor(name).attach(producer);
+    }
+
+    @Override
+    public void detachCamelProducer(String name) {
+        getCamelProcessor(name).detach();
+    }
+
+    @Override
+    public void sendCamelExchange(String name, Exchange exchange) {
+        getCamelProcessor(name).send(exchange);
+    }
+
+    private ReactorCamelProcessor getCamelProcessor(String name) {
+        return publishers.computeIfAbsent(name, key -> new ReactorCamelProcessor(this, key));
+    }
+
+    // ******************************************
+    // Consumer
+    // ******************************************
+
+    @Override
+    public CamelSubscriber attachCamelConsumer(String name, ReactiveStreamsConsumer consumer) {
+        CamelSubscriber subscriber = streamSubscriber(name);
+        subscriber.attachConsumer(consumer);
+
+        return subscriber;
+    }
+
+    @Override
+    public void detachCamelConsumer(String name) {
+        CamelSubscriber subscriber = streamSubscriber(name);
+        subscriber.detachConsumer();
+    }
+
+    // *******************************************
+    // Helpers
+    // *******************************************
+
+    protected Publisher<Exchange> doRequest(String name, Exchange data) {
+        ReactiveStreamsConsumer consumer = streamSubscriber(name).getConsumer();
+        if (consumer == null) {
+            throw new IllegalStateException("No consumers attached to the stream " + name);
+        }
+
+        return Mono.<Exchange>create(
+            sink -> data.addOnCompletion(new Synchronization() {
+                @Override
+                public void onComplete(Exchange exchange) {
+                    sink.success(exchange);
+                }
+
+                @Override
+                public void onFailure(Exchange exchange) {
+                    Throwable throwable = exchange.getException();
+                    if (throwable == null) {
+                        throwable = new IllegalStateException("Unknown Exception");
+                    }
+
+                    sink.error(throwable);
+                }
+            })
+        ).doOnSubscribe(
+            subs -> consumer.process(data, ReactorStreamsConstants.EMPTY_ASYNC_CALLBACK)
+        );
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceFactory.java b/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceFactory.java
new file mode 100644
index 0000000..ae963d9
--- /dev/null
+++ b/components/camel-reactor/src/main/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceFactory.java
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.reactor.engine;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService;
+import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsServiceFactory;
+import org.apache.camel.component.reactive.streams.engine.ReactiveStreamsEngineConfiguration;
+
+public class ReactorStreamsServiceFactory implements CamelReactiveStreamsServiceFactory {
+    @Override
+    public CamelReactiveStreamsService newInstance(CamelContext context, ReactiveStreamsEngineConfiguration configuration) {
+        return new ReactorStreamsService(context, configuration);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/main/resources/META-INF/LICENSE.txt b/components/camel-reactor/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-reactor/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/main/resources/META-INF/NOTICE.txt b/components/camel-reactor/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-reactor/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/main/resources/META-INF/services/org/apache/camel/reactive-streams/reactor
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/main/resources/META-INF/services/org/apache/camel/reactive-streams/reactor b/components/camel-reactor/src/main/resources/META-INF/services/org/apache/camel/reactive-streams/reactor
new file mode 100644
index 0000000..8057c60
--- /dev/null
+++ b/components/camel-reactor/src/main/resources/META-INF/services/org/apache/camel/reactive-streams/reactor
@@ -0,0 +1,17 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+class=org.apache.camel.component.reactor.engine.ReactorStreamsServiceFactory
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceBackpressureTest.java
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceBackpressureTest.java b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceBackpressureTest.java
new file mode 100644
index 0000000..37671fc
--- /dev/null
+++ b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceBackpressureTest.java
@@ -0,0 +1,164 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.reactor.engine;
+
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.reactive.streams.ReactiveStreamsBackpressureStrategy;
+import org.apache.camel.component.reactor.engine.suport.TestSubscriber;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+import reactor.core.publisher.Flux;
+
+public class ReactorStreamsServiceBackpressureTest extends ReactorStreamsServiceTestSupport {
+
+    @Test
+    public void testBufferStrategy() throws Exception {
+        getReactiveStreamsComponent().setBackpressureStrategy(ReactiveStreamsBackpressureStrategy.BUFFER);
+
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("timer:gen?period=20&repeatCount=20")
+                    .setBody()
+                        .header(Exchange.TIMER_COUNTER)
+                    .to("reactive-streams:integers");
+            }
+        });
+
+        Flux<Integer> integers = Flux.from(crs.fromStream("integers", Integer.class));
+        ConcurrentLinkedQueue<Integer> queue = new ConcurrentLinkedQueue<>();
+        CountDownLatch latch = new CountDownLatch(1);
+
+        Flux.range(0, 50)
+            .zipWith(integers, (l, i) -> i)
+            .timeoutMillis(2000, Flux.empty())
+            .doOnComplete(latch::countDown)
+            .subscribe(queue::add);
+
+        context.start();
+
+        Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
+        Assert.assertEquals(20, queue.size());
+
+        int num = 1;
+        for (int i : queue) {
+            Assert.assertEquals(num++, i);
+        }
+    }
+
+    @Ignore
+    @Test
+    public void testDropStrategy() throws Exception {
+        getReactiveStreamsComponent().setBackpressureStrategy(ReactiveStreamsBackpressureStrategy.OLDEST);
+
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("timer:gen?period=20&repeatCount=20")
+                    .setBody()
+                        .header(Exchange.TIMER_COUNTER)
+                    .to("reactive-streams:integers");
+            }
+        });
+
+        final ConcurrentLinkedQueue<Integer> queue = new ConcurrentLinkedQueue<>();
+        final CountDownLatch latch = new CountDownLatch(1);
+        final CountDownLatch latch2 = new CountDownLatch(2);
+
+        TestSubscriber<Integer> subscriber = new TestSubscriber<Integer>() {
+            @Override
+            public void onNext(Integer o) {
+                queue.add(o);
+                latch.countDown();
+                latch2.countDown();
+            }
+        };
+
+        subscriber.setInitiallyRequested(1);
+
+        crs.fromStream("integers", Integer.class).subscribe(subscriber);
+        context.start();
+
+        Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
+        Thread.sleep(1000); // wait for all numbers to be generated
+
+        subscriber.request(19);
+        Assert.assertTrue(latch2.await(1, TimeUnit.SECONDS));
+
+        Thread.sleep(200); // add other time to ensure no other items arrive
+        Assert.assertEquals(2, queue.size());
+
+        int sum = queue.stream().reduce((i, j) -> i + j).get();
+        Assert.assertEquals(3, sum); // 1 + 2 = 3
+
+        subscriber.cancel();
+    }
+
+    @Ignore
+    @Test
+    public void testLatestStrategy() throws Exception {
+        getReactiveStreamsComponent().setBackpressureStrategy(ReactiveStreamsBackpressureStrategy.LATEST);
+
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("timer:gen?period=20&repeatCount=20")
+                    .setBody()
+                        .header(Exchange.TIMER_COUNTER)
+                    .to("reactive-streams:integers");
+            }
+        });
+
+        final ConcurrentLinkedQueue<Integer> queue = new ConcurrentLinkedQueue<>();
+        final CountDownLatch latch1 = new CountDownLatch(1);
+        final CountDownLatch latch2 = new CountDownLatch(2);
+
+        TestSubscriber<Integer> subscriber = new TestSubscriber<Integer>() {
+            @Override
+            public void onNext(Integer o) {
+                queue.add(o);
+                latch1.countDown();
+                latch2.countDown();
+            }
+        };
+
+        subscriber.setInitiallyRequested(1);
+
+        crs.fromStream("integers", Integer.class).subscribe(subscriber);
+        context.start();
+
+        Assert.assertTrue(latch1.await(5, TimeUnit.SECONDS));
+        Thread.sleep(1000); // wait for all numbers to be generated
+
+        subscriber.request(19);
+        Assert.assertTrue(latch2.await(1, TimeUnit.SECONDS));
+
+        Thread.sleep(200); // add other time to ensure no other items arrive
+        Assert.assertEquals(2, queue.size());
+
+        int sum = queue.stream().reduce((i, j) -> i + j).get();
+        Assert.assertEquals(21, sum); // 1 + 20 = 21
+
+        subscriber.cancel();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceEventTypeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceEventTypeTest.java b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceEventTypeTest.java
new file mode 100644
index 0000000..a12813c
--- /dev/null
+++ b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceEventTypeTest.java
@@ -0,0 +1,164 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.reactor.engine;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.reactive.streams.ReactiveStreamsConstants;
+import org.junit.Assert;
+import org.junit.Test;
+import org.reactivestreams.Subscriber;
+import reactor.core.publisher.Flux;
+
+public class ReactorStreamsServiceEventTypeTest extends ReactorStreamsServiceTestSupport {
+
+    @Test
+    public void testOnCompleteHeaderForwarded() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("reactive-streams:numbers?forwardOnComplete=true")
+                    .to("mock:endpoint");
+            }
+        });
+
+        Subscriber<Integer> numbers = crs.streamSubscriber("numbers", Integer.class);
+
+        context.start();
+
+        Flux.<Integer>empty().subscribe(numbers);
+
+        MockEndpoint endpoint = getMockEndpoint("mock:endpoint");
+        endpoint.expectedMessageCount(1);
+        endpoint.expectedHeaderReceived(ReactiveStreamsConstants.REACTIVE_STREAMS_EVENT_TYPE, "onComplete");
+        endpoint.expectedBodiesReceived(new Object[]{null});
+        endpoint.assertIsSatisfied();
+    }
+
+    @Test
+    public void testOnCompleteHeaderNotForwarded() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("reactive-streams:numbers")
+                    .to("mock:endpoint");
+            }
+        });
+
+        Subscriber<Integer> numbers = crs.streamSubscriber("numbers", Integer.class);
+
+        context.start();
+
+        Flux.<Integer>empty().subscribe(numbers);
+
+        MockEndpoint endpoint = getMockEndpoint("mock:endpoint");
+        endpoint.expectedMessageCount(0);
+        endpoint.assertIsSatisfied(200);
+    }
+
+    @Test
+    public void testOnNextHeaderForwarded() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("reactive-streams:numbers")
+                    .to("mock:endpoint");
+            }
+        });
+
+        Subscriber<Integer> numbers = crs.streamSubscriber("numbers", Integer.class);
+
+        context.start();
+
+        Flux.just(1).subscribe(numbers);
+
+        MockEndpoint endpoint = getMockEndpoint("mock:endpoint");
+        endpoint.expectedHeaderReceived(ReactiveStreamsConstants.REACTIVE_STREAMS_EVENT_TYPE, "onNext");
+        endpoint.expectedMessageCount(1);
+        endpoint.assertIsSatisfied();
+
+        Exchange ex = endpoint.getExchanges().get(0);
+        Assert.assertEquals(1, ex.getIn().getBody());
+    }
+
+    @Test
+    public void testOnErrorHeaderForwarded() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("reactive-streams:numbers?forwardOnError=true")
+                    .to("mock:endpoint");
+            }
+        });
+
+        Subscriber<Integer> numbers = crs.streamSubscriber("numbers", Integer.class);
+
+        context.start();
+
+        RuntimeException ex = new RuntimeException("1");
+
+        Flux.just(1)
+            .map(n -> {
+                if (n == 1) {
+                    throw ex;
+                }
+                return n;
+            })
+            .subscribe(numbers);
+
+
+        MockEndpoint endpoint = getMockEndpoint("mock:endpoint");
+        endpoint.expectedMessageCount(1);
+        endpoint.expectedHeaderReceived(ReactiveStreamsConstants.REACTIVE_STREAMS_EVENT_TYPE, "onError");
+        endpoint.assertIsSatisfied();
+
+        Exchange exch = endpoint.getExchanges().get(0);
+        Assert.assertEquals(ex, exch.getIn().getBody());
+    }
+
+    @Test
+    public void testOnErrorHeaderNotForwarded() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("reactive-streams:numbers")
+                    .to("mock:endpoint");
+            }
+        });
+
+        Subscriber<Integer> numbers = crs.streamSubscriber("numbers", Integer.class);
+
+        context.start();
+
+        RuntimeException ex = new RuntimeException("1");
+
+        Flux.just(1)
+            .map(n -> {
+                if (n == 1) {
+                    throw ex;
+                }
+                return n;
+            })
+            .subscribe(numbers);
+
+
+        MockEndpoint endpoint = getMockEndpoint("mock:endpoint");
+        endpoint.expectedMessageCount(0);
+        endpoint.assertIsSatisfied(200);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceSubscriberTest.java
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceSubscriberTest.java b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceSubscriberTest.java
new file mode 100644
index 0000000..94e8007
--- /dev/null
+++ b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceSubscriberTest.java
@@ -0,0 +1,150 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.reactor.engine;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Assert;
+import org.junit.Test;
+import org.reactivestreams.Publisher;
+import org.reactivestreams.Subscriber;
+import reactor.core.publisher.Flux;
+
+public class ReactorStreamsServiceSubscriberTest extends ReactorStreamsServiceTestSupport {
+    @Test
+    public void testSubscriber() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("reactive-streams:sub1")
+                    .to("mock:sub1");
+                from("reactive-streams:sub2")
+                    .to("mock:sub2");
+                from("timer:tick?period=50")
+                    .setBody()
+                        .simple("random(500)")
+                    .to("mock:sub3")
+                    .to("reactive-streams:pub");
+            }
+        });
+
+        Subscriber<Integer> sub1 = crs.streamSubscriber("sub1", Integer.class);
+        Subscriber<Integer> sub2 = crs.streamSubscriber("sub2", Integer.class);
+        Publisher<Integer> pub = crs.fromStream("pub", Integer.class);
+
+        pub.subscribe(sub1);
+        pub.subscribe(sub2);
+
+        context.start();
+
+        int count = 2;
+
+        MockEndpoint e1 = getMockEndpoint("mock:sub1");
+        e1.expectedMinimumMessageCount(count);
+        e1.assertIsSatisfied();
+
+        MockEndpoint e2 = getMockEndpoint("mock:sub2");
+        e2.expectedMinimumMessageCount(count);
+        e2.assertIsSatisfied();
+
+        MockEndpoint e3 = getMockEndpoint("mock:sub3");
+        e3.expectedMinimumMessageCount(count);
+        e3.assertIsSatisfied();
+
+        for (int i = 0; i < count; i++) {
+            Exchange ex1 = e1.getExchanges().get(i);
+            Exchange ex2 = e2.getExchanges().get(i);
+            Exchange ex3 = e3.getExchanges().get(i);
+
+            assertEquals(ex1.getIn().getBody(), ex2.getIn().getBody());
+            assertEquals(ex1.getIn().getBody(), ex3.getIn().getBody());
+        }
+    }
+
+    @Test
+    public void testSingleConsumer() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("reactive-streams:singleConsumer")
+                    .process()
+                        .message(m -> m.setHeader("thread", Thread.currentThread().getId()))
+                    .to("mock:singleBucket");
+            }
+        });
+
+        context.start();
+
+        Flux.range(0, 1000).subscribe(
+            crs.streamSubscriber("singleConsumer", Number.class)
+        );
+
+        MockEndpoint endpoint = getMockEndpoint("mock:singleBucket");
+        endpoint.expectedMessageCount(1000);
+        endpoint.assertIsSatisfied();
+
+        Assert.assertEquals(
+            1,
+            endpoint.getExchanges().stream()
+                .map(x -> x.getIn().getHeader("thread", String.class))
+                .distinct()
+                .count()
+        );
+
+        // Ensure order is preserved when using a single consumer
+        AtomicLong num = new AtomicLong(0);
+
+        endpoint.getExchanges().stream()
+            .map(x -> x.getIn().getBody(Long.class))
+            .forEach(n -> Assert.assertEquals(num.getAndIncrement(), n.longValue()));
+    }
+
+    @Test
+    public void testMultipleConsumers() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("reactive-streams:multipleConsumers?concurrentConsumers=3")
+                    .process()
+                        .message(m -> m.setHeader("thread", Thread.currentThread().getId()))
+                    .to("mock:multipleBucket");
+            }
+        });
+
+        context.start();
+
+        Flux.range(0, 1000).subscribe(
+            crs.streamSubscriber("multipleConsumers", Number.class)
+        );
+
+        MockEndpoint endpoint = getMockEndpoint("mock:multipleBucket");
+        endpoint.expectedMessageCount(1000);
+        endpoint.assertIsSatisfied();
+
+        Assert.assertEquals(
+            3,
+            endpoint.getExchanges().stream()
+                .map(x -> x.getIn().getHeader("thread", String.class))
+                .distinct()
+                .count()
+        );
+        // Order cannot be preserved when using multiple consumers
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceTest.java
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceTest.java b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceTest.java
new file mode 100644
index 0000000..19a1f5c
--- /dev/null
+++ b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceTest.java
@@ -0,0 +1,402 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.reactor.engine;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Function;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.util.ExchangeHelper;
+import org.junit.Assert;
+import org.junit.Test;
+import org.reactivestreams.Publisher;
+import reactor.core.Disposable;
+import reactor.core.publisher.Flux;
+
+public class ReactorStreamsServiceTest extends ReactorStreamsServiceTestSupport {
+    
+    // ************************************************
+    // Setup
+    // ************************************************
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("hello", new SampleBean());
+
+        return registry;
+    }
+
+    public static class SampleBean {
+        public String hello(String name) {
+            return "Hello " + name;
+        }
+    }
+
+    // ************************************************
+    // fromStream/from
+    // ************************************************
+
+    @Test
+    public void testFromStreamDirect() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                from("direct:reactive")
+                    .to("reactive-streams:numbers");
+            }
+        });
+
+        context.start();
+        ProducerTemplate template = context.createProducerTemplate();
+
+        AtomicInteger value = new AtomicInteger(0);
+
+        Flux.from(crs.fromStream("numbers", Integer.class))
+            .doOnNext(res -> Assert.assertEquals(value.incrementAndGet(), res.intValue()))
+            .subscribe();
+
+        template.sendBody("direct:reactive", 1);
+        template.sendBody("direct:reactive", 2);
+        template.sendBody("direct:reactive", 3);
+    }
+
+    @Test
+    public void testFromStreamTimer() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("timer:tick?period=5&repeatCount=30")
+                    .setBody()
+                        .header(Exchange.TIMER_COUNTER)
+                    .to("reactive-streams:tick");
+            }
+        });
+
+        final int num = 30;
+        final CountDownLatch latch = new CountDownLatch(num);
+        final AtomicInteger value = new AtomicInteger(0);
+
+        Flux.from(crs.fromStream("tick", Integer.class))
+            .doOnNext(res -> Assert.assertEquals(value.incrementAndGet(), res.intValue()))
+            .doOnNext(n -> latch.countDown())
+            .subscribe();
+
+        context.start();
+
+        latch.await(5, TimeUnit.SECONDS);
+
+        Assert.assertEquals(num, value.get());
+    }
+
+    @Test
+    public void testFromStreamMultipleSubscriptionsWithDirect() throws Exception {
+        context.start();
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:reactive")
+                    .to("reactive-streams:direct");
+            }
+        });
+
+        CountDownLatch latch1 = new CountDownLatch(2);
+        Flux.from(crs.fromStream("direct", Integer.class))
+            .doOnNext(res -> latch1.countDown())
+            .subscribe();
+
+        CountDownLatch latch2 = new CountDownLatch(2);
+        Flux.from(crs.fromStream("direct", Integer.class))
+            .doOnNext(res -> latch2.countDown())
+            .subscribe();
+
+        template.sendBody("direct:reactive", 1);
+        template.sendBody("direct:reactive", 2);
+
+        Assert.assertTrue(latch1.await(5, TimeUnit.SECONDS));
+        Assert.assertTrue(latch2.await(5, TimeUnit.SECONDS));
+    }
+
+    @Test
+    public void testMultipleSubscriptionsWithTimer() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("timer:tick?period=50")
+                    .setBody().header(Exchange.TIMER_COUNTER)
+                    .to("reactive-streams:tick");
+            }
+        });
+
+        CountDownLatch latch1 = new CountDownLatch(5);
+        Disposable disp1 = Flux.from(crs.fromStream("tick", Integer.class)).subscribe(res -> latch1.countDown());
+
+        context.start();
+
+        // Add another subscription
+        CountDownLatch latch2 = new CountDownLatch(5);
+        Disposable disp2 = Flux.from(crs.fromStream("tick", Integer.class)).subscribe(res -> latch2.countDown());
+
+        assertTrue(latch1.await(5, TimeUnit.SECONDS));
+        assertTrue(latch2.await(5, TimeUnit.SECONDS));
+
+        // Un subscribe both
+        disp1.dispose();
+        disp2.dispose();
+
+        // No active subscriptions, warnings expected
+        Thread.sleep(60);
+
+        // Add another subscription
+        CountDownLatch latch3 = new CountDownLatch(5);
+        Disposable disp3 = Flux.from(crs.fromStream("tick", Integer.class)).subscribe(res -> latch3.countDown());
+
+        assertTrue(latch3.await(5, TimeUnit.SECONDS));
+        disp3.dispose();
+    }
+
+    @Test
+    public void testFrom() throws Exception {
+        context.start();
+
+        Publisher<Exchange> timer = crs.from("timer:reactive?period=250&repeatCount=3");
+
+        AtomicInteger value = new AtomicInteger(0);
+        CountDownLatch latch = new CountDownLatch(3);
+
+        Flux.from(timer)
+            .map(exchange -> ExchangeHelper.getHeaderOrProperty(exchange, Exchange.TIMER_COUNTER, Integer.class))
+            .doOnNext(res -> Assert.assertEquals(value.incrementAndGet(), res.intValue()))
+            .doOnNext(res -> latch.countDown())
+            .subscribe();
+
+        Assert.assertTrue(latch.await(2, TimeUnit.SECONDS));
+    }
+
+    // ************************************************
+    // fromPublisher
+    // ************************************************
+
+    @Test
+    public void testFromPublisher() throws Exception {
+        context.start();
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:source")
+                    .to("direct:stream")
+                    .setBody()
+                        .simple("after stream: ${body}");
+            }
+        });
+
+        crs.process("direct:stream",
+            publisher ->
+                Flux.from(publisher)
+                    .map(e -> {
+                        int i = e.getIn().getBody(Integer.class);
+                        e.getOut().setBody(-i);
+
+                        return e;
+                    }
+                )
+        );
+
+        for (int i = 1; i <= 3; i++) {
+            Assert.assertEquals(
+                "after stream: " + (-i),
+                template.requestBody("direct:source", i, String.class)
+            );
+        }
+    }
+
+    @Test
+    public void testFromPublisherWithConversion() throws Exception {
+        context.start();
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:source")
+                    .to("direct:stream")
+                    .setBody()
+                        .simple("after stream: ${body}");
+            }
+        });
+
+        crs.process("direct:stream",
+            Integer.class,
+            publisher ->
+                Flux.from(publisher).map(Math::negateExact)
+        );
+
+        for (int i = 1; i <= 3; i++) {
+            Assert.assertEquals(
+                "after stream: " + (-i),
+                template.requestBody("direct:source", i, String.class)
+            );
+        }
+    }
+
+    // ************************************************
+    // toStream/to
+    // ************************************************
+
+    @Test
+    public void testToStream() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                from("reactive-streams:reactive")
+                    .setBody().constant("123");
+            }
+        });
+
+        context.start();
+
+        Publisher<Exchange> publisher = crs.toStream("reactive", new DefaultExchange(context));
+        Exchange res = Flux.from(publisher).blockFirst();
+
+        Assert.assertNotNull(res);
+
+        String content = res.getIn().getBody(String.class);
+
+        Assert.assertNotNull(content);
+        Assert.assertEquals("123", content);
+    }
+
+    @Test
+    public void testTo() throws Exception {
+        context.start();
+
+        AtomicInteger value = new AtomicInteger(0);
+        CountDownLatch latch = new CountDownLatch(1);
+
+        Flux.just(1, 2, 3)
+            .flatMap(e -> crs.to("bean:hello", e, String.class))
+            .doOnNext(res -> Assert.assertEquals("Hello " + value.incrementAndGet(), res))
+            .doOnNext(res -> latch.countDown())
+            .subscribe();
+
+        Assert.assertTrue(latch.await(2, TimeUnit.SECONDS));
+    }
+
+    @Test
+    public void testToWithExchange() throws Exception {
+        context.start();
+
+        AtomicInteger value = new AtomicInteger(0);
+        CountDownLatch latch = new CountDownLatch(1);
+
+        Flux.just(1, 2, 3)
+            .flatMap(e -> crs.to("bean:hello", e))
+            .map(e -> e.getOut())
+            .map(e -> e.getBody(String.class))
+            .doOnNext(res -> Assert.assertEquals("Hello " + value.incrementAndGet(), res))
+            .doOnNext(res -> latch.countDown())
+            .subscribe();
+
+        Assert.assertTrue(latch.await(2, TimeUnit.SECONDS));
+    }
+
+    @Test
+    public void testToFunction() throws Exception {
+        context.start();
+
+        AtomicInteger value = new AtomicInteger(0);
+        CountDownLatch latch = new CountDownLatch(1);
+        Function<Object, Publisher<String>> fun = crs.to("bean:hello", String.class);
+
+        Flux.just(1, 2, 3)
+            .flatMap(fun)
+            .doOnNext(res -> Assert.assertEquals("Hello " + value.incrementAndGet(), res))
+            .doOnNext(res -> latch.countDown())
+            .subscribe();
+
+        Assert.assertTrue(latch.await(2, TimeUnit.SECONDS));
+    }
+
+    @Test
+    public void testToFunctionWithExchange() throws Exception {
+        context.start();
+
+        AtomicInteger value = new AtomicInteger(0);
+        CountDownLatch latch = new CountDownLatch(1);
+        Function<Object, Publisher<Exchange>> fun = crs.to("bean:hello");
+
+        Flux.just(1, 2, 3)
+            .flatMap(fun)
+            .map(e -> e.getOut())
+            .map(e -> e.getBody(String.class))
+            .doOnNext(res -> Assert.assertEquals("Hello " + value.incrementAndGet(), res))
+            .doOnNext(res -> latch.countDown())
+            .subscribe();
+
+        Assert.assertTrue(latch.await(2, TimeUnit.SECONDS));
+    }
+
+    // ************************************************
+    // subscriber
+    // ************************************************
+
+    @Test
+    public void testSubscriber() throws Exception {
+        context.start();
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:reactor")
+                    .to("mock:result");
+            }
+        });
+
+        Flux.just(1, 2, 3)
+            .subscribe(crs.subscriber("direct:reactor", Integer.class));
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(3);
+        mock.assertIsSatisfied();
+
+        int idx = 1;
+        for (Exchange ex : mock.getExchanges()) {
+            Assert.assertEquals(new Integer(idx++), ex.getIn().getBody(Integer.class));
+        }
+    }
+
+    // ************************************************
+    // misc
+    // ************************************************
+
+    @Test(expected = IllegalStateException.class)
+    public void testOnlyOneCamelProducerPerPublisher() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:one")
+                    .to("reactive-streams:stream");
+                from("direct:two")
+                    .to("reactive-streams:stream");
+            }
+        });
+
+        context.start();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceTestSupport.java b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceTestSupport.java
new file mode 100644
index 0000000..e4e11f7
--- /dev/null
+++ b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/ReactorStreamsServiceTestSupport.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.reactor.engine;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.reactive.streams.ReactiveStreamsComponent;
+import org.apache.camel.component.reactive.streams.ReactiveStreamsConstants;
+import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams;
+import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ObjectHelper;
+
+class ReactorStreamsServiceTestSupport extends CamelTestSupport {
+    protected CamelReactiveStreamsService crs;
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+
+        context.addComponent(
+            ReactiveStreamsConstants.SCHEME,
+            ReactiveStreamsComponent.withServiceType(ReactorStreamsConstants.SERVICE_NAME)
+        );
+
+        return context;
+    }
+
+    @Override
+    protected void doPostSetup() throws Exception {
+        this.crs = CamelReactiveStreams.get(context);
+    }
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        // You need to start the context if "use route builder" is set to false
+        return false;
+    }
+
+    protected ReactiveStreamsComponent getReactiveStreamsComponent() {
+        return ObjectHelper.notNull(
+            context.getComponent(ReactiveStreamsConstants.SCHEME, ReactiveStreamsComponent.class),
+            ReactiveStreamsConstants.SCHEME
+        );
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/suport/TestSubscriber.java
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/suport/TestSubscriber.java b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/suport/TestSubscriber.java
new file mode 100644
index 0000000..d87dc96
--- /dev/null
+++ b/components/camel-reactor/src/test/java/org/apache/camel/component/reactor/engine/suport/TestSubscriber.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.reactor.engine.suport;
+
+import org.reactivestreams.Subscriber;
+import org.reactivestreams.Subscription;
+
+/**
+ * A subscriber for tests.
+ */
+public class TestSubscriber<T> implements Subscriber<T> {
+
+    protected Subscription subscription;
+
+    private long initiallyRequested;
+
+    public TestSubscriber() {
+    }
+
+    public long getInitiallyRequested() {
+        return initiallyRequested;
+    }
+
+    public void setInitiallyRequested(long initiallyRequested) {
+        this.initiallyRequested = initiallyRequested;
+    }
+
+    public void request(long exchanges) {
+        this.subscription.request(exchanges);
+    }
+
+    public void cancel() {
+        this.subscription.cancel();
+    }
+
+    @Override
+    public void onSubscribe(Subscription subscription) {
+        this.subscription = subscription;
+
+        if (initiallyRequested > 0) {
+            subscription.request(initiallyRequested);
+        }
+    }
+
+    @Override
+    public void onNext(T t) {
+
+    }
+
+    @Override
+    public void onError(Throwable throwable) {
+
+    }
+
+    @Override
+    public void onComplete() {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/camel-reactor/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/components/camel-reactor/src/test/resources/log4j2.properties b/components/camel-reactor/src/test/resources/log4j2.properties
new file mode 100644
index 0000000..fbab18c
--- /dev/null
+++ b/components/camel-reactor/src/test/resources/log4j2.properties
@@ -0,0 +1,33 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-reactive-streams-test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.stdout.type = Console
+appender.stdout.name = stdout
+appender.stdout.layout.type = PatternLayout
+appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file
+
+#rootLogger.appenderRef.stdout.ref = stdout
+#logger.debug.name = org.apache.camel.component.reactive.streams
+#logger.debug.level = DEBUG
+#logger.debug.additivity = true

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index 1449ba0..30412e7 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -226,6 +226,7 @@
     <module>camel-quickfix</module>
     <module>camel-rabbitmq</module>
     <module>camel-reactive-streams</module>
+    <module>camel-reactor</module>
     <module>camel-rest-swagger</module>
     <module>camel-restlet</module>
     <module>camel-rmi</module>

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/components/readme.adoc
----------------------------------------------------------------------
diff --git a/components/readme.adoc b/components/readme.adoc
index b13f816..8b29ef2 100644
--- a/components/readme.adoc
+++ b/components/readme.adoc
@@ -894,7 +894,7 @@ Miscellaneous Components
 ^^^^^^^^^^^^^^^^^^^^^^^^
 
 // others: START
-Number of Miscellaneous Components: 36 in 36 JAR artifacts (14 deprecated)
+Number of Miscellaneous Components: 37 in 37 JAR artifacts (14 deprecated)
 
 [width="100%",cols="4,1,5",options="header"]
 |=======================================================================
@@ -926,6 +926,8 @@ Number of Miscellaneous Components: 36 in 36 JAR artifacts (14 deprecated)
 
 | link:camel-opentracing/src/main/docs/opentracing.adoc[OpenTracing] (camel-opentracing) | 2.19 | Distributed tracing using OpenTracing
 
+| link:camel-reactor/src/main/docs/reactor.adoc[Reactor] (camel-reactor) |  | Camel Reactor  Component
+
 | link:camel-ribbon/src/main/docs/ribbon.adoc[Ribbon] (camel-ribbon) | 2.18 | Using Netflix Ribbon for client side load balancing
 
 | link:camel-ruby/src/main/docs/ruby.adoc[Ruby] (camel-ruby) | 1.0 | *deprecated* Camel Ruby DSL

http://git-wip-us.apache.org/repos/asf/camel/blob/1ca43e41/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index c0787de..5ffcb5b 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -357,6 +357,7 @@
 	* [Kura](kura.adoc)
 	* [LevelDB](leveldb.adoc)
 	* [OpenTracing](opentracing.adoc)
+	* [Reactor](reactor.adoc)
 	* [Ribbon](ribbon.adoc)
 	* [Ruby](ruby.adoc)
 	* [RX](rx.adoc)