You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/07/15 07:09:54 UTC

[1/4] camel git commit: CAMEL-10133 - Use lumberjack for SSL too, remove lumberjacks

Repository: camel
Updated Branches:
  refs/heads/master 920a88d2c -> f496aac76


CAMEL-10133 - Use lumberjack for SSL too, remove lumberjacks


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/12dcc564
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/12dcc564
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/12dcc564

Branch: refs/heads/master
Commit: 12dcc564673c26b49102876f1e075db7ac944f1c
Parents: 3d0379d
Author: Antoine DESSAIGNE <an...@gmail.com>
Authored: Mon Jul 11 10:24:09 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jul 15 08:59:27 2016 +0200

----------------------------------------------------------------------
 .../src/main/docs/lumberjack.adoc               |   6 +-
 .../lumberjack/LumberjackComponent.java         |   9 +-
 .../lumberjack/LumberjackConsumer.java          |   2 +-
 .../lumberjack/LumberjackEndpoint.java          |  25 +++--
 .../lumberjack/LumberjacksComponent.java        |  31 ------
 .../lumberjack/LumberjacksEndpoint.java         |  45 --------
 .../org/apache/camel/component/lumberjacks      |  17 ---
 .../lumberjack/LumberjackComponentSSLTest.java  | 109 +++++++++++++++++++
 .../lumberjack/LumberjackComponentTest.java     |   2 +-
 .../lumberjack/LumberjacksComponentTest.java    | 109 -------------------
 docs/user-manual/en/SUMMARY.md                  |   1 +
 11 files changed, 137 insertions(+), 219 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/12dcc564/components/camel-lumberjack/src/main/docs/lumberjack.adoc
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/docs/lumberjack.adoc b/components/camel-lumberjack/src/main/docs/lumberjack.adoc
index 51c2fca..8d87a21 100644
--- a/components/camel-lumberjack/src/main/docs/lumberjack.adoc
+++ b/components/camel-lumberjack/src/main/docs/lumberjack.adoc
@@ -30,7 +30,6 @@ URI format
 ------------------------------------
 lumberjack:host
 lumberjack:host:port
-lumberjacks:host:port?sslContextParameters=#ssl
 ------------------------------------
 
 You can append query options to the URI in the following format,
@@ -47,8 +46,9 @@ The Lumberjack component has no options.
 
 
 
+
 // endpoint options: START
-The Lumberjack component supports 6 endpoint options which are listed below:
+The Lumberjack component supports 7 endpoint options which are listed below:
 
 {% raw %}
 [width="100%",cols="2s,1,1m,1m,5",options="header"]
@@ -56,6 +56,7 @@ The Lumberjack component supports 6 endpoint options which are listed below:
 | Name | Group | Default | Java Type | Description
 | host | common |  | String | *Required* Network interface on which to listen for Lumberjack
 | port | common | 5044 | int | Network port on which to listen for Lumberjack
+| sslContextParameters | common |  | SSLContextParameters | SSL configuration
 | bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored.
 | exceptionHandler | consumer (advanced) |  | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
 | exchangePattern | advanced | InOnly | ExchangePattern | Sets the default exchange pattern when creating an exchange
@@ -66,6 +67,7 @@ The Lumberjack component supports 6 endpoint options which are listed below:
 
 
 
+
 [[Lumberjack-Result]]
 Result
 ^^^^^^

http://git-wip-us.apache.org/repos/asf/camel/blob/12dcc564/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java
index 1cb9dda..83e9e4e 100644
--- a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java
@@ -24,7 +24,7 @@ import org.apache.camel.impl.UriEndpointComponent;
 /**
  * The class is the Camel component for the Lumberjack server
  */
-public class LumberjackComponent extends UriEndpointComponent {
+public final class LumberjackComponent extends UriEndpointComponent {
     static final int DEFAULT_PORT = 5044;
 
     public LumberjackComponent() {
@@ -49,12 +49,9 @@ public class LumberjackComponent extends UriEndpointComponent {
             port = DEFAULT_PORT;
         }
 
-        Endpoint answer = createEndpoint(uri, host, port);
+        // Create the endpoint
+        Endpoint answer = new LumberjackEndpoint(uri, this, host, port);
         setProperties(answer, parameters);
         return answer;
     }
-
-    protected LumberjackEndpoint createEndpoint(String uri, String host, int port) {
-        return new LumberjackEndpoint(uri, this, host, port);
-    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/12dcc564/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java
index affdaaf..fd3fc78 100644
--- a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java
@@ -26,7 +26,7 @@ import org.apache.camel.component.lumberjack.io.LumberjackServer;
 import org.apache.camel.impl.DefaultConsumer;
 import org.apache.camel.util.concurrent.CamelThreadFactory;
 
-class LumberjackConsumer extends DefaultConsumer {
+final class LumberjackConsumer extends DefaultConsumer {
     private final LumberjackServer lumberjackServer;
 
     LumberjackConsumer(LumberjackEndpoint endpoint, Processor processor, String host, int port, SSLContext sslContext) {

http://git-wip-us.apache.org/repos/asf/camel/blob/12dcc564/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java
index 0b0d37e..0db9dbd 100644
--- a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java
@@ -5,9 +5,9 @@
  * 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
- *
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
  * 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.
@@ -16,20 +16,26 @@
  */
 package org.apache.camel.component.lumberjack;
 
+import javax.net.ssl.SSLContext;
+
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
+import org.apache.camel.util.jsse.SSLContextParameters;
 
 @UriEndpoint(scheme = "lumberjack", title = "Lumberjack", syntax = "lumberjack:host:port", consumerClass = LumberjackConsumer.class, label = "log")
-class LumberjackEndpoint extends DefaultEndpoint {
+final class LumberjackEndpoint extends DefaultEndpoint {
     @UriPath(description = "Network interface on which to listen for Lumberjack")
     @Metadata(required = "true")
-    final String host;
+    private final String host;
     @UriPath(description = "Network port on which to listen for Lumberjack", defaultValue = "" + LumberjackComponent.DEFAULT_PORT)
-    final int port;
+    private final int port;
+    @UriParam(description = "SSL configuration")
+    private SSLContextParameters sslContextParameters;
 
     LumberjackEndpoint(String endpointUri, LumberjackComponent component, String host, int port) {
         super(endpointUri, component);
@@ -44,11 +50,16 @@ class LumberjackEndpoint extends DefaultEndpoint {
 
     @Override
     public LumberjackConsumer createConsumer(Processor processor) throws Exception {
-        return new LumberjackConsumer(this, processor, host, port, null);
+        SSLContext sslContext = sslContextParameters != null ? sslContextParameters.createSSLContext(getCamelContext()) : null;
+        return new LumberjackConsumer(this, processor, host, port, sslContext);
     }
 
     @Override
     public boolean isSingleton() {
         return true;
     }
+
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/12dcc564/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksComponent.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksComponent.java
deleted file mode 100644
index 3d5bfb2..0000000
--- a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksComponent.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.lumberjack;
-
-/**
- * The class is the Camel component for the Lumberjack server with SSL
- */
-public class LumberjacksComponent extends LumberjackComponent {
-    public LumberjacksComponent() {
-        super(LumberjacksEndpoint.class);
-    }
-
-    @Override
-    protected LumberjacksEndpoint createEndpoint(String uri, String host, int port) {
-        return new LumberjacksEndpoint(uri, this, host, port);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/12dcc564/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksEndpoint.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksEndpoint.java
deleted file mode 100644
index db02d3b..0000000
--- a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksEndpoint.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.lumberjack;
-
-import org.apache.camel.Processor;
-import org.apache.camel.spi.UriEndpoint;
-import org.apache.camel.spi.UriParam;
-import org.apache.camel.util.jsse.SSLContextParameters;
-
-@UriEndpoint(scheme = "lumberjacks", title = "Lumberjacks", syntax = "lumberjacks:host:port", consumerClass = LumberjackConsumer.class, label = "log")
-class LumberjacksEndpoint extends LumberjackEndpoint {
-    @UriParam(description = "SSL configuration")
-    private SSLContextParameters sslContextParameters;
-
-    LumberjacksEndpoint(String endpointUri, LumberjackComponent component, String host, int port) {
-        super(endpointUri, component, host, port);
-    }
-
-    @Override
-    public LumberjackConsumer createConsumer(Processor processor) throws Exception {
-        if (sslContextParameters == null) {
-            throw new IllegalStateException("The sslContextParameters attribute must be defined for lumberjacks");
-        }
-        return new LumberjackConsumer(this, processor, host, port, sslContextParameters.createSSLContext(getCamelContext()));
-    }
-
-    @SuppressWarnings("unused")
-    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
-        this.sslContextParameters = sslContextParameters;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/12dcc564/components/camel-lumberjack/src/main/resources/META-INF/services/org/apache/camel/component/lumberjacks
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/resources/META-INF/services/org/apache/camel/component/lumberjacks b/components/camel-lumberjack/src/main/resources/META-INF/services/org/apache/camel/component/lumberjacks
deleted file mode 100644
index e542717..0000000
--- a/components/camel-lumberjack/src/main/resources/META-INF/services/org/apache/camel/component/lumberjacks
+++ /dev/null
@@ -1,17 +0,0 @@
-# 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.lumberjack.LumberjacksComponent

http://git-wip-us.apache.org/repos/asf/camel/blob/12dcc564/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentSSLTest.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentSSLTest.java b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentSSLTest.java
new file mode 100644
index 0000000..bcb52be
--- /dev/null
+++ b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentSSLTest.java
@@ -0,0 +1,109 @@
+/**
+ * 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.lumberjack;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.jsse.KeyManagersParameters;
+import org.apache.camel.util.jsse.KeyStoreParameters;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.camel.util.jsse.TrustManagersParameters;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@SuppressWarnings("unchecked")
+public class LumberjackComponentSSLTest extends CamelTestSupport {
+    private static int port;
+
+    @BeforeClass
+    public static void beforeClass() {
+        port = AvailablePortFinder.getNextAvailable();
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("ssl", createServerSSLContextParameters());
+        return registry;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                // Lumberjack configured with SSL
+                from("lumberjack:0.0.0.0:" + port + "?sslContextParameters=#ssl").to("mock:output");
+            }
+        };
+    }
+
+    @Test
+    public void shouldListenToMessagesOverSSL() throws Exception {
+        // We're expecting 25 messages with Maps
+        MockEndpoint mock = getMockEndpoint("mock:output");
+        mock.expectedMessageCount(25);
+        mock.allMessages().body().isInstanceOf(Map.class);
+
+        // When sending messages
+        List<Integer> responses = LumberjackUtil.sendMessages(port, createClientSSLContextParameters());
+
+        // Then we should have the messages we're expecting
+        mock.assertIsSatisfied();
+
+        // And we should have replied with 2 acknowledgments for each window frame
+        assertEquals(Arrays.asList(10, 15), responses);
+    }
+
+    /**
+     * Creates the {@link SSLContextParameters} Camel object for the Lumberjack component
+     *
+     * @return The {@link SSLContextParameters} Camel object for the Lumberjack component
+     */
+    private SSLContextParameters createServerSSLContextParameters() {
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+
+        KeyManagersParameters keyManagersParameters = new KeyManagersParameters();
+        KeyStoreParameters keyStore = new KeyStoreParameters();
+        keyStore.setPassword("changeit");
+        keyStore.setResource("org/apache/camel/component/lumberjack/keystore.jks");
+        keyManagersParameters.setKeyPassword("changeit");
+        keyManagersParameters.setKeyStore(keyStore);
+        sslContextParameters.setKeyManagers(keyManagersParameters);
+
+        return sslContextParameters;
+    }
+
+    private SSLContextParameters createClientSSLContextParameters() {
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+
+        TrustManagersParameters trustManagersParameters = new TrustManagersParameters();
+        KeyStoreParameters trustStore = new KeyStoreParameters();
+        trustStore.setPassword("changeit");
+        trustStore.setResource("org/apache/camel/component/lumberjack/keystore.jks");
+        trustManagersParameters.setKeyStore(trustStore);
+        sslContextParameters.setTrustManagers(trustManagersParameters);
+
+        return sslContextParameters;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/12dcc564/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentTest.java b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentTest.java
index 3a0d0f9..ec8026a 100644
--- a/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentTest.java
+++ b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentTest.java
@@ -64,6 +64,6 @@ public class LumberjackComponentTest extends CamelTestSupport {
         assertEquals("/home/qatest/collectNetwork/log/data-integration/00000000-f000-0000-1541-8da26f200001/absorption.log", first.get("source"));
 
         // And we should have replied with 2 acknowledgments for each window frame
-        assertEquals(responses, Arrays.asList(10, 15));
+        assertEquals(Arrays.asList(10, 15), responses);
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/12dcc564/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjacksComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjacksComponentTest.java b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjacksComponentTest.java
deleted file mode 100644
index 29e9397..0000000
--- a/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjacksComponentTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * 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.lumberjack;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.test.AvailablePortFinder;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.camel.util.jsse.KeyManagersParameters;
-import org.apache.camel.util.jsse.KeyStoreParameters;
-import org.apache.camel.util.jsse.SSLContextParameters;
-import org.apache.camel.util.jsse.TrustManagersParameters;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-@SuppressWarnings("unchecked")
-public class LumberjacksComponentTest extends CamelTestSupport {
-    private static int port;
-
-    @BeforeClass
-    public static void beforeClass() {
-        port = AvailablePortFinder.getNextAvailable();
-    }
-
-    @Override
-    protected JndiRegistry createRegistry() throws Exception {
-        JndiRegistry registry = super.createRegistry();
-        registry.bind("ssl", createServerSSLContextParameters());
-        return registry;
-    }
-
-    @Override
-    protected RouteBuilder createRouteBuilder() {
-        return new RouteBuilder() {
-            public void configure() {
-                // Lumberjack configured with SSL
-                from("lumberjacks:0.0.0.0:" + port + "?sslContextParameters=#ssl").to("mock:output");
-            }
-        };
-    }
-
-    @Test
-    public void shouldListenToMessagesOverSSL() throws Exception {
-        // We're expecting 25 messages with Maps
-        MockEndpoint mock = getMockEndpoint("mock:output");
-        mock.expectedMessageCount(25);
-        mock.allMessages().body().isInstanceOf(Map.class);
-
-        // When sending messages
-        List<Integer> responses = LumberjackUtil.sendMessages(port, createClientSSLContextParameters());
-
-        // Then we should have the messages we're expecting
-        mock.assertIsSatisfied();
-
-        // And we should have replied with 2 acknowledgments for each window frame
-        assertEquals(responses, Arrays.asList(10, 15));
-    }
-
-    /**
-     * Creates the {@link SSLContextParameters} Camel object for the Lumberjack component
-     *
-     * @return The {@link SSLContextParameters} Camel object for the Lumberjack component
-     */
-    private SSLContextParameters createServerSSLContextParameters() {
-        SSLContextParameters sslContextParameters = new SSLContextParameters();
-
-        KeyManagersParameters keyManagersParameters = new KeyManagersParameters();
-        KeyStoreParameters keyStore = new KeyStoreParameters();
-        keyStore.setPassword("changeit");
-        keyStore.setResource("org/apache/camel/component/lumberjack/keystore.jks");
-        keyManagersParameters.setKeyPassword("changeit");
-        keyManagersParameters.setKeyStore(keyStore);
-        sslContextParameters.setKeyManagers(keyManagersParameters);
-
-        return sslContextParameters;
-    }
-
-    private SSLContextParameters createClientSSLContextParameters() {
-        SSLContextParameters sslContextParameters = new SSLContextParameters();
-
-        TrustManagersParameters trustManagersParameters = new TrustManagersParameters();
-        KeyStoreParameters trustStore = new KeyStoreParameters();
-        trustStore.setPassword("changeit");
-        trustStore.setResource("org/apache/camel/component/lumberjack/keystore.jks");
-        trustManagersParameters.setKeyStore(trustStore);
-        sslContextParameters.setTrustManagers(trustManagersParameters);
-
-        return sslContextParameters;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/12dcc564/docs/user-manual/en/SUMMARY.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/SUMMARY.md b/docs/user-manual/en/SUMMARY.md
index 85f0056..1db0dcc 100644
--- a/docs/user-manual/en/SUMMARY.md
+++ b/docs/user-manual/en/SUMMARY.md
@@ -222,6 +222,7 @@
     * [LevelDB](leveldb.adoc)
     * [Linkedin](linkedin.adoc)
     * [Lucene](lucene.adoc)
+    * [Lumberjack](lumberjack.adoc)
     * [Mail](mail.adoc)
         * [IMAP](imap.adoc)
         * [IMAPs](imaps.adoc)


[3/4] camel git commit: Add Lumberjack component

Posted by da...@apache.org.
Add Lumberjack component


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3d0379d0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3d0379d0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3d0379d0

Branch: refs/heads/master
Commit: 3d0379d0379944187d6c780cf7567b895697c648
Parents: 920a88d
Author: Antoine DESSAIGNE <an...@gmail.com>
Authored: Fri Jul 8 09:37:53 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jul 15 08:59:27 2016 +0200

----------------------------------------------------------------------
 apache-camel/pom.xml                            |  12 +-
 .../src/main/descriptors/common-bin.xml         |   1 +
 components/camel-lumberjack/pom.xml             |  84 +++++++
 .../src/main/docs/lumberjack.adoc               |  93 ++++++++
 .../lumberjack/LumberjackComponent.java         |  60 +++++
 .../lumberjack/LumberjackConsumer.java          |  68 ++++++
 .../lumberjack/LumberjackEndpoint.java          |  54 +++++
 .../lumberjack/LumberjacksComponent.java        |  31 +++
 .../lumberjack/LumberjacksEndpoint.java         |  45 ++++
 .../io/LumberjackChannelInitializer.java        |  62 ++++++
 .../lumberjack/io/LumberjackConstants.java      |  46 ++++
 .../lumberjack/io/LumberjackFrameDecoder.java   | 217 +++++++++++++++++++
 .../lumberjack/io/LumberjackMessage.java        |  38 ++++
 .../lumberjack/io/LumberjackMessageHandler.java |  67 ++++++
 .../io/LumberjackMessageProcessor.java          |  44 ++++
 .../lumberjack/io/LumberjackServer.java         | 111 ++++++++++
 .../lumberjack/io/LumberjackSessionHandler.java |  65 ++++++
 .../src/main/resources/LICENSE.txt              | 203 +++++++++++++++++
 .../org/apache/camel/component/lumberjack       |  17 ++
 .../org/apache/camel/component/lumberjacks      |  17 ++
 .../src/main/resources/NOTICE.txt               |  11 +
 .../lumberjack/LumberjackComponentTest.java     |  69 ++++++
 .../lumberjack/LumberjackDisconnectionTest.java |  82 +++++++
 .../component/lumberjack/LumberjackUtil.java    | 112 ++++++++++
 .../lumberjack/LumberjacksComponentTest.java    | 109 ++++++++++
 .../io/LumberjackChannelInitializerTest.java    |  81 +++++++
 .../src/test/resources/log4j.properties         |  38 ++++
 .../camel/component/lumberjack/io/window10      | Bin 0 -> 1195 bytes
 .../camel/component/lumberjack/io/window15      | Bin 0 -> 1489 bytes
 .../camel/component/lumberjack/keystore.jks     | Bin 0 -> 1473 bytes
 components/pom.xml                              |   1 +
 parent/pom.xml                                  |  15 +-
 .../features/src/main/resources/features.xml    |  11 +
 .../camel/itest/karaf/CamelLumberjackTest.java  |  36 +++
 34 files changed, 1891 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index 8e9d4c4..e2e6001 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -528,10 +528,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-lucene</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.camel</groupId>
       <artifactId>camel-ldap</artifactId>
     </dependency>
     <dependency>
@@ -548,6 +544,14 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-lucene</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-lumberjack</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-lzf</artifactId>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index af39760..5f3e9bc 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -147,6 +147,7 @@
         <include>org.apache.camel:camel-linkedin-api</include>
         <include>org.apache.camel:camel-linkedin</include>
         <include>org.apache.camel:camel-lucene</include>
+        <include>org.apache.camel:camel-lumberjack</include>
         <include>org.apache.camel:camel-lzf</include>
         <include>org.apache.camel:camel-metrics</include>
         <include>org.apache.camel:camel-mail</include>

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/pom.xml b/components/camel-lumberjack/pom.xml
new file mode 100644
index 0000000..1e69023
--- /dev/null
+++ b/components/camel-lumberjack/pom.xml
@@ -0,0 +1,84 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>components</artifactId>
+        <version>2.18-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>camel-lumberjack</artifactId>
+    <packaging>jar</packaging>
+    <name>Camel :: Lumberjack</name>
+    <description>Camel Lumberjack log streaming component</description>
+
+    <properties>
+        <camel.osgi.export.pkg>org.apache.camel.component.lumberjack.*</camel.osgi.export.pkg>
+        <camel.osgi.export.service>
+            org.apache.camel.spi.ComponentResolver;component=lumberjack,
+            org.apache.camel.spi.ComponentResolver;component=lumberjacks
+        </camel.osgi.export.service>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-transport</artifactId>
+            <version>${netty-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty-handler</artifactId>
+            <version>${netty-version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>${gson-version}</version>
+        </dependency>
+
+        <!-- test dependencies -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/docs/lumberjack.adoc
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/docs/lumberjack.adoc b/components/camel-lumberjack/src/main/docs/lumberjack.adoc
new file mode 100644
index 0000000..51c2fca
--- /dev/null
+++ b/components/camel-lumberjack/src/main/docs/lumberjack.adoc
@@ -0,0 +1,93 @@
+[[Lumberjack-LumberjackComponent]]
+Lumberjack Component
+~~~~~~~~~~~~~~~~~~~~
+
+*Available as of Camel 2.18*
+
+The *Lumberjack* component retrieves logs sent over the network using the Lumberjack protocol,
+from https://www.elastic.co/fr/products/beats/filebeat[Filebeat] for instance.
+The network communication can be secured with SSL using the `lumberjacks` component.
+
+This component only supports consumer endpoints.
+
+Maven users will need to add the following dependency to their `pom.xml` for this component:
+
+[source,xml]
+------------------------------------------------------------
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-lumberjack</artifactId>
+    <version>x.x.x</version>
+    <!-- use the same version as your Camel core version -->
+</dependency>
+------------------------------------------------------------
+
+[[Lumberjack-URIformat]]
+URI format
+^^^^^^^^^^
+
+[source,java]
+------------------------------------
+lumberjack:host
+lumberjack:host:port
+lumberjacks:host:port?sslContextParameters=#ssl
+------------------------------------
+
+You can append query options to the URI in the following format,
+`?option=value&option=value&...`
+
+[[Lumberjack-Options]]
+Options
+^^^^^^^
+
+
+// component options: START
+The Lumberjack component has no options.
+// component options: END
+
+
+
+// endpoint options: START
+The Lumberjack component supports 6 endpoint options which are listed below:
+
+{% raw %}
+[width="100%",cols="2s,1,1m,1m,5",options="header"]
+|=======================================================================
+| Name | Group | Default | Java Type | Description
+| host | common |  | String | *Required* Network interface on which to listen for Lumberjack
+| port | common | 5044 | int | Network port on which to listen for Lumberjack
+| bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored.
+| exceptionHandler | consumer (advanced) |  | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
+| exchangePattern | advanced | InOnly | ExchangePattern | Sets the default exchange pattern when creating an exchange
+| synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
+|=======================================================================
+{% endraw %}
+// endpoint options: END
+
+
+
+[[Lumberjack-Result]]
+Result
+^^^^^^
+
+The result body is a `Map<String, Object>` object.
+
+[[Lumberjack-LumberjackUsageSamples]]
+Lumberjack Usage Samples
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+[[Lumberjack-Example1:]]
+Example 1: Streaming the log messages
++++++++++++++++++++++++++++++++++++++
+
+[source,java]
+------------------------------------------------------------------------------------
+RouteBuilder builder = new RouteBuilder() {
+    public void configure() {
+       from("lumberjack:0.0.0.0").                  // Listen on all network interfaces using the default port
+           setBody(simple("${body[message]}")).     // Select only the log message
+           to("stream:out");                        // Write it into the output stream
+    }
+};
+------------------------------------------------------------------------------------
+

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java
new file mode 100644
index 0000000..1cb9dda
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java
@@ -0,0 +1,60 @@
+/**
+ * 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.lumberjack;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.UriEndpointComponent;
+
+/**
+ * The class is the Camel component for the Lumberjack server
+ */
+public class LumberjackComponent extends UriEndpointComponent {
+    static final int DEFAULT_PORT = 5044;
+
+    public LumberjackComponent() {
+        this(LumberjackEndpoint.class);
+    }
+
+    protected LumberjackComponent(Class<? extends LumberjackEndpoint> endpointClass) {
+        super(endpointClass);
+    }
+
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        // Extract host and port
+        String host;
+        int port;
+        int separatorIndex = remaining.indexOf(':');
+        if (separatorIndex >= 0) {
+            host = remaining.substring(0, separatorIndex);
+            port = Integer.parseInt(remaining.substring(separatorIndex + 1));
+        } else {
+            host = remaining;
+            port = DEFAULT_PORT;
+        }
+
+        Endpoint answer = createEndpoint(uri, host, port);
+        setProperties(answer, parameters);
+        return answer;
+    }
+
+    protected LumberjackEndpoint createEndpoint(String uri, String host, int port) {
+        return new LumberjackEndpoint(uri, this, host, port);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java
new file mode 100644
index 0000000..affdaaf
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java
@@ -0,0 +1,68 @@
+/**
+ * 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.lumberjack;
+
+import java.util.concurrent.ThreadFactory;
+import javax.net.ssl.SSLContext;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.lumberjack.io.LumberjackMessageProcessor;
+import org.apache.camel.component.lumberjack.io.LumberjackServer;
+import org.apache.camel.impl.DefaultConsumer;
+import org.apache.camel.util.concurrent.CamelThreadFactory;
+
+class LumberjackConsumer extends DefaultConsumer {
+    private final LumberjackServer lumberjackServer;
+
+    LumberjackConsumer(LumberjackEndpoint endpoint, Processor processor, String host, int port, SSLContext sslContext) {
+        super(endpoint, processor);
+        lumberjackServer = new LumberjackServer(host, port, sslContext, getThreadFactory(), this::onMessageReceived);
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        lumberjackServer.start();
+    }
+
+    @Override
+    protected void doResume() throws Exception {
+        super.doResume();
+        lumberjackServer.start();
+    }
+
+    @Override
+    protected void doSuspend() throws Exception {
+        lumberjackServer.stop();
+        super.doSuspend();
+    }
+
+    private ThreadFactory getThreadFactory() {
+        String threadNamePattern = getEndpoint().getCamelContext().getExecutorServiceManager().getThreadNamePattern();
+        return new CamelThreadFactory(threadNamePattern, "LumberjackNettyExecutor", true);
+    }
+
+    private void onMessageReceived(Object payload, LumberjackMessageProcessor.Callback callback) {
+        // Create the exchange
+        Exchange exchange = getEndpoint().createExchange();
+        exchange.getIn().setBody(payload);
+
+        // Process the exchange
+        getAsyncProcessor().process(exchange, doneSync -> callback.onComplete(!exchange.isFailed()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java
new file mode 100644
index 0000000..0b0d37e
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java
@@ -0,0 +1,54 @@
+/**
+ * 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.lumberjack;
+
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriPath;
+
+@UriEndpoint(scheme = "lumberjack", title = "Lumberjack", syntax = "lumberjack:host:port", consumerClass = LumberjackConsumer.class, label = "log")
+class LumberjackEndpoint extends DefaultEndpoint {
+    @UriPath(description = "Network interface on which to listen for Lumberjack")
+    @Metadata(required = "true")
+    final String host;
+    @UriPath(description = "Network port on which to listen for Lumberjack", defaultValue = "" + LumberjackComponent.DEFAULT_PORT)
+    final int port;
+
+    LumberjackEndpoint(String endpointUri, LumberjackComponent component, String host, int port) {
+        super(endpointUri, component);
+        this.host = host;
+        this.port = port;
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        throw new UnsupportedOperationException("The Lumberjack component cannot be used as a producer");
+    }
+
+    @Override
+    public LumberjackConsumer createConsumer(Processor processor) throws Exception {
+        return new LumberjackConsumer(this, processor, host, port, null);
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return true;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksComponent.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksComponent.java
new file mode 100644
index 0000000..3d5bfb2
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksComponent.java
@@ -0,0 +1,31 @@
+/**
+ * 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.lumberjack;
+
+/**
+ * The class is the Camel component for the Lumberjack server with SSL
+ */
+public class LumberjacksComponent extends LumberjackComponent {
+    public LumberjacksComponent() {
+        super(LumberjacksEndpoint.class);
+    }
+
+    @Override
+    protected LumberjacksEndpoint createEndpoint(String uri, String host, int port) {
+        return new LumberjacksEndpoint(uri, this, host, port);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksEndpoint.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksEndpoint.java
new file mode 100644
index 0000000..db02d3b
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjacksEndpoint.java
@@ -0,0 +1,45 @@
+/**
+ * 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.lumberjack;
+
+import org.apache.camel.Processor;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.util.jsse.SSLContextParameters;
+
+@UriEndpoint(scheme = "lumberjacks", title = "Lumberjacks", syntax = "lumberjacks:host:port", consumerClass = LumberjackConsumer.class, label = "log")
+class LumberjacksEndpoint extends LumberjackEndpoint {
+    @UriParam(description = "SSL configuration")
+    private SSLContextParameters sslContextParameters;
+
+    LumberjacksEndpoint(String endpointUri, LumberjackComponent component, String host, int port) {
+        super(endpointUri, component, host, port);
+    }
+
+    @Override
+    public LumberjackConsumer createConsumer(Processor processor) throws Exception {
+        if (sslContextParameters == null) {
+            throw new IllegalStateException("The sslContextParameters attribute must be defined for lumberjacks");
+        }
+        return new LumberjackConsumer(this, processor, host, port, sslContextParameters.createSSLContext(getCamelContext()));
+    }
+
+    @SuppressWarnings("unused")
+    public void setSslContextParameters(SSLContextParameters sslContextParameters) {
+        this.sslContextParameters = sslContextParameters;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackChannelInitializer.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackChannelInitializer.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackChannelInitializer.java
new file mode 100644
index 0000000..903fa94
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackChannelInitializer.java
@@ -0,0 +1,62 @@
+/**
+ * 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.lumberjack.io;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelPipeline;
+import io.netty.handler.ssl.SslHandler;
+import io.netty.util.concurrent.EventExecutorGroup;
+
+final class LumberjackChannelInitializer extends ChannelInitializer<Channel> {
+    private final SSLContext sslContext;
+    private final EventExecutorGroup messageExecutorService;
+    private final LumberjackMessageProcessor messageProcessor;
+
+    LumberjackChannelInitializer(SSLContext sslContext, EventExecutorGroup messageExecutorService,
+                                 LumberjackMessageProcessor messageProcessor) {
+        this.sslContext = sslContext;
+        this.messageExecutorService = messageExecutorService;
+        this.messageProcessor = messageProcessor;
+    }
+
+    @Override
+    protected void initChannel(Channel ch) throws Exception {
+        ChannelPipeline pipeline = ch.pipeline();
+
+        // Add SSL support if configured
+        if (sslContext != null) {
+            SSLEngine sslEngine = sslContext.createSSLEngine();
+            sslEngine.setUseClientMode(false);
+            pipeline.addLast(new SslHandler(sslEngine));
+        }
+
+        LumberjackSessionHandler sessionHandler = new LumberjackSessionHandler();
+
+        // Add the primary lumberjack frame decoder
+        pipeline.addLast(new LumberjackFrameDecoder(sessionHandler));
+
+        // Add the secondary lumberjack frame decoder, used when the first one is processing compressed frames
+        pipeline.addLast(new LumberjackFrameDecoder(sessionHandler));
+
+        // Add the bridge to Camel
+        pipeline.addLast(messageExecutorService, new LumberjackMessageHandler(sessionHandler, messageProcessor));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackConstants.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackConstants.java
new file mode 100644
index 0000000..37ca5e6
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackConstants.java
@@ -0,0 +1,46 @@
+/**
+ * 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.lumberjack.io;
+
+final class LumberjackConstants {
+    static final int VERSION_V1 = '1';
+    static final int VERSION_V2 = '2';
+
+    static final int TYPE_ACKNOWLEDGE = 'A';
+
+    static final int TYPE_WINDOW = 'W';
+    static final int TYPE_COMPRESS = 'C';
+    static final int TYPE_JSON = 'J';
+    static final int TYPE_DATA = 'D';
+
+    static final int INT_LENGTH = 4;
+
+    static final int FRAME_HEADER_LENGTH = 1 + 1; // version(byte) + type(byte)
+
+    static final int FRAME_ACKNOWLEDGE_LENGTH = FRAME_HEADER_LENGTH + INT_LENGTH; // sequence number(int)
+
+    static final int FRAME_JSON_HEADER_LENGTH = INT_LENGTH + INT_LENGTH; // sequence number(int) + payload length(int)
+
+    static final int FRAME_DATA_HEADER_LENGTH = INT_LENGTH + INT_LENGTH; // sequence number(int) + key/value pair count(int)
+
+    static final int FRAME_WINDOW_HEADER_LENGTH = INT_LENGTH; // window size(int)
+
+    static final int FRAME_COMPRESS_HEADER_LENGTH = INT_LENGTH; // compressed payload length(int)
+
+    private LumberjackConstants() {
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackFrameDecoder.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackFrameDecoder.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackFrameDecoder.java
new file mode 100644
index 0000000..c3fa454
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackFrameDecoder.java
@@ -0,0 +1,217 @@
+/**
+ * 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.lumberjack.io;
+
+import java.nio.charset.StandardCharsets;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.Inflater;
+
+import com.google.gson.Gson;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.FRAME_COMPRESS_HEADER_LENGTH;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.FRAME_DATA_HEADER_LENGTH;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.FRAME_HEADER_LENGTH;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.FRAME_JSON_HEADER_LENGTH;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.FRAME_WINDOW_HEADER_LENGTH;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.INT_LENGTH;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.TYPE_COMPRESS;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.TYPE_DATA;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.TYPE_JSON;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.TYPE_WINDOW;
+
+/**
+ * Decode lumberjack protocol frames. Support protocol V1 and V2 and frame types D, J, W and C.<br/>
+ * <p>
+ * For more info, see:
+ * <ul>
+ * <li><a href="https://github.com/elastic/beats">https://github.com/elastic/beats</a></li>
+ * <li><a href="https://github.com/logstash-plugins/logstash-input-beats/blob/master/PROTOCOL.md">https://github.com/logstash-plugins/logstash-input-beats/blob/master/PROTOCOL.md</a></li>
+ * <li><a href="https://github.com/elastic/logstash-forwarder/blob/master/PROTOCOL.md">https://github.com/elastic/logstash-forwarder/blob/master/PROTOCOL.md</a></li>
+ * <li><a href="https://github.com/elastic/libbeat/issues/279">https://github.com/elastic/libbeat/issues/279</a></li>
+ * </ul>
+ */
+final class LumberjackFrameDecoder extends ByteToMessageDecoder {
+    private static final Logger LOG = LoggerFactory.getLogger(LumberjackFrameDecoder.class);
+
+    private final LumberjackSessionHandler sessionHandler;
+    private final Gson gson;
+
+    LumberjackFrameDecoder(LumberjackSessionHandler sessionHandler) {
+        this.sessionHandler = sessionHandler;
+        gson = new Gson();
+    }
+
+    @Override
+    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
+        // mark the reader index to be able to start decoding from the same position if there is not enough data to finish the frame decoding
+        in.markReaderIndex();
+
+        boolean frameDecoded = false;
+
+        try {
+            if (!in.isReadable(FRAME_HEADER_LENGTH)) {
+                return;
+            }
+
+            int frameVersion = in.readUnsignedByte();
+            sessionHandler.versionRead(frameVersion);
+
+            int frameType = in.readUnsignedByte();
+            LOG.debug("Received a lumberjack frame of type {}", (char) frameType);
+
+            switch (frameType) {
+            case TYPE_JSON:
+                frameDecoded = handleJsonFrame(in, out);
+                break;
+            case TYPE_DATA:
+                frameDecoded = handleDataFrame(in, out);
+                break;
+            case TYPE_WINDOW:
+                frameDecoded = handleWindowFrame(in);
+                break;
+            case TYPE_COMPRESS:
+                frameDecoded = handleCompressedFrame(ctx, in, out);
+                break;
+            default:
+                throw new RuntimeException("Unsupported frame type=" + frameType);
+            }
+        } finally {
+            if (!frameDecoded) {
+                LOG.debug("Not enough data to decode a complete frame, retry when more data is available. Reader index was {}", in.readerIndex());
+                in.resetReaderIndex();
+            }
+        }
+    }
+
+    private boolean handleJsonFrame(ByteBuf in, List<Object> out) {
+        if (!in.isReadable(FRAME_JSON_HEADER_LENGTH)) {
+            return false;
+        }
+
+        int sequenceNumber = in.readInt();
+
+        // read message string and then decode it as JSON
+        String jsonStr = readLengthPrefixedString(in);
+        if (jsonStr == null) {
+            return false;
+        }
+
+        Object jsonMessage = gson.fromJson(jsonStr, Object.class);
+
+        // put message in the pipeline
+        out.add(new LumberjackMessage(sequenceNumber, jsonMessage));
+        return true;
+    }
+
+    private boolean handleDataFrame(ByteBuf in, List<Object> out) {
+        if (!in.isReadable(FRAME_DATA_HEADER_LENGTH)) {
+            return false;
+        }
+
+        int sequenceNumber = in.readInt();
+        int entriesCount = in.readInt();
+
+        Map<String, String> dataMessage = new LinkedHashMap<>();
+
+        while (entriesCount-- > 0) {
+            String key = readLengthPrefixedString(in);
+            if (key == null) {
+                return false;
+            }
+
+            String value = readLengthPrefixedString(in);
+            if (value == null) {
+                return false;
+            }
+
+            dataMessage.put(key, value);
+        }
+
+        out.add(new LumberjackMessage(sequenceNumber, dataMessage));
+        return true;
+    }
+
+    private boolean handleWindowFrame(ByteBuf in) {
+        if (!in.isReadable(FRAME_WINDOW_HEADER_LENGTH)) {
+            return false;
+        }
+
+        // update window size
+        sessionHandler.windowSizeRead(in.readInt());
+        return true;
+    }
+
+    private boolean handleCompressedFrame(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
+        if (!in.isReadable(FRAME_COMPRESS_HEADER_LENGTH)) {
+            return false;
+        }
+
+        int compressedPayloadLength = in.readInt();
+        if (!in.isReadable(compressedPayloadLength)) {
+            return false;
+        }
+
+        // decompress payload
+        Inflater inflater = new Inflater();
+        if (in.hasArray()) {
+            inflater.setInput(in.array(), in.arrayOffset() + in.readerIndex(), compressedPayloadLength);
+            in.skipBytes(compressedPayloadLength);
+        } else {
+            byte[] array = new byte[compressedPayloadLength];
+            in.readBytes(array);
+            inflater.setInput(array);
+        }
+
+        while (!inflater.finished()) {
+            ByteBuf decompressed = ctx.alloc().heapBuffer(1024, 1024);
+            byte[] outArray = decompressed.array();
+            int count = inflater.inflate(outArray, decompressed.arrayOffset(), decompressed.writableBytes());
+            decompressed.writerIndex(count);
+            // put data in the pipeline
+            out.add(decompressed);
+        }
+
+        return true;
+    }
+
+    /**
+     * Read a string that is prefixed by its length encoded by a 4 bytes integer.
+     *
+     * @param in the buffer to consume
+     * @return the read string or {@code null} if not enough data available to read the whole string
+     */
+    private String readLengthPrefixedString(ByteBuf in) {
+        if (!in.isReadable(INT_LENGTH)) {
+            return null;
+        }
+        int length = in.readInt();
+        if (!in.isReadable(length)) {
+            return null;
+        }
+
+        String str = in.toString(in.readerIndex(), length, StandardCharsets.UTF_8);
+        in.skipBytes(length);
+        return str;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackMessage.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackMessage.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackMessage.java
new file mode 100644
index 0000000..466179f
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackMessage.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.lumberjack.io;
+
+/**
+ * A received lumberjack message, that contains it's sequence number and payload.
+ */
+final class LumberjackMessage {
+    private final int sequenceNumber;
+    private final Object payload;
+
+    LumberjackMessage(int sequenceNumber, Object payload) {
+        this.sequenceNumber = sequenceNumber;
+        this.payload = payload;
+    }
+
+    int getSequenceNumber() {
+        return sequenceNumber;
+    }
+
+    Object getPayload() {
+        return payload;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackMessageHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackMessageHandler.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackMessageHandler.java
new file mode 100644
index 0000000..f6b50d8
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackMessageHandler.java
@@ -0,0 +1,67 @@
+/**
+ * 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.lumberjack.io;
+
+import java.io.IOException;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This handler connects the Netty pipeline to the Camel endpoint.
+ */
+final class LumberjackMessageHandler extends SimpleChannelInboundHandler<LumberjackMessage> {
+    private static final Logger LOG = LoggerFactory.getLogger(LumberjackMessageHandler.class);
+
+    private final LumberjackSessionHandler sessionHandler;
+    private final LumberjackMessageProcessor messageProcessor;
+
+    private volatile boolean process = true;
+
+    LumberjackMessageHandler(LumberjackSessionHandler sessionHandler, LumberjackMessageProcessor messageProcessor) {
+        this.sessionHandler = sessionHandler;
+        this.messageProcessor = messageProcessor;
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+        if (cause instanceof IOException) {
+            LOG.debug("IO exception (client connection closed ?)", cause);
+        } else {
+            LOG.warn("Caught an exception while reading, closing channel.", cause);
+        }
+        ctx.close();
+    }
+
+    @Override
+    protected void channelRead0(ChannelHandlerContext ctx, LumberjackMessage msg) throws Exception {
+        if (process) {
+            messageProcessor.onMessageReceived(msg.getPayload(), success -> {
+                if (success) {
+                    sessionHandler.notifyMessageProcessed(ctx, msg.getSequenceNumber());
+                } else {
+                    ctx.close();
+
+                    // Mark that we shouldn't process the next messages that are already decoded and are waiting in netty queues
+                    process = false;
+                }
+            });
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackMessageProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackMessageProcessor.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackMessageProcessor.java
new file mode 100644
index 0000000..a11e09c
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackMessageProcessor.java
@@ -0,0 +1,44 @@
+/**
+ * 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.lumberjack.io;
+
+/**
+ * This functional interface defines a processor that will be called when a lumberjack message is received
+ */
+@FunctionalInterface
+public interface LumberjackMessageProcessor {
+    /**
+     * Called when a message is received. The {@code callback} must be called with the status of the processing
+     *
+     * @param payload Lumberjack message payload
+     * @param callback Callback to call when the processing is complete
+     */
+    void onMessageReceived(Object payload, Callback callback);
+
+    /**
+     * This functional interface defines the callback to call when the processing of a Lumberjack message is complete
+     */
+    @FunctionalInterface
+    interface Callback {
+        /**
+         * Called when the processing is complete.
+         *
+         * @param success {@code true} is the processing is a success, {@code false} otherwise
+         */
+        void onComplete(boolean success);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackServer.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackServer.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackServer.java
new file mode 100644
index 0000000..4e7c5db
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackServer.java
@@ -0,0 +1,111 @@
+/**
+ * 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.lumberjack.io;
+
+import java.util.concurrent.ThreadFactory;
+import javax.net.ssl.SSLContext;
+
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.util.concurrent.DefaultEventExecutorGroup;
+import io.netty.util.concurrent.EventExecutorGroup;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class defines the Lumberjack server that will receive Lumberjack messages
+ */
+public final class LumberjackServer {
+    private static final Logger LOG = LoggerFactory.getLogger(LumberjackServer.class);
+    private static final int WORKER_THREADS = 16;
+
+    private final String host;
+    private final int port;
+    private final SSLContext sslContext;
+    private final ThreadFactory threadFactory;
+    private final LumberjackMessageProcessor messageProcessor;
+
+    private EventExecutorGroup executorService;
+    private EventLoopGroup bossGroup;
+    private EventLoopGroup workerGroup;
+    private Channel channel;
+
+    public LumberjackServer(String host, int port, SSLContext sslContext, ThreadFactory threadFactory,
+                            LumberjackMessageProcessor messageProcessor) {
+        this.host = host;
+        this.port = port;
+        this.sslContext = sslContext;
+        this.threadFactory = threadFactory;
+        this.messageProcessor = messageProcessor;
+    }
+
+    /**
+     * Starts the server.
+     *
+     * @throws InterruptedException when interrupting while connecting the socket
+     */
+    public void start() throws InterruptedException {
+        LOG.info("Starting the LUMBERJACK server (host={}, port={}).", host, port);
+
+        // Create the group that will listen for incoming connections
+        bossGroup = new NioEventLoopGroup(1);
+        // Create the group that will process the connections
+        workerGroup = new NioEventLoopGroup(WORKER_THREADS);
+        // Create the executor service that will process the payloads without blocking netty threads
+        executorService = new DefaultEventExecutorGroup(WORKER_THREADS, threadFactory);
+
+        // Create the channel initializer
+        ChannelHandler initializer = new LumberjackChannelInitializer(sslContext, executorService, messageProcessor);
+
+        // Bootstrap the netty server
+        ServerBootstrap serverBootstrap = new ServerBootstrap()  //
+                .group(bossGroup, workerGroup)               //
+                .channel(NioServerSocketChannel.class)           //
+                .option(ChannelOption.SO_BACKLOG, 100)           //
+                .childHandler(initializer);                      //
+
+        // Connect the socket
+        channel = serverBootstrap.bind(host, port).sync().channel();
+
+        LOG.info("LUMBERJACK server is started (host={}, port={}).", host, port);
+    }
+
+    /**
+     * Stops the server.
+     *
+     * @throws InterruptedException when interrupting while stopping the socket
+     */
+    public void stop() throws InterruptedException {
+        LOG.info("Stopping the LUMBERJACK server (host={}, port={}).", host, port);
+
+        try {
+            // Wait for the channel to be indeed closed before shutting the groups & service
+            channel.close().sync();
+        } finally {
+            bossGroup.shutdownGracefully();
+            workerGroup.shutdownGracefully();
+            executorService.shutdownGracefully();
+        }
+
+        LOG.info("LUMBERJACK server is stopped (host={}, port={}).", host, port);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackSessionHandler.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackSessionHandler.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackSessionHandler.java
new file mode 100644
index 0000000..6c16656
--- /dev/null
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/io/LumberjackSessionHandler.java
@@ -0,0 +1,65 @@
+/**
+ * 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.lumberjack.io;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.FRAME_ACKNOWLEDGE_LENGTH;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.TYPE_ACKNOWLEDGE;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.VERSION_V1;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.VERSION_V2;
+
+/**
+ * Handles lumberjack window and send acknowledge when required.
+ */
+final class LumberjackSessionHandler {
+    private static final Logger LOG = LoggerFactory.getLogger(LumberjackSessionHandler.class);
+
+    private volatile int version = -1;
+    private volatile int windowSize = 1;
+
+    void versionRead(int version) {
+        if (this.version == -1) {
+            if (version != VERSION_V1 && version != VERSION_V2) {
+                throw new RuntimeException("Unsupported frame version=" + version);
+            }
+            LOG.debug("Lumberjack protocol version is {}", (char) version);
+            this.version = version;
+        } else if (this.version != version) {
+            throw new IllegalStateException("Protocol version changed during session from " + this.version + " to " + version);
+        }
+    }
+
+    void windowSizeRead(int windowSize) {
+        LOG.debug("Lumberjack window size is {}", windowSize);
+        this.windowSize = windowSize;
+    }
+
+    void notifyMessageProcessed(ChannelHandlerContext ctx, int sequenceNumber) {
+        if (sequenceNumber == windowSize) {
+            LOG.debug("Sequence number is {}. Sending ACK", sequenceNumber);
+            ByteBuf response = ctx.alloc().heapBuffer(FRAME_ACKNOWLEDGE_LENGTH, FRAME_ACKNOWLEDGE_LENGTH);
+            response.writeByte(version);
+            response.writeByte(TYPE_ACKNOWLEDGE);
+            response.writeInt(sequenceNumber);
+            ctx.writeAndFlush(response);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/resources/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/resources/LICENSE.txt b/components/camel-lumberjack/src/main/resources/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-lumberjack/src/main/resources/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/3d0379d0/components/camel-lumberjack/src/main/resources/META-INF/services/org/apache/camel/component/lumberjack
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/resources/META-INF/services/org/apache/camel/component/lumberjack b/components/camel-lumberjack/src/main/resources/META-INF/services/org/apache/camel/component/lumberjack
new file mode 100644
index 0000000..7011d94
--- /dev/null
+++ b/components/camel-lumberjack/src/main/resources/META-INF/services/org/apache/camel/component/lumberjack
@@ -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.lumberjack.LumberjackComponent

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/resources/META-INF/services/org/apache/camel/component/lumberjacks
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/resources/META-INF/services/org/apache/camel/component/lumberjacks b/components/camel-lumberjack/src/main/resources/META-INF/services/org/apache/camel/component/lumberjacks
new file mode 100644
index 0000000..e542717
--- /dev/null
+++ b/components/camel-lumberjack/src/main/resources/META-INF/services/org/apache/camel/component/lumberjacks
@@ -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.lumberjack.LumberjacksComponent

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/main/resources/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/resources/NOTICE.txt b/components/camel-lumberjack/src/main/resources/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-lumberjack/src/main/resources/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/3d0379d0/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentTest.java b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentTest.java
new file mode 100644
index 0000000..3a0d0f9
--- /dev/null
+++ b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackComponentTest.java
@@ -0,0 +1,69 @@
+/**
+ * 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.lumberjack;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class LumberjackComponentTest extends CamelTestSupport {
+    private static int port;
+
+    @BeforeClass
+    public static void beforeClass() {
+        port = AvailablePortFinder.getNextAvailable();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                // Lumberjack configured with a specific port
+                from("lumberjack:0.0.0.0:" + port).to("mock:output");
+            }
+        };
+    }
+
+    @Test
+    public void shouldListenToMessages() throws Exception {
+        // We're expecting 25 messages with Maps
+        MockEndpoint mock = getMockEndpoint("mock:output");
+        mock.expectedMessageCount(25);
+        mock.allMessages().body().isInstanceOf(Map.class);
+
+        // When sending messages
+        List<Integer> responses = LumberjackUtil.sendMessages(port, null);
+
+        // Then we should have the messages we're expecting
+        mock.assertIsSatisfied();
+
+        // And the first map should contains valid data (we're assuming it's also valid for the other ones)
+        Map first = mock.getExchanges().get(0).getIn().getBody(Map.class);
+        assertEquals("log", first.get("input_type"));
+        assertEquals("/home/qatest/collectNetwork/log/data-integration/00000000-f000-0000-1541-8da26f200001/absorption.log", first.get("source"));
+
+        // And we should have replied with 2 acknowledgments for each window frame
+        assertEquals(responses, Arrays.asList(10, 15));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackDisconnectionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackDisconnectionTest.java b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackDisconnectionTest.java
new file mode 100644
index 0000000..3a34603
--- /dev/null
+++ b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackDisconnectionTest.java
@@ -0,0 +1,82 @@
+/**
+ * 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.lumberjack;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@SuppressWarnings("unchecked")
+public class LumberjackDisconnectionTest extends CamelTestSupport {
+    private static int port;
+
+    @BeforeClass
+    public static void beforeClass() {
+        port = AvailablePortFinder.getNextAvailable();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                // Lumberjack configured with something that throws an exception
+                from("lumberjack:0.0.0.0:" + port).process(new ErrorProcessor()).to("mock:output");
+            }
+        };
+    }
+
+    @Test
+    public void shouldDisconnectUponError() throws Exception {
+        // We're expecting 3 messages with Maps
+        // The fourth one crashed and we didn't received the next ones
+        MockEndpoint mock = getMockEndpoint("mock:output");
+        mock.expectedMessageCount(3);
+        mock.allMessages().body().isInstanceOf(Map.class);
+
+        // When sending messages
+        List<Integer> responses = LumberjackUtil.sendMessages(port, null);
+
+        // Then we should have the messages we're expecting
+        mock.assertIsSatisfied();
+
+        // And no acknowledgment is received
+        assertCollectionSize(responses, 0);
+    }
+
+    /**
+     * This processor throws an exception as the fourth message received.
+     */
+    private static final class ErrorProcessor implements Processor {
+        int count;
+
+        @Override
+        public void process(Exchange exchange) throws Exception {
+            count++;
+            if (count == 4) {
+                throw new RuntimeException("Ooops");
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackUtil.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackUtil.java b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackUtil.java
new file mode 100644
index 0000000..2dcfbbb
--- /dev/null
+++ b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjackUtil.java
@@ -0,0 +1,112 @@
+/**
+ * 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.lumberjack;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import javax.net.ssl.SSLEngine;
+
+import io.netty.bootstrap.Bootstrap;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelPipeline;
+import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioSocketChannel;
+import io.netty.handler.ssl.SslHandler;
+import org.apache.camel.util.jsse.SSLContextParameters;
+
+import static io.netty.buffer.Unpooled.wrappedBuffer;
+import static org.junit.Assert.assertEquals;
+
+final class LumberjackUtil {
+    private LumberjackUtil() {
+    }
+
+    static List<Integer> sendMessages(int port, SSLContextParameters sslContextParameters) throws InterruptedException {
+        NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup();
+        try {
+            // This list will hold the acknowledgment response sequence numbers
+            List<Integer> responses = new ArrayList<>();
+
+            // This initializer configures the SSL and an acknowledgment recorder
+            ChannelInitializer<Channel> initializer = new ChannelInitializer<Channel>() {
+                @Override
+                protected void initChannel(Channel ch) throws Exception {
+                    ChannelPipeline pipeline = ch.pipeline();
+                    if (sslContextParameters != null) {
+                        SSLEngine sslEngine = sslContextParameters.createSSLContext(null).createSSLEngine();
+                        sslEngine.setUseClientMode(true);
+                        pipeline.addLast(new SslHandler(sslEngine));
+                    }
+
+                    // Add the response recorder
+                    pipeline.addLast(new SimpleChannelInboundHandler<ByteBuf>() {
+                        @Override
+                        protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
+                            assertEquals(msg.readUnsignedByte(), (short) '2');
+                            assertEquals(msg.readUnsignedByte(), (short) 'A');
+                            synchronized (responses) {
+                                responses.add(msg.readInt());
+                            }
+                        }
+                    });
+                }
+            };
+
+            // Connect to the server
+            Channel channel = new Bootstrap()                     //
+                    .group(eventLoopGroup)                        //
+                    .channel(NioSocketChannel.class)              //
+                    .handler(initializer)                         //
+                    .connect("127.0.0.1", port).sync().channel(); //
+
+            // Send the 2 window frames
+            channel.writeAndFlush(readSample("io/window10"));
+            TimeUnit.MILLISECONDS.sleep(100);
+            channel.writeAndFlush(readSample("io/window15"));
+            TimeUnit.MILLISECONDS.sleep(100);
+
+            channel.close();
+
+            synchronized (responses) {
+                return responses;
+            }
+        } finally {
+            eventLoopGroup.shutdownGracefully();
+        }
+    }
+
+    private static ByteBuf readSample(String resource) {
+        try (InputStream stream = LumberjackUtil.class.getResourceAsStream(resource)) {
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
+            int input;
+            while ((input = stream.read()) != -1) {
+                output.write(input);
+            }
+            return wrappedBuffer(output.toByteArray());
+        } catch (IOException e) {
+            throw new RuntimeException("Cannot read sample data", e);
+        }
+    }
+}


[4/4] camel git commit: Fixed CS. Added test to SB. This fixes #1071

Posted by da...@apache.org.
Fixed CS. Added test to SB. This fixes #1071


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f496aac7
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f496aac7
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f496aac7

Branch: refs/heads/master
Commit: f496aac76098600313248a8a4c62c75efedf1830
Parents: 12dcc56
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Jul 15 09:09:45 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jul 15 09:09:45 2016 +0200

----------------------------------------------------------------------
 components/camel-lumberjack/pom.xml             | 107 +++++++++----------
 .../src/main/docs/lumberjack.adoc               |   8 +-
 .../lumberjack/LumberjackComponent.java         |   2 +-
 .../lumberjack/LumberjackConsumer.java          |   4 +-
 .../lumberjack/LumberjackEndpoint.java          |  11 +-
 .../src/test/resources/log4j.properties         |   6 +-
 .../itest/springboot/CamelLumberjackTest.java   |  48 +++++++++
 7 files changed, 117 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f496aac7/components/camel-lumberjack/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/pom.xml b/components/camel-lumberjack/pom.xml
index 1e69023..38029d7 100644
--- a/components/camel-lumberjack/pom.xml
+++ b/components/camel-lumberjack/pom.xml
@@ -20,65 +20,64 @@
 <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/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
+  <modelVersion>4.0.0</modelVersion>
 
-    <parent>
-        <groupId>org.apache.camel</groupId>
-        <artifactId>components</artifactId>
-        <version>2.18-SNAPSHOT</version>
-    </parent>
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>components</artifactId>
+    <version>2.18-SNAPSHOT</version>
+  </parent>
 
-    <artifactId>camel-lumberjack</artifactId>
-    <packaging>jar</packaging>
-    <name>Camel :: Lumberjack</name>
-    <description>Camel Lumberjack log streaming component</description>
+  <artifactId>camel-lumberjack</artifactId>
+  <packaging>jar</packaging>
+  <name>Camel :: Lumberjack</name>
+  <description>Camel Lumberjack log streaming component</description>
 
-    <properties>
-        <camel.osgi.export.pkg>org.apache.camel.component.lumberjack.*</camel.osgi.export.pkg>
-        <camel.osgi.export.service>
-            org.apache.camel.spi.ComponentResolver;component=lumberjack,
-            org.apache.camel.spi.ComponentResolver;component=lumberjacks
-        </camel.osgi.export.service>
-    </properties>
+  <properties>
+    <camel.osgi.export.pkg>org.apache.camel.component.lumberjack.*</camel.osgi.export.pkg>
+    <camel.osgi.export.service>
+      org.apache.camel.spi.ComponentResolver;component=lumberjack
+    </camel.osgi.export.service>
+  </properties>
 
-    <dependencies>
+  <dependencies>
 
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>io.netty</groupId>
-            <artifactId>netty-transport</artifactId>
-            <version>${netty-version}</version>
-        </dependency>
-        <dependency>
-            <groupId>io.netty</groupId>
-            <artifactId>netty-handler</artifactId>
-            <version>${netty-version}</version>
-        </dependency>
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-            <version>${gson-version}</version>
-        </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>io.netty</groupId>
+      <artifactId>netty-transport</artifactId>
+      <version>${netty-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>io.netty</groupId>
+      <artifactId>netty-handler</artifactId>
+      <version>${netty-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+      <version>${gson-version}</version>
+    </dependency>
 
-        <!-- test dependencies -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-test</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <scope>test</scope>
-        </dependency>
-    </dependencies>
+    <!-- test dependencies -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
 
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/f496aac7/components/camel-lumberjack/src/main/docs/lumberjack.adoc
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/docs/lumberjack.adoc b/components/camel-lumberjack/src/main/docs/lumberjack.adoc
index 8d87a21..bc92bbd 100644
--- a/components/camel-lumberjack/src/main/docs/lumberjack.adoc
+++ b/components/camel-lumberjack/src/main/docs/lumberjack.adoc
@@ -47,6 +47,7 @@ The Lumberjack component has no options.
 
 
 
+
 // endpoint options: START
 The Lumberjack component supports 7 endpoint options which are listed below:
 
@@ -54,10 +55,10 @@ The Lumberjack component supports 7 endpoint options which are listed below:
 [width="100%",cols="2s,1,1m,1m,5",options="header"]
 |=======================================================================
 | Name | Group | Default | Java Type | Description
-| host | common |  | String | *Required* Network interface on which to listen for Lumberjack
-| port | common | 5044 | int | Network port on which to listen for Lumberjack
-| sslContextParameters | common |  | SSLContextParameters | SSL configuration
+| host | consumer |  | String | *Required* Network interface on which to listen for Lumberjack
+| port | consumer | 5044 | int | Network port on which to listen for Lumberjack
 | bridgeErrorHandler | consumer | false | boolean | Allows for bridging the consumer to the Camel routing Error Handler which mean any exceptions occurred while the consumer is trying to pickup incoming messages or the likes will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions that will be logged at WARN/ERROR level and ignored.
+| sslContextParameters | consumer |  | SSLContextParameters | SSL configuration
 | exceptionHandler | consumer (advanced) |  | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
 | exchangePattern | advanced | InOnly | ExchangePattern | Sets the default exchange pattern when creating an exchange
 | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
@@ -68,6 +69,7 @@ The Lumberjack component supports 7 endpoint options which are listed below:
 
 
 
+
 [[Lumberjack-Result]]
 Result
 ^^^^^^

http://git-wip-us.apache.org/repos/asf/camel/blob/f496aac7/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java
index 83e9e4e..096d10f 100644
--- a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackComponent.java
@@ -24,7 +24,7 @@ import org.apache.camel.impl.UriEndpointComponent;
 /**
  * The class is the Camel component for the Lumberjack server
  */
-public final class LumberjackComponent extends UriEndpointComponent {
+public class LumberjackComponent extends UriEndpointComponent {
     static final int DEFAULT_PORT = 5044;
 
     public LumberjackComponent() {

http://git-wip-us.apache.org/repos/asf/camel/blob/f496aac7/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java
index fd3fc78..48c5010 100644
--- a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackConsumer.java
@@ -26,10 +26,10 @@ import org.apache.camel.component.lumberjack.io.LumberjackServer;
 import org.apache.camel.impl.DefaultConsumer;
 import org.apache.camel.util.concurrent.CamelThreadFactory;
 
-final class LumberjackConsumer extends DefaultConsumer {
+public class LumberjackConsumer extends DefaultConsumer {
     private final LumberjackServer lumberjackServer;
 
-    LumberjackConsumer(LumberjackEndpoint endpoint, Processor processor, String host, int port, SSLContext sslContext) {
+    public LumberjackConsumer(LumberjackEndpoint endpoint, Processor processor, String host, int port, SSLContext sslContext) {
         super(endpoint, processor);
         lumberjackServer = new LumberjackServer(host, port, sslContext, getThreadFactory(), this::onMessageReceived);
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/f496aac7/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java
index 0db9dbd..a86fe14 100644
--- a/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java
+++ b/components/camel-lumberjack/src/main/java/org/apache/camel/component/lumberjack/LumberjackEndpoint.java
@@ -5,9 +5,9 @@
  * 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
+ *
+ *      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.
@@ -27,8 +27,9 @@ import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
 import org.apache.camel.util.jsse.SSLContextParameters;
 
-@UriEndpoint(scheme = "lumberjack", title = "Lumberjack", syntax = "lumberjack:host:port", consumerClass = LumberjackConsumer.class, label = "log")
-final class LumberjackEndpoint extends DefaultEndpoint {
+@UriEndpoint(scheme = "lumberjack", title = "Lumberjack", syntax = "lumberjack:host:port",
+        consumerOnly = true, consumerClass = LumberjackConsumer.class, label = "log")
+public class LumberjackEndpoint extends DefaultEndpoint {
     @UriPath(description = "Network interface on which to listen for Lumberjack")
     @Metadata(required = "true")
     private final String host;

http://git-wip-us.apache.org/repos/asf/camel/blob/f496aac7/components/camel-lumberjack/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/resources/log4j.properties b/components/camel-lumberjack/src/test/resources/log4j.properties
index 4321049..6827323 100644
--- a/components/camel-lumberjack/src/test/resources/log4j.properties
+++ b/components/camel-lumberjack/src/test/resources/log4j.properties
@@ -16,14 +16,12 @@
 ## ------------------------------------------------------------------------
 
 #
-# The logging properties used for eclipse testing, We want to see debug output on the console.
+# The logging properties used for testing
 #
 log4j.rootLogger=INFO, file
 
 # uncomment the following to enable camel debugging
-log4j.logger.org.apache.camel.component.lucene=DEBUG
-#log4j.logger.org.apache.camel=DEBUG
-#log4j.logger.org.apache.commons.net=TRACE
+log4j.logger.org.apache.camel.component.lumberjack=DEBUG
 
 # CONSOLE appender not used by default
 log4j.appender.out=org.apache.log4j.ConsoleAppender

http://git-wip-us.apache.org/repos/asf/camel/blob/f496aac7/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelLumberjackTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelLumberjackTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelLumberjackTest.java
new file mode 100644
index 0000000..1deb8fd
--- /dev/null
+++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelLumberjackTest.java
@@ -0,0 +1,48 @@
+/**
+ * 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.itest.springboot;
+
+import org.apache.camel.itest.springboot.util.ArquillianPackager;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+@RunWith(Arquillian.class)
+public class CamelLumberjackTest extends AbstractSpringBootTestSupport {
+
+    @Deployment
+    public static Archive<?> createSpringBootPackage() throws Exception {
+        return ArquillianPackager.springBootPackage(createTestConfig());
+    }
+
+    public static ITestConfig createTestConfig() {
+        return new ITestConfigBuilder()
+                .module(inferModuleName(CamelLumberjackTest.class))
+                .build();
+    }
+
+    @Test
+    public void componentTests() throws Exception {
+        this.runComponentTest(config);
+        this.runModuleUnitTestsIfEnabled(config);
+    }
+
+
+}


[2/4] camel git commit: Add Lumberjack component

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjacksComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjacksComponentTest.java b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjacksComponentTest.java
new file mode 100644
index 0000000..29e9397
--- /dev/null
+++ b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/LumberjacksComponentTest.java
@@ -0,0 +1,109 @@
+/**
+ * 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.lumberjack;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.jsse.KeyManagersParameters;
+import org.apache.camel.util.jsse.KeyStoreParameters;
+import org.apache.camel.util.jsse.SSLContextParameters;
+import org.apache.camel.util.jsse.TrustManagersParameters;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+@SuppressWarnings("unchecked")
+public class LumberjacksComponentTest extends CamelTestSupport {
+    private static int port;
+
+    @BeforeClass
+    public static void beforeClass() {
+        port = AvailablePortFinder.getNextAvailable();
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        registry.bind("ssl", createServerSSLContextParameters());
+        return registry;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                // Lumberjack configured with SSL
+                from("lumberjacks:0.0.0.0:" + port + "?sslContextParameters=#ssl").to("mock:output");
+            }
+        };
+    }
+
+    @Test
+    public void shouldListenToMessagesOverSSL() throws Exception {
+        // We're expecting 25 messages with Maps
+        MockEndpoint mock = getMockEndpoint("mock:output");
+        mock.expectedMessageCount(25);
+        mock.allMessages().body().isInstanceOf(Map.class);
+
+        // When sending messages
+        List<Integer> responses = LumberjackUtil.sendMessages(port, createClientSSLContextParameters());
+
+        // Then we should have the messages we're expecting
+        mock.assertIsSatisfied();
+
+        // And we should have replied with 2 acknowledgments for each window frame
+        assertEquals(responses, Arrays.asList(10, 15));
+    }
+
+    /**
+     * Creates the {@link SSLContextParameters} Camel object for the Lumberjack component
+     *
+     * @return The {@link SSLContextParameters} Camel object for the Lumberjack component
+     */
+    private SSLContextParameters createServerSSLContextParameters() {
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+
+        KeyManagersParameters keyManagersParameters = new KeyManagersParameters();
+        KeyStoreParameters keyStore = new KeyStoreParameters();
+        keyStore.setPassword("changeit");
+        keyStore.setResource("org/apache/camel/component/lumberjack/keystore.jks");
+        keyManagersParameters.setKeyPassword("changeit");
+        keyManagersParameters.setKeyStore(keyStore);
+        sslContextParameters.setKeyManagers(keyManagersParameters);
+
+        return sslContextParameters;
+    }
+
+    private SSLContextParameters createClientSSLContextParameters() {
+        SSLContextParameters sslContextParameters = new SSLContextParameters();
+
+        TrustManagersParameters trustManagersParameters = new TrustManagersParameters();
+        KeyStoreParameters trustStore = new KeyStoreParameters();
+        trustStore.setPassword("changeit");
+        trustStore.setResource("org/apache/camel/component/lumberjack/keystore.jks");
+        trustManagersParameters.setKeyStore(trustStore);
+        sslContextParameters.setTrustManagers(trustManagersParameters);
+
+        return sslContextParameters;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/io/LumberjackChannelInitializerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/io/LumberjackChannelInitializerTest.java b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/io/LumberjackChannelInitializerTest.java
new file mode 100644
index 0000000..873c0eb
--- /dev/null
+++ b/components/camel-lumberjack/src/test/java/org/apache/camel/component/lumberjack/io/LumberjackChannelInitializerTest.java
@@ -0,0 +1,81 @@
+/**
+ * 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.lumberjack.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.embedded.EmbeddedChannel;
+import org.junit.Test;
+
+import static io.netty.buffer.Unpooled.buffer;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.TYPE_ACKNOWLEDGE;
+import static org.apache.camel.component.lumberjack.io.LumberjackConstants.VERSION_V2;
+import static org.junit.Assert.assertEquals;
+
+@SuppressWarnings("unchecked")
+public class LumberjackChannelInitializerTest {
+    @Test
+    public void shouldDecodeTwoWindowsWithCompressedMessages() throws Exception {
+        // Given a properly configured netty channel
+        List<Object> messages = new ArrayList<>();
+        EmbeddedChannel channel = new EmbeddedChannel(new LumberjackChannelInitializer(null, null, (payload, callback) -> {
+            messages.add(payload);
+            callback.onComplete(true);
+        }));
+
+        // When writing the stream byte per byte in order to ensure that we support splits everywhere
+        // It contains 2 windows with compressed messages
+        writeResourceBytePerByte(channel, "window10");
+        writeResourceBytePerByte(channel, "window15");
+
+        // Then we must have 25 messages with only maps
+        assertEquals(25, messages.size());
+
+        // And the first map should contains valid data (we're assuming it's also valid for the other ones)
+        Map first = (Map) messages.get(0);
+        assertEquals("log", first.get("type"));
+        assertEquals("/home/qatest/collectNetwork/log/data-integration/00000000-f000-0000-1541-8da26f200001/absorption.log", first.get("source"));
+
+        // And we should have replied twice (one per window)
+        assertEquals(2, channel.outboundMessages().size());
+        checkAck((ByteBuf) channel.outboundMessages().poll(), 10);
+        checkAck((ByteBuf) channel.outboundMessages().poll(), 15);
+    }
+
+    private void writeResourceBytePerByte(EmbeddedChannel channel, String resource) throws IOException {
+        try (InputStream stream = getClass().getResourceAsStream(resource)) {
+            int input;
+            while ((input = stream.read()) != -1) {
+                ByteBuf buffer = buffer(1, 1);
+                buffer.writeByte(input);
+                channel.writeInbound(buffer);
+            }
+        }
+    }
+
+    private void checkAck(ByteBuf buf, int sequence) {
+        assertEquals("version", (short) VERSION_V2, buf.readUnsignedByte());
+        assertEquals("frame", (short) TYPE_ACKNOWLEDGE, buf.readUnsignedByte());
+        assertEquals("sequence", sequence, buf.readInt());
+        assertEquals("remaining", 0, buf.readableBytes());
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/resources/log4j.properties b/components/camel-lumberjack/src/test/resources/log4j.properties
new file mode 100644
index 0000000..4321049
--- /dev/null
+++ b/components/camel-lumberjack/src/test/resources/log4j.properties
@@ -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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, file
+
+# uncomment the following to enable camel debugging
+log4j.logger.org.apache.camel.component.lucene=DEBUG
+#log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.org.apache.commons.net=TRACE
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+#log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.file.file=target/camel-lumberjack-test.log

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/test/resources/org/apache/camel/component/lumberjack/io/window10
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/resources/org/apache/camel/component/lumberjack/io/window10 b/components/camel-lumberjack/src/test/resources/org/apache/camel/component/lumberjack/io/window10
new file mode 100644
index 0000000..610d112
Binary files /dev/null and b/components/camel-lumberjack/src/test/resources/org/apache/camel/component/lumberjack/io/window10 differ

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/test/resources/org/apache/camel/component/lumberjack/io/window15
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/resources/org/apache/camel/component/lumberjack/io/window15 b/components/camel-lumberjack/src/test/resources/org/apache/camel/component/lumberjack/io/window15
new file mode 100644
index 0000000..bee6f2f
Binary files /dev/null and b/components/camel-lumberjack/src/test/resources/org/apache/camel/component/lumberjack/io/window15 differ

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/camel-lumberjack/src/test/resources/org/apache/camel/component/lumberjack/keystore.jks
----------------------------------------------------------------------
diff --git a/components/camel-lumberjack/src/test/resources/org/apache/camel/component/lumberjack/keystore.jks b/components/camel-lumberjack/src/test/resources/org/apache/camel/component/lumberjack/keystore.jks
new file mode 100644
index 0000000..78e8571
Binary files /dev/null and b/components/camel-lumberjack/src/test/resources/org/apache/camel/component/lumberjack/keystore.jks differ

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index 41ad249..c742ff7 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -186,6 +186,7 @@
     <module>camel-leveldb</module>
     <module>camel-linkedin</module>
     <module>camel-lucene</module>
+    <module>camel-lumberjack</module>
     <module>camel-lzf</module>
     <module>camel-mail</module>
     <module>camel-metrics</module>

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index b36ca78..3984633 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1294,11 +1294,6 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
-        <artifactId>camel-lucene</artifactId>
-        <version>${project.version}</version>
-      </dependency>
-      <dependency>
-        <groupId>org.apache.camel</groupId>
         <artifactId>camel-ldap</artifactId>
         <version>${project.version}</version>
       </dependency>
@@ -1319,6 +1314,16 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-lucene</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-lumberjack</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-lzf</artifactId>
         <version>${project.version}</version>
       </dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/platforms/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/platforms/karaf/features/src/main/resources/features.xml b/platforms/karaf/features/src/main/resources/features.xml
index 66178c7..32b0c16 100644
--- a/platforms/karaf/features/src/main/resources/features.xml
+++ b/platforms/karaf/features/src/main/resources/features.xml
@@ -1105,6 +1105,17 @@
     <bundle dependency='true'>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jakarta-regexp/${regexp-bundle-version}</bundle>
     <bundle>mvn:org.apache.camel/camel-lucene/${project.version}</bundle>
   </feature>
+  <feature name='camel-lumberjack' version='${project.version}' resolver='(obr)' start-level='50'>
+    <feature version='${project.version}'>camel-core</feature>
+    <bundle dependency='true'>mvn:io.netty/netty-common/${netty-version}</bundle>
+    <bundle dependency='true'>mvn:io.netty/netty-buffer/${netty-version}</bundle>
+    <bundle dependency='true'>mvn:io.netty/netty-resolver/${netty-version}</bundle>
+    <bundle dependency='true'>mvn:io.netty/netty-transport/${netty-version}</bundle>
+    <bundle dependency='true'>mvn:io.netty/netty-handler/${netty-version}</bundle>
+    <bundle dependency='true'>mvn:io.netty/netty-codec/${netty-version}</bundle>
+    <bundle dependency='true'>mvn:com.google.code.gson/gson/${gson-version}</bundle>
+    <bundle>mvn:org.apache.camel/camel-lumberjack/${project.version}</bundle>
+  </feature>
   <feature name='camel-lzf' version='${project.version}' resolver='(obr)' start-level='50'>
     <feature version='${project.version}'>camel-core</feature>
     <bundle dependency='true'>mvn:com.ning/compress-lzf/${compress-lzf-version}</bundle>

http://git-wip-us.apache.org/repos/asf/camel/blob/3d0379d0/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelLumberjackTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelLumberjackTest.java b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelLumberjackTest.java
new file mode 100644
index 0000000..8ae807c
--- /dev/null
+++ b/tests/camel-itest-karaf/src/test/java/org/apache/camel/itest/karaf/CamelLumberjackTest.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.itest.karaf;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+
+@RunWith(PaxExam.class)
+public class CamelLumberjackTest extends BaseKarafTest {
+
+    public CamelLumberjackTest() {
+    }
+
+    public static final String COMPONENT = extractName(CamelLumberjackTest.class);
+
+    @Test
+    public void test() throws Exception {
+        testComponent(COMPONENT);
+    }
+}