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 2017/04/12 19:56:22 UTC

[03/11] camel git commit: polished

polished

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

Branch: refs/heads/master
Commit: a070919d3016b980ec7536547801ae7ef25b84b6
Parents: 1304292
Author: Preben Asmussen <pr...@gmail.com>
Authored: Tue Apr 11 10:21:21 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Apr 12 21:56:07 2017 +0200

----------------------------------------------------------------------
 .../src/main/docs/pubnub-component.adoc         | 143 +++++++++++++++++++
 .../component/pubnub/PubNubConfiguration.java   |  55 ++++---
 .../camel/component/pubnub/PubNubEndpoint.java  |   7 +-
 .../camel/component/pubnub/PubNubProducer.java  |  39 ++---
 .../pubnub/PubNubConfigurationTest.java         |  10 +-
 .../camel/component/pubnub/PubNubFireTest.java  |  69 +++++++++
 .../component/pubnub/PubNubOperationsTest.java  |  12 +-
 .../component/pubnub/PubNubPresensTest.java     |   2 +-
 .../component/pubnub/PubNubPublishTest.java     |   4 +-
 .../component/pubnub/PubNubSubscriberTest.java  |   2 +-
 .../pubnub/example/PubNubExampleConstants.java  |   6 +-
 .../example/PubNubGeoLocationExample.java       |  43 ++++++
 .../pubnub/example/PubNubPresenseExample.java   |   4 +-
 .../pubnub/example/PubNubSensor2Example.java    |  14 +-
 .../pubnub/example/PubNubSensorExample.java     |   2 +-
 .../src/test/resources/log4j2.properties        |   2 +-
 parent/pom.xml                                  |   2 +-
 17 files changed, 348 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/main/docs/pubnub-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/main/docs/pubnub-component.adoc b/components/camel-pubnub/src/main/docs/pubnub-component.adoc
new file mode 100644
index 0000000..ead5556
--- /dev/null
+++ b/components/camel-pubnub/src/main/docs/pubnub-component.adoc
@@ -0,0 +1,143 @@
+## PubNub Component
+
+*Available as of Camel version *
+
+Camel PubNub component can be used to communicate with the https://www.pubnub.com/[PubNub] data stream network for connected devices. This component uses pubnub https://github.com/pubnub/java[java library].
+
+### Use cases include
+
+** Chat rooms: Sending and receiving messages
+** Locations and Connected cars: dispatching taxi cabs
+** Smart sensors: Receiving data from a sensor for data visualizations
+** Health: Monitoring heart rate from a patient's wearable device
+** Multiplayer gamings
+** Interactive media: audience-participating voting system
+
+
+
+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-pubnub</artifactId>
+    <version>x.x.x</version>
+    <!-- use the same version as your Camel core version -->
+</dependency>
+------------------------------------------------------------
+
+### URI format
+
+[source,java]
+------------------------
+pubnub://channel[?options]
+------------------------
+
+Where *channel* is the PubNub channel to publish or subscribe to.
+
+### Options
+
+
+// component options: START
+The PubNub component has no options.
+// component options: END
+
+
+
+// endpoint options: START
+The PubNub endpoint is configured using URI syntax:
+
+    pubnub://channel
+
+with the following path and query parameters:
+
+#### Path Parameters (1 parameters):
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|=======================================================================
+| Name | Description | Default | Type
+| **channel** | *Required* The channel used for subscribing/publishing events |  | String
+|=======================================================================
+
+#### Query Parameters (14 parameters):
+
+[width="100%",cols="2,5,^1,2",options="header"]
+|=======================================================================
+| Name | Description | Default | Type
+| **pubnub** (common) | Reference to a Pubnub client in the registry. |  | PubNub
+| **secure** (common) | Use ssl | true | boolean
+| **uuid** (common) | UUID to be used as a device identifier a default UUID is generated if not passed. |  | String
+| **bridgeErrorHandler** (consumer) | 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 or ERROR level and ignored. | false | boolean
+| **withPresence** (consumer) | Also subscribe to related presence information | false | boolean
+| **exceptionHandler** (consumer) | 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 or ERROR level and ignored. |  | ExceptionHandler
+| **exchangePattern** (consumer) | Sets the exchange pattern when the consumer creates an exchange. |  | ExchangePattern
+| **operation** (producer) | The operation to perform. PUBLISH: Default. Send a message to all subscribers of a channel. FIRE: allows the client to send a message to BLOCKS Event Handlers. These messages will go directly to any Event Handlers registered on the channel that you fire to and will trigger their execution HERENOW: Obtain information about the current state of a channel including a list of unique user-ids currently subscribed to the channel and the total occupancy count. WHERENOW: Obtain information about the current list of channels to which a uuid is subscribed to. GETSTATE: Used to get key/value pairs specific to a subscriber uuid. State information is supplied as a JSON object of key/value pairs SETSTATE: Used to set key/value pairs specific to a subscriber uuid GETHISTORY: Fetches historical messages of a channel. |  | String
+| **synchronous** (advanced) | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported). | false | boolean
+| **authKey** (security) | If Access Manager is utilized client will use this authKey in all restricted requests. |  | String
+| **cipherKey** (security) | If cipher is passed all communicatons to/from PubNub will be encrypted. |  | String
+| **publishKey** (security) | The publish key obtained from your PubNub account. Required when publishing messages. |  | String
+| **secretKey** (security) | The secret key used for message signing. |  | String
+| **subscribeKey** (security) | The subscribe key obtained from your PubNub account. Required when subscribing to channels or listening for presence events |  | String
+|=======================================================================
+// endpoint options: END
+
+### Message headers when subscribing
+
+[width="100%",cols="20%,80%",options="header",]
+|=======================================================================
+|Name |Description
+|`CamelPubNubTimeToken` |The Timestamp for the event.
+
+|`CamelPubNubChannel` |The channel for which the message belongs.
+
+### Messsage body
+The message body can contain any JSON serializable data, including: Objects, Arrays, Ints and Strings. Message data should not contain special Java V4 classes or functions as these will not serialize. String content can include any single-byte or multi-byte UTF-8
+
+Object serialization when sending is done automatically. Just pass the full object as the message payload. PubNub will takes care of object serialization.
+
+When receiving the message body utilize objects provided by the PubNub API.
+
+### Use cases
+
+#### Publishing events
+
+Default operation when producing.
+The following snippet publish the event DeviceInfo to the channel iot.
+
+[source,java]
+----
+from("timer:mytimer")
+    // generate some data as POJO.
+    .bean(PojoBean.class)
+    .to("pubnub://iot?publishKey=mypublishKey");
+----
+
+#### Subscribing to events
+
+The following snippet listens for events on the iot channel.
+If you can add the option withPresens, you will also receive channel Join, Leave asf events. 
+
+[source,java]
+----
+from("pubnub://iot?subscribeKey=mySubscribeKey")
+    .log("${body}")
+    .to("mock:result");
+----
+
+There is a couple of examples in test directory that shows some of the PubNub features. 
+They require a PubNub account, from where you can obtain a publish- and subscribe key.
+ 
+The example PubNubSensorExample already contains a subscribe key provided by PubNub, so this is ready to run without a account. 
+The example illustrates the PubNub component subscribing to a infinite stream of sensor data.
+
+
+### See Also
+
+* link:configuring-camel.html[Configuring Camel]
+* link:component.html[Component]
+* link:endpoint.html[Endpoint]
+* link:getting-started.html[Getting Started]
+
+* link:rss.html[RSS]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConfiguration.java b/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConfiguration.java
index 65342fa..b9a0ad6 100644
--- a/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConfiguration.java
+++ b/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConfiguration.java
@@ -29,25 +29,28 @@ public class PubNubConfiguration {
     @Metadata(required = "true")
     private String channel;
 
-    @UriParam()
-    private String publisherKey;
+    @UriParam(label = "security", secret = true)
+    private String publishKey;
 
-    @UriParam()
-    private String subscriberKey;
+    @UriParam(label = "security", secret = true)
+    private String subscribeKey;
 
-    @UriParam()
+    @UriParam(label = "security", secret = true)
     private String secretKey;
 
-    @UriParam()
+    @UriParam(label = "security", secret = true)
     private String authKey;
 
+    @UriParam(label = "security", secret = true)
+    private String cipherKey;
+
     @UriParam(defaultValue = "true")
     private boolean secure = true;
 
     @UriParam()
     private String uuid;
 
-    @UriParam(label = "producer", enums = "HERE_NOW,WHERE_NOW,GET_STATE,SET_STATE,GET_HISTORY,PUBLISH,FIRE")
+    @UriParam(label = "producer", enums = "HERENOW,WHERENOW,GETSTATE,SETSTATE,GETHISTORY,PUBLISH,FIRE")
     private String operation;
 
     @UriParam(label = "consumer", defaultValue = "false")
@@ -56,23 +59,23 @@ public class PubNubConfiguration {
     /**
      * The publish key obtained from your PubNub account. Required when publishing messages.
      */
-    public String getPublisherKey() {
-        return this.publisherKey;
+    public String getPublishKey() {
+        return this.publishKey;
     }
 
-    public void setPublisherKey(String publisherKey) {
-        this.publisherKey = publisherKey;
+    public void setPublishKey(String publishKey) {
+        this.publishKey = publishKey;
     }
 
     /**
      * The subscribe key obtained from your PubNub account. Required when subscribing to channels or listening for presence events
      */
-    public String getSubscriberKey() {
-        return this.subscriberKey;
+    public String getSubscribeKey() {
+        return this.subscribeKey;
     }
 
-    public void setSubscriberKey(String subscriberKey) {
-        this.subscriberKey = subscriberKey;
+    public void setSubscribeKey(String subscribeKey) {
+        this.subscribeKey = subscribeKey;
     }
 
     /**
@@ -98,6 +101,17 @@ public class PubNubConfiguration {
     }
 
     /**
+     * If cipher is passed, all communicatons to/from PubNub will be encrypted.
+     */
+    public String getCipherKey() {
+        return cipherKey;
+    }
+
+    public void setCipherKey(String cipherKey) {
+        this.cipherKey = cipherKey;
+    }
+
+    /**
      * Use ssl
      */
     public boolean isSecure() {
@@ -120,7 +134,7 @@ public class PubNubConfiguration {
     }
 
     /**
-     * The uuid identifying the connection. Will be auto assigned if not set.
+     * UUID to be used as a device identifier, a default UUID is generated if not passed.
      */
     public void setUuid(String uuid) {
         this.uuid = uuid;
@@ -132,6 +146,15 @@ public class PubNubConfiguration {
 
     /**
      * The operation to perform.
+     * <ul>
+     * <li>PUBLISH: Default. Send a message to all subscribers of a channel.</li>
+     * <li>FIRE: allows the client to send a message to BLOCKS Event Handlers. These messages will go directly to any Event Handlers registered on the channel that you fire to and will trigger their execution,</li>
+     * <li>HERENOW: Obtain information about the current state of a channel including a list of unique user-ids currently subscribed to the channel and the total occupancy count.</li>
+     * <li>WHERENOW: Obtain information about the current list of channels to which a uuid is subscribed to.</li>
+     * <li>GETSTATE: Used to get key/value pairs specific to a subscriber uuid. State information is supplied as a JSON object of key/value pairs</li>
+     * <li>SETSTATE: Used to set key/value pairs specific to a subscriber uuid</li>
+     * <li>GETHISTORY: Fetches historical messages of a channel.</li>
+     * </ul>
      */
     public void setOperation(String operation) {
         this.operation = operation;

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubEndpoint.java b/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubEndpoint.java
index a58b41b..a592e7a 100644
--- a/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubEndpoint.java
+++ b/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubEndpoint.java
@@ -28,7 +28,7 @@ import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.util.ObjectHelper;
 
-@UriEndpoint(scheme = "pubnub", title = "PubNub", syntax = "pubnub:endpointType:channel", consumerClass = PubNubConsumer.class, label = "cloud,iot,messaging")
+@UriEndpoint(scheme = "pubnub", title = "PubNub", syntax = "pubnub://channel", consumerClass = PubNubConsumer.class, label = "cloud,iot,messaging")
 public class PubNubEndpoint extends DefaultEndpoint {
 
     @UriParam
@@ -93,10 +93,11 @@ public class PubNubEndpoint extends DefaultEndpoint {
     private PubNub getInstance() {
         PubNub answer = null;
         PNConfiguration pnConfiguration = new PNConfiguration();
-        pnConfiguration.setPublishKey(configuration.getPublisherKey());
-        pnConfiguration.setSubscribeKey(configuration.getSubscriberKey());
+        pnConfiguration.setPublishKey(configuration.getPublishKey());
+        pnConfiguration.setSubscribeKey(configuration.getSubscribeKey());
         pnConfiguration.setSecretKey(configuration.getSecretKey());
         pnConfiguration.setAuthKey(configuration.getAuthKey());
+        pnConfiguration.setCipherKey(configuration.getCipherKey());
         pnConfiguration.setSecure(configuration.isSecure());
         if (ObjectHelper.isNotEmpty(configuration.getUuid())) {
             pnConfiguration.setUuid(configuration.getUuid());

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubProducer.java b/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubProducer.java
index 29665e2..4e688d4 100644
--- a/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubProducer.java
+++ b/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubProducer.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.pubnub;
 
 import java.util.Arrays;
 
+import com.pubnub.api.PubNubException;
 import com.pubnub.api.callbacks.PNCallback;
 import com.pubnub.api.models.consumer.PNPublishResult;
 import com.pubnub.api.models.consumer.PNStatus;
@@ -65,29 +66,36 @@ public class PubNubProducer extends DefaultAsyncProducer {
             doFire(exchange, callback);
             break;
         }
-        case GET_HISTORY: {
+        case GETHISTORY: {
             doGetHistory(exchange, callback);
             break;
         }
-        case GET_STATE: {
+        case GETSTATE: {
             doGetState(exchange, callback);
             break;
         }
-        case HERE_NOW: {
+        case HERENOW: {
             doHereNow(exchange, callback);
             break;
         }
-        case SET_STATE: {
+        case SETSTATE: {
             doSetState(exchange, callback);
             break;
         }
-        case WHERE_NOW: {
+        case WHERENOW: {
             doWhereNow(exchange, callback);
             break;
         }
         default:
             throw new UnsupportedOperationException(operation.toString());
         }
+        if (exchange.getException() != null) {
+            if (exchange.getException() instanceof PubNubException) {
+                LOG.error("Exception from PubNub : {}", exchange.getException(PubNubException.class).getPubnubError().getMessage());
+            }
+            callback.done(true);
+            return true;
+        }
         return false;
     }
 
@@ -138,7 +146,6 @@ public class PubNubProducer extends DefaultAsyncProducer {
     }
 
     private void doGetHistory(Exchange exchange, AsyncCallback callback) {
-        // @formatter:off
         endpoint.getPubnub()
             .history()
             .channel(getChannel(exchange))
@@ -149,7 +156,6 @@ public class PubNubProducer extends DefaultAsyncProducer {
                     processMessage(exchange, callback, status, result.getMessages());
                 }
             });
-    // @formatter:on
     }
 
     private void doSetState(Exchange exchange, AsyncCallback callback) {
@@ -173,7 +179,6 @@ public class PubNubProducer extends DefaultAsyncProducer {
     }
 
     private void doGetState(Exchange exchange, AsyncCallback callback) {
-        // @formatter:off
         endpoint.getPubnub()
             .getPresenceState()
             .channels(Arrays.asList(getChannel(exchange)))
@@ -185,7 +190,6 @@ public class PubNubProducer extends DefaultAsyncProducer {
                     processMessage(exchange, callback, status, result.getStateByUUID());
                 }
             });
-    // @formatter:on
     }
 
     private void doHereNow(Exchange exchange, AsyncCallback callback) {
@@ -204,7 +208,6 @@ public class PubNubProducer extends DefaultAsyncProducer {
     }
 
     private void doWhereNow(Exchange exchange, AsyncCallback callback) {
-        // @formatter:off
         endpoint.getPubnub()
             .whereNow()
             .uuid(getUUID(exchange))
@@ -215,21 +218,19 @@ public class PubNubProducer extends DefaultAsyncProducer {
                     processMessage(exchange, callback, status, result.getChannels());
                 };
             });
-        // @formatter:on
     }
 
     private void processMessage(Exchange exchange, AsyncCallback callback, PNStatus status, Object body) {
         if (status.isError()) {
             exchange.setException(status.getErrorData().getThrowable());
-            callback.done(true);
-        } else if (body != null) {
-            exchange.getIn().setBody(body);
+            callback.done(false);
+            return;
         }
         if (exchange.getPattern().isOutCapable()) {
             exchange.getOut().copyFrom(exchange.getIn());
-            if (body != null) {
-                exchange.getOut().setBody(body);
-            }
+            exchange.getOut().setBody(body);
+        } else {
+            exchange.getIn().setBody(body);
         }
 
         // signal exchange completion
@@ -241,7 +242,7 @@ public class PubNubProducer extends DefaultAsyncProducer {
         if (operation == null) {
             operation = pubnubConfiguration.getOperation();
         }
-        return operation != null ? Operation.valueOf(operation) : Operation.PUBLISH;
+        return operation != null ? Operation.valueOf(operation.toUpperCase()) : Operation.PUBLISH;
     }
 
     private String getChannel(Exchange exchange) {
@@ -255,6 +256,6 @@ public class PubNubProducer extends DefaultAsyncProducer {
     }
 
     private enum Operation {
-        HERE_NOW, WHERE_NOW, GET_STATE, SET_STATE, GET_HISTORY, PUBLISH, FIRE;
+        HERENOW, WHERENOW, GETSTATE, SETSTATE, GETHISTORY, PUBLISH, FIRE;
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubConfigurationTest.java b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubConfigurationTest.java
index 20ddd24..12aca16 100644
--- a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubConfigurationTest.java
+++ b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubConfigurationTest.java
@@ -30,10 +30,10 @@ public class PubNubConfigurationTest extends CamelTestSupport {
     @Test
     public void createEndpointWithMinimalConfiguration() throws Exception {
         PubNubComponent component = new PubNubComponent(context);
-        PubNubEndpoint endpoint = (PubNubEndpoint) component.createEndpoint("pubnub:xxx?subscriberKey=mysubkey");
+        PubNubEndpoint endpoint = (PubNubEndpoint) component.createEndpoint("pubnub://xxx?subscribeKey=mysubkey");
 
         assertEquals("xxx", endpoint.getConfiguration().getChannel());
-        assertEquals("mysubkey", endpoint.getConfiguration().getSubscriberKey());
+        assertEquals("mysubkey", endpoint.getConfiguration().getSubscribeKey());
         assertTrue(endpoint.getConfiguration().isSecure());
     }
 
@@ -41,11 +41,11 @@ public class PubNubConfigurationTest extends CamelTestSupport {
     public void createEndpointWithMaximalConfiguration() throws Exception {
         PubNubComponent component = new PubNubComponent(context);
         PubNubEndpoint endpoint = (PubNubEndpoint)component
-            .createEndpoint("pubnub:xxx?subscriberKey=mysubkey&publisherKey=mypubkey&secretKey=secrets&uuid=myuuid&operation=PUBLISH&secure=false&authKey=authKey");
+            .createEndpoint("pubnub://xxx?subscribeKey=mysubkey&publishKey=mypubkey&secretKey=secrets&uuid=myuuid&operation=PUBLISH&secure=false&authKey=authKey");
 
         assertEquals("xxx", endpoint.getConfiguration().getChannel());
-        assertEquals("mysubkey", endpoint.getConfiguration().getSubscriberKey());
-        assertEquals("mypubkey", endpoint.getConfiguration().getPublisherKey());
+        assertEquals("mysubkey", endpoint.getConfiguration().getSubscribeKey());
+        assertEquals("mypubkey", endpoint.getConfiguration().getPublishKey());
         assertEquals("secrets", endpoint.getConfiguration().getSecretKey());
         assertEquals("myuuid", endpoint.getConfiguration().getUuid());
         assertEquals("PUBLISH", endpoint.getConfiguration().getOperation());

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubFireTest.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubFireTest.java b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubFireTest.java
new file mode 100644
index 0000000..3407fcd
--- /dev/null
+++ b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubFireTest.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.pubnub;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+
+import static org.apache.camel.component.pubnub.PubNubConstants.TIMETOKEN;
+
+public class PubNubFireTest extends PubNubTestBase {
+    private String endpoint = "pubnub://someChannel?operation=fire&pubnub=#pubnub";
+
+    @EndpointInject(uri = "mock:result")
+    private MockEndpoint mockResult;
+
+    @Test
+    public void testFire() throws Exception {
+        stubFor(get(urlPathEqualTo("/publish/myPublishKey/mySubscribeKey/0/someChannel/0/%22Hi%22"))
+            .willReturn(aResponse().withBody("[1,\"Sent\",\"14598111595318003\"]")));
+        mockResult.expectedMessageCount(1);
+        mockResult.expectedHeaderReceived(TIMETOKEN, "14598111595318003");
+
+        template.sendBody("direct:publish", "Hi");
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:publish").to(endpoint).to("mock:result");
+            }
+        };
+    }
+
+    static class Hello {
+        private String message;
+
+        Hello(String message) {
+            this.message = message;
+        }
+
+        public String getMessage() {
+            return message;
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubOperationsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubOperationsTest.java b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubOperationsTest.java
index d0406db..4258ff1 100644
--- a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubOperationsTest.java
+++ b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubOperationsTest.java
@@ -44,7 +44,7 @@ public class PubNubOperationsTest extends PubNubTestBase {
             .willReturn(aResponse().withBody("{\"status\": 200, \"message\": \"OK\", \"payload\": {\"channels\": [\"channel-a\",\"channel-b\"]}, \"service\": \"Presence\"}")));
 
         Map<String, Object> headers = new HashMap<String, Object>();
-        headers.put(PubNubConstants.OPERATION, "WHERE_NOW");
+        headers.put(PubNubConstants.OPERATION, "WHERENOW");
         headers.put(PubNubConstants.UUID, "myUUID");
         @SuppressWarnings("unchecked")
         List<String> response = template.requestBodyAndHeaders("direct:publish", null, headers, List.class);
@@ -60,7 +60,7 @@ public class PubNubOperationsTest extends PubNubTestBase {
                       + "\"uuid\" : \"myUUID1\"}, {\"uuid\" : \"b9eb408c-bcec-4d34-b4c4-fabec057ad0d\"}, {\"state\" : {\"abcd\" : {\"age\" : 15}}, \"uuid\" : \"myUUID2\"},"
                       + " {\"state\" : {\"abcd\" : {\"age\" : 24}}, \"uuid\" : \"myUUID9\"}], \"occupancy\" : 5} Return Occupancy O")));
         Map<String, Object> headers = new HashMap<String, Object>();
-        headers.put(PubNubConstants.OPERATION, "HERE_NOW");
+        headers.put(PubNubConstants.OPERATION, "HERENOW");
         PNHereNowResult response = template.requestBodyAndHeaders("direct:publish", null, headers, PNHereNowResult.class);
         assertNotNull(response);
         assertEquals(5, response.getTotalOccupancy());
@@ -95,7 +95,7 @@ public class PubNubOperationsTest extends PubNubTestBase {
         stubFor(get(urlPathEqualTo("/v2/history/sub-key/mySubscribeKey/channel/myChannel")).willReturn(aResponse().withBody(getPubnub().getMapper().toJson(testArray))));
 
         Map<String, Object> headers = new HashMap<String, Object>();
-        headers.put(PubNubConstants.OPERATION, "GET_HISTORY");
+        headers.put(PubNubConstants.OPERATION, "GETHISTORY");
         @SuppressWarnings("unchecked")
         List<PNHistoryItemResult> response = template.requestBodyAndHeaders("direct:publish", null, headers, List.class);
         assertNotNull(response);
@@ -108,7 +108,7 @@ public class PubNubOperationsTest extends PubNubTestBase {
             .withBody("{ \"status\": 200, \"message\": \"OK\", \"payload\": "
                       + "{ \"myChannel\": { \"age\" : 20, \"status\" : \"online\"}, \"ch2\": { \"age\": 100, \"status\": \"offline\" } }, \"service\": \"Presence\"}")));
         Map<String, Object> headers = new HashMap<String, Object>();
-        headers.put(PubNubConstants.OPERATION, "GET_STATE");
+        headers.put(PubNubConstants.OPERATION, "GETSTATE");
         @SuppressWarnings("unchecked")
         Map<String, JsonObject> response = template.requestBodyAndHeaders("direct:publish", null, headers, Map.class);
         assertNotNull(response);
@@ -122,7 +122,7 @@ public class PubNubOperationsTest extends PubNubTestBase {
         Map<String, Object> myState = new HashMap<>();
         myState.put("age", 20);
         Map<String, Object> headers = new HashMap<String, Object>();
-        headers.put(PubNubConstants.OPERATION, "SET_STATE");
+        headers.put(PubNubConstants.OPERATION, "SETSTATE");
         PNSetStateResult response = template.requestBodyAndHeaders("direct:publish", myState, headers, PNSetStateResult.class);
         assertNotNull(response);
         assertNotNull(response.getState());
@@ -133,7 +133,7 @@ public class PubNubOperationsTest extends PubNubTestBase {
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
-                from("direct:publish").to("pubnub:myChannel?uuid=myuuid&pubnub=#pubnub")
+                from("direct:publish").to("pubnub://myChannel?uuid=myuuid&pubnub=#pubnub")
                     .to("mock:result");
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPresensTest.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPresensTest.java b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPresensTest.java
index 252a894..775b233 100644
--- a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPresensTest.java
+++ b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPresensTest.java
@@ -60,7 +60,7 @@ public class PubNubPresensTest extends PubNubTestBase {
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
-                from("pubnub:mychannel?pubnub=#pubnub&withPresence=true").id("presence-route")
+                from("pubnub://mychannel?pubnub=#pubnub&withPresence=true").id("presence-route")
                     .autoStartup(false)
                     .to("mock:result");
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPublishTest.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPublishTest.java b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPublishTest.java
index 8b3d9f0..535f25c 100644
--- a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPublishTest.java
+++ b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubPublishTest.java
@@ -31,7 +31,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
 import static org.apache.camel.component.pubnub.PubNubConstants.TIMETOKEN;
 
 public class PubNubPublishTest extends PubNubTestBase {
-    private String endpoint = "pubnub:someChannel?pubnub=#pubnub";
+    private String endpoint = "pubnub://someChannel?pubnub=#pubnub";
 
     @EndpointInject(uri = "mock:result")
     private MockEndpoint mockResult;
@@ -59,7 +59,7 @@ public class PubNubPublishTest extends PubNubTestBase {
     }
 
     @Test
-    public void testFire() throws Exception {
+    public void testFireWithOperationHeader() throws Exception {
         stubFor(get(urlPathEqualTo("/publish/myPublishKey/mySubscribeKey/0/someChannel/0/%22Hi%22"))
             .willReturn(aResponse().withBody("[1,\"Sent\",\"14598111595318003\"]")));
         mockResult.expectedMessageCount(1);

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubSubscriberTest.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubSubscriberTest.java b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubSubscriberTest.java
index 5202401..43a4ce8 100644
--- a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubSubscriberTest.java
+++ b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubSubscriberTest.java
@@ -51,7 +51,7 @@ public class PubNubSubscriberTest extends PubNubTestBase {
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
-                from("pubnub:mychannel?pubnub=#pubnub").id("subroute").autoStartup(false)
+                from("pubnub://mychannel?pubnub=#pubnub").id("subroute").autoStartup(false)
                     .to("mock:result");
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubExampleConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubExampleConstants.java b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubExampleConstants.java
index 4e7209d..0df8957 100644
--- a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubExampleConstants.java
+++ b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubExampleConstants.java
@@ -17,8 +17,8 @@
 package org.apache.camel.component.pubnub.example;
 
 public interface PubNubExampleConstants {
-    // replace subscriber+publisher key with one obtained from PubNub.
+    // replace subscribe+publish key with one obtained from PubNub.
     // http://www.pubnub.com
-    String PUBNUB_SUBSCRIBER_KEY = "subkey";
-    String PUBNUB_PUBLISHER_KEY = "pubkey";
+    String PUBNUB_SUBSCRIBE_KEY = "mysubkey";
+    String PUBNUB_PUBLISH_KEY = "mypubkey";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubGeoLocationExample.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubGeoLocationExample.java b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubGeoLocationExample.java
new file mode 100644
index 0000000..1efae17
--- /dev/null
+++ b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubGeoLocationExample.java
@@ -0,0 +1,43 @@
+package org.apache.camel.component.pubnub.example;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.main.Main;
+
+import static org.apache.camel.component.pubnub.example.PubNubExampleConstants.PUBNUB_PUBLISH_KEY;
+import static org.apache.camel.component.pubnub.example.PubNubExampleConstants.PUBNUB_SUBSCRIBE_KEY;
+
+/**
+ * Example of the use of GeoLocation Blocks https://www.pubnub.com/blocks-catalog/geolocation/
+ */
+
+public class PubNubGeoLocationExample {
+
+    public static void main(String[] args) throws Exception {
+        Main main = new Main();
+        main.addRouteBuilder(new GeoLocationRoute());
+        main.run();
+    }
+
+    static class GeoLocationRoute extends RouteBuilder {
+        @Override
+        public void configure() throws Exception {
+            from("timer:geotimer")
+                .process(exchange -> exchange.getIn().setBody(new Foo("bar", "TEXT")))
+                .to("pubnub://eon-maps-geolocation-input?operation=fire&publishKey=" + PUBNUB_PUBLISH_KEY + "&subscribeKey=" + PUBNUB_SUBSCRIBE_KEY);
+
+            from("pubnub://eon-map-geolocation-output?subscribeKey=" + PUBNUB_SUBSCRIBE_KEY)
+                .log("${body}");
+        }
+    }
+
+    static class Foo {
+        String foo;
+        String text;
+
+        public Foo(String foo, String text) {
+            super();
+            this.foo = foo;
+            this.text = text;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubPresenseExample.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubPresenseExample.java b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubPresenseExample.java
index faac12c..bb24558 100644
--- a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubPresenseExample.java
+++ b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubPresenseExample.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.pubnub.example;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.main.Main;
 
-import static org.apache.camel.component.pubnub.example.PubNubExampleConstants.PUBNUB_SUBSCRIBER_KEY;
+import static org.apache.camel.component.pubnub.example.PubNubExampleConstants.PUBNUB_SUBSCRIBE_KEY;
 
 public final class PubNubPresenseExample {
 
@@ -35,7 +35,7 @@ public final class PubNubPresenseExample {
     static class PresensRoute extends RouteBuilder {
         @Override
         public void configure() throws Exception {
-            from("pubnub:iot?withPresence=true&subscriberKey=" + PUBNUB_SUBSCRIBER_KEY)
+            from("pubnub://iot?withPresence=true&subscribeKey=" + PUBNUB_SUBSCRIBE_KEY)
                 .log("${body}")
                 .to("mock:result");
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubSensor2Example.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubSensor2Example.java b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubSensor2Example.java
index 7389193..74c7d7f 100644
--- a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubSensor2Example.java
+++ b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubSensor2Example.java
@@ -31,8 +31,8 @@ import org.apache.camel.main.Main;
 
 import static org.apache.camel.component.pubnub.PubNubConstants.OPERATION;
 import static org.apache.camel.component.pubnub.PubNubConstants.UUID;
-import static org.apache.camel.component.pubnub.example.PubNubExampleConstants.PUBNUB_PUBLISHER_KEY;
-import static org.apache.camel.component.pubnub.example.PubNubExampleConstants.PUBNUB_SUBSCRIBER_KEY;
+import static org.apache.camel.component.pubnub.example.PubNubExampleConstants.PUBNUB_PUBLISH_KEY;
+import static org.apache.camel.component.pubnub.example.PubNubExampleConstants.PUBNUB_SUBSCRIBE_KEY;
 
 public final class PubNubSensor2Example {
 
@@ -47,8 +47,8 @@ public final class PubNubSensor2Example {
     }
 
     static class SimulatedDeviceEventGeneratorRoute extends RouteBuilder {
-        private final String deviceEP = "pubnub:iot?uuid=device2&publisherKey=" + PUBNUB_PUBLISHER_KEY + "&subscriberKey=" + PUBNUB_SUBSCRIBER_KEY;
-        private final String devicePrivateEP = "pubnub:device2private?uuid=device2&publisherKey=" + PUBNUB_PUBLISHER_KEY + "&subscriberKey=" + PUBNUB_SUBSCRIBER_KEY;
+        private final String deviceEP = "pubnub://iot?uuid=device2&publishKey=" + PUBNUB_PUBLISH_KEY + "&subscribeKey=" + PUBNUB_SUBSCRIBE_KEY;
+        private final String devicePrivateEP = "pubnub://device2private?uuid=device2&publishKey=" + PUBNUB_PUBLISH_KEY + "&subscribeKey=" + PUBNUB_SUBSCRIBE_KEY;
 
         @Override
         public void configure() throws Exception {
@@ -63,7 +63,7 @@ public final class PubNubSensor2Example {
     }
 
     static class PubsubRoute extends RouteBuilder {
-        private static String masterEP = "pubnub:iot?uuid=master&subscriberKey=" + PUBNUB_SUBSCRIBER_KEY + "&publisherKey=" + PUBNUB_PUBLISHER_KEY;
+        private static String masterEP = "pubnub://iot?uuid=master&subscribeKey=" + PUBNUB_SUBSCRIBE_KEY + "&publishKey=" + PUBNUB_PUBLISH_KEY;
         private static Map<String, String> devices = new ConcurrentHashMap<String, String>();
 
         @Override
@@ -81,7 +81,7 @@ public final class PubNubSensor2Example {
         }
 
         public static class DataProcessorBean {
-            @EndpointInject(uri = "pubnub:iot?uuid=master&subscriberKey=" + PUBNUB_SUBSCRIBER_KEY)
+            @EndpointInject(uri = "pubnub://iot?uuid=master&subscribeKey=" + PUBNUB_SUBSCRIBE_KEY)
             private static ProducerTemplate template;
 
             public static String getUnicastChannelOfDevice() {
@@ -94,7 +94,7 @@ public final class PubNubSensor2Example {
                 deviceUUID = message.getPublisher();
                 if (devices.get(deviceUUID) == null) {
                     Map<String, Object> headers = new HashMap<String, Object>();
-                    headers.put(OPERATION, "WHERE_NOW");
+                    headers.put(OPERATION, "WHERENOW");
                     headers.put(UUID, deviceUUID);
                     @SuppressWarnings("unchecked")
                     java.util.List<String> channels = (java.util.List<String>) template.requestBodyAndHeaders(null, headers);

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubSensorExample.java
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubSensorExample.java b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubSensorExample.java
index f5cff83..b56b31d 100644
--- a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubSensorExample.java
+++ b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/example/PubNubSensorExample.java
@@ -33,7 +33,7 @@ public final class PubNubSensorExample {
     static class SensorRoute extends RouteBuilder {
         @Override
         public void configure() throws Exception {
-            from("pubnub:pubnub-sensor-network?subscriberKey=sub-c-5f1b7c8e-fbee-11e3-aa40-02ee2ddab7fe").log("${body}").to("mock:result");
+            from("pubnub://pubnub-sensor-network?subscribeKey=sub-c-5f1b7c8e-fbee-11e3-aa40-02ee2ddab7fe").log("${body}").to("mock:result");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/components/camel-pubnub/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/components/camel-pubnub/src/test/resources/log4j2.properties b/components/camel-pubnub/src/test/resources/log4j2.properties
index fbb9b06..25b59c8 100644
--- a/components/camel-pubnub/src/test/resources/log4j2.properties
+++ b/components/camel-pubnub/src/test/resources/log4j2.properties
@@ -25,4 +25,4 @@ appender.out.name = out
 appender.out.layout.type = PatternLayout
 appender.out.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
 rootLogger.level = INFO
-rootLogger.appenderRef.file.ref = out
+rootLogger.appenderRef.file.ref = file

http://git-wip-us.apache.org/repos/asf/camel/blob/a070919d/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 0b46f85..b84caad 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -517,7 +517,7 @@
     <pgjdbc-ng-driver-version>0.7.1</pgjdbc-ng-driver-version>
     <powermock-version>1.6.6</powermock-version>
     <protobuf-version>3.1.0</protobuf-version>
-    <pubnub-version>4.6.0</pubnub-version>
+    <pubnub-version>4.6.1</pubnub-version>
     <qpid-bundle-version>0.28_1</qpid-bundle-version>
     <qpid-proton-j-version>0.16.0</qpid-proton-j-version>
     <qpid-proton-j-bundle-version>0.14.0</qpid-proton-j-bundle-version>