This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 90dc53067fd2 CAMEL-28016: camel-pubnub - CamelMessageTimestamp holds 
milliseconds, not the timetoken (#31256)
90dc53067fd2 is described below

commit 90dc53067fd2b18b4b86a259af1186c8292b62e0
Author: Guillaume Nodet <[email protected]>
AuthorDate: Wed Dec 2 21:37:52 2026 +0100

    CAMEL-28016: camel-pubnub - CamelMessageTimestamp holds milliseconds, not 
the timetoken (#31256)
    
    PubNub timetokens are counts of 100-nanosecond intervals since the epoch,
    not milliseconds. PubNubConsumer was setting Exchange.MESSAGE_TIMESTAMP
    directly to message.getTimetoken() / presence.getTimetoken(), producing
    a value 10,000x too large.
    
    Fix: divide the timetoken by 10_000L before setting MESSAGE_TIMESTAMP.
    CamelPubNubTimeToken continues to carry the raw timetoken unchanged.
    The @Metadata description on PubNubConstants.MESSAGE_TIMESTAMP is updated
    to document the millisecond contract.
    
    Two regression tests added to PubNubConsumerListenerTest:
    - testMessageTimestampIsMilliseconds (message path)
    - testPresenceTimestampIsMilliseconds (presence path)
    
    Follow-up commits:
    - CAMEL-28016: regenerate catalog JSON and endpoint DSL with updated 
CamelMessageTimestamp description
    - CAMEL-28016: null guard on timetoken, test visibility, upgrade guide
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
---
 .../apache/camel/catalog/components/pubnub.json    |  2 +-
 .../org/apache/camel/component/pubnub/pubnub.json  |  2 +-
 .../camel/component/pubnub/PubNubConstants.java    |  5 ++--
 .../camel/component/pubnub/PubNubConsumer.java     | 10 +++++--
 .../pubnub/PubNubConsumerListenerTest.java         | 32 ++++++++++++++++++++++
 .../ROOT/pages/camel-4x-upgrade-guide-4_25.adoc    | 12 ++++++++
 .../endpoint/dsl/PubNubEndpointBuilderFactory.java |  7 +++--
 7 files changed, 61 insertions(+), 9 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/pubnub.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/pubnub.json
index 4c27e49598cb..ee44f97264e7 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/pubnub.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/pubnub.json
@@ -43,7 +43,7 @@
     "CamelPubNubChannel": { "index": 2, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The channel the message belongs to.", "constantName": 
"org.apache.camel.component.pubnub.PubNubConstants#CHANNEL" },
     "CamelPubNubOverrideChannel": { "index": 3, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The channel to use instead of the channel configured on the 
endpoint.", "constantName": 
"org.apache.camel.component.pubnub.PubNubConstants#OVERRIDE_CHANNEL" },
     "CamelPubNubUUID": { "index": 4, "kind": "header", "displayName": "", 
"group": "producer", "label": "producer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The user ID (UUID) whose presence state GETSTATE and SETSTATE 
get or set, instead of the uuid option.", "constantName": 
"org.apache.camel.component.pubnub.PubNubConstants#UUID" },
-    "CamelMessageTimestamp": { "index": 5, "kind": "header", "displayName": 
"", "group": "consumer", "label": "consumer", "required": false, "javaType": 
"Long", "deprecated": false, "autowired": false, "secret": false, 
"description": "The PubNub timetoken of the received message or presence event, 
the same value as CamelPubNubTimeToken: a count of 100-nanosecond units since 
the epoch (not milliseconds).", "constantName": 
"org.apache.camel.component.pubnub.PubNubConstants#MESSAGE_TIMESTAMP" }
+    "CamelMessageTimestamp": { "index": 5, "kind": "header", "displayName": 
"", "group": "consumer", "label": "consumer", "required": false, "javaType": 
"Long", "deprecated": false, "autowired": false, "secret": false, 
"description": "The timestamp of the received message or presence event in 
milliseconds since the epoch, derived from the PubNub timetoken 
(CamelPubNubTimeToken) by dividing by 10,000 (timetokens count 100-nanosecond 
units).", "constantName": "org.apache.camel.component.pu [...]
   },
   "bodyTypes": {
     "consumerOut": { "carriers": [ "pojo" ], "javaType": 
"com.pubnub.api.models.consumer.pubsub.PNMessageResult", "byOption": [ { 
"option": "withPresence", "value": "true", "carriers": [ "pojo" ] } ], 
"description": "The PubNub PNMessageResult; its getMessage() is the payload as 
a Gson JsonElement. It converts to a String: a string message as its text, any 
other message as JSON. With withPresence, a presence event comes as a 
PNPresenceEventResult. The channel and timetoken are in the Cam [...]
diff --git 
a/components/camel-pubnub/src/generated/resources/META-INF/org/apache/camel/component/pubnub/pubnub.json
 
b/components/camel-pubnub/src/generated/resources/META-INF/org/apache/camel/component/pubnub/pubnub.json
index 4c27e49598cb..ee44f97264e7 100644
--- 
a/components/camel-pubnub/src/generated/resources/META-INF/org/apache/camel/component/pubnub/pubnub.json
+++ 
b/components/camel-pubnub/src/generated/resources/META-INF/org/apache/camel/component/pubnub/pubnub.json
@@ -43,7 +43,7 @@
     "CamelPubNubChannel": { "index": 2, "kind": "header", "displayName": "", 
"group": "consumer", "label": "consumer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The channel the message belongs to.", "constantName": 
"org.apache.camel.component.pubnub.PubNubConstants#CHANNEL" },
     "CamelPubNubOverrideChannel": { "index": 3, "kind": "header", 
"displayName": "", "group": "producer", "label": "producer", "required": false, 
"javaType": "String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The channel to use instead of the channel configured on the 
endpoint.", "constantName": 
"org.apache.camel.component.pubnub.PubNubConstants#OVERRIDE_CHANNEL" },
     "CamelPubNubUUID": { "index": 4, "kind": "header", "displayName": "", 
"group": "producer", "label": "producer", "required": false, "javaType": 
"String", "deprecated": false, "autowired": false, "secret": false, 
"description": "The user ID (UUID) whose presence state GETSTATE and SETSTATE 
get or set, instead of the uuid option.", "constantName": 
"org.apache.camel.component.pubnub.PubNubConstants#UUID" },
-    "CamelMessageTimestamp": { "index": 5, "kind": "header", "displayName": 
"", "group": "consumer", "label": "consumer", "required": false, "javaType": 
"Long", "deprecated": false, "autowired": false, "secret": false, 
"description": "The PubNub timetoken of the received message or presence event, 
the same value as CamelPubNubTimeToken: a count of 100-nanosecond units since 
the epoch (not milliseconds).", "constantName": 
"org.apache.camel.component.pubnub.PubNubConstants#MESSAGE_TIMESTAMP" }
+    "CamelMessageTimestamp": { "index": 5, "kind": "header", "displayName": 
"", "group": "consumer", "label": "consumer", "required": false, "javaType": 
"Long", "deprecated": false, "autowired": false, "secret": false, 
"description": "The timestamp of the received message or presence event in 
milliseconds since the epoch, derived from the PubNub timetoken 
(CamelPubNubTimeToken) by dividing by 10,000 (timetokens count 100-nanosecond 
units).", "constantName": "org.apache.camel.component.pu [...]
   },
   "bodyTypes": {
     "consumerOut": { "carriers": [ "pojo" ], "javaType": 
"com.pubnub.api.models.consumer.pubsub.PNMessageResult", "byOption": [ { 
"option": "withPresence", "value": "true", "carriers": [ "pojo" ] } ], 
"description": "The PubNub PNMessageResult; its getMessage() is the payload as 
a Gson JsonElement. It converts to a String: a string message as its text, any 
other message as JSON. With withPresence, a presence event comes as a 
PNPresenceEventResult. The channel and timetoken are in the Cam [...]
diff --git 
a/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConstants.java
 
b/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConstants.java
index d0b12b8f1e7a..bf7850bdda19 100644
--- 
a/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConstants.java
+++ 
b/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConstants.java
@@ -35,8 +35,9 @@ public final class PubNubConstants {
               javaType = "String")
     public static final String UUID = "CamelPubNubUUID";
     @Metadata(label = "consumer",
-              description = "The PubNub timetoken of the received message or 
presence event, the same value as"
-                            + " CamelPubNubTimeToken: a count of 
100-nanosecond units since the epoch (not milliseconds).",
+              description = "The timestamp of the received message or presence 
event in milliseconds since the epoch,"
+                            + " derived from the PubNub timetoken 
(CamelPubNubTimeToken) by dividing by 10,000"
+                            + " (timetokens count 100-nanosecond units).",
               javaType = "Long")
     public static final String MESSAGE_TIMESTAMP = Exchange.MESSAGE_TIMESTAMP;
 
diff --git 
a/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConsumer.java
 
b/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConsumer.java
index c9d0fcc9a6b1..e8470274f2e8 100644
--- 
a/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConsumer.java
+++ 
b/components/camel-pubnub/src/main/java/org/apache/camel/component/pubnub/PubNubConsumer.java
@@ -141,7 +141,10 @@ public class PubNubConsumer extends DefaultConsumer {
             inmessage.setBody(message);
             inmessage.setHeader(TIMETOKEN, message.getTimetoken());
             inmessage.setHeader(CHANNEL, message.getChannel());
-            inmessage.setHeader(PubNubConstants.MESSAGE_TIMESTAMP, 
message.getTimetoken());
+            // PubNub timetokens are counts of 100-nanosecond units; divide by 
10_000 to get milliseconds
+            Long messageTimetoken = message.getTimetoken();
+            inmessage.setHeader(PubNubConstants.MESSAGE_TIMESTAMP,
+                    messageTimetoken != null ? messageTimetoken / 10_000L : 
null);
 
             try {
                 getProcessor().process(exchange);
@@ -163,7 +166,10 @@ public class PubNubConsumer extends DefaultConsumer {
             inmessage.setBody(presence);
             inmessage.setHeader(TIMETOKEN, presence.getTimetoken());
             inmessage.setHeader(CHANNEL, presence.getChannel());
-            inmessage.setHeader(PubNubConstants.MESSAGE_TIMESTAMP, 
presence.getTimetoken());
+            // PubNub timetokens are counts of 100-nanosecond units; divide by 
10_000 to get milliseconds
+            Long presenceTimetoken = presence.getTimetoken();
+            inmessage.setHeader(PubNubConstants.MESSAGE_TIMESTAMP,
+                    presenceTimetoken != null ? presenceTimetoken / 10_000L : 
null);
             try {
                 getProcessor().process(exchange);
             } catch (Exception e) {
diff --git 
a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubConsumerListenerTest.java
 
b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubConsumerListenerTest.java
index 14a81b529b6f..7b0fcf547eeb 100644
--- 
a/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubConsumerListenerTest.java
+++ 
b/components/camel-pubnub/src/test/java/org/apache/camel/component/pubnub/PubNubConsumerListenerTest.java
@@ -69,6 +69,38 @@ public class PubNubConsumerListenerTest extends 
PubNubTestBase {
         sharedPubnub.destroy();
     }
 
+    @Test
+    public void testMessageTimestampIsMilliseconds() throws Exception {
+        context.getRouteController().startRoute("alpha");
+
+        MockEndpoint alpha = getMockEndpoint("mock:alpha");
+        alpha.expectedMessageCount(1);
+        // 14607577960932488 is the timetoken injected by announce(); dividing 
by 10_000 gives milliseconds
+        
alpha.message(0).header(PubNubConstants.MESSAGE_TIMESTAMP).isEqualTo(14607577960932488L
 / 10_000L);
+        // CamelPubNubTimeToken must still carry the raw 100-ns value
+        
alpha.message(0).header(PubNubConstants.TIMETOKEN).isEqualTo(14607577960932488L);
+
+        sharedPubnub.announce("alpha");
+
+        MockEndpoint.assertIsSatisfied(context);
+    }
+
+    @Test
+    public void testPresenceTimestampIsMilliseconds() throws Exception {
+        context.getRouteController().startRoute("alpha");
+
+        MockEndpoint alpha = getMockEndpoint("mock:alpha");
+        alpha.expectedMessageCount(1);
+        alpha.message(0).body().isInstanceOf(PNPresenceEventResult.class);
+        // 14607577960932488 is the timetoken injected by announcePresence(); 
dividing by 10_000 gives milliseconds
+        
alpha.message(0).header(PubNubConstants.MESSAGE_TIMESTAMP).isEqualTo(14607577960932488L
 / 10_000L);
+        
alpha.message(0).header(PubNubConstants.TIMETOKEN).isEqualTo(14607577960932488L);
+
+        sharedPubnub.announcePresence("alpha");
+
+        MockEndpoint.assertIsSatisfied(context);
+    }
+
     @Test
     public void testConsumerOnlyReceivesItsOwnChannel() throws Exception {
         context.getRouteController().startRoute("alpha");
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
index 403decfa0163..3a0694b8ba06 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_25.adoc
@@ -333,6 +333,18 @@ As a result, applications that use `camel-infinispan` no 
longer get `infinispan-
 Hibernate Search or Lucene on their classpath through it. If your application 
also starts an embedded cache manager or
 uses the embedded query engine, use `camel-infinispan-embedded`, or add these 
dependencies yourself.
 
+=== camel-pubnub - CamelMessageTimestamp now holds milliseconds
+
+The `CamelMessageTimestamp` header on PubNub message and presence events now 
holds the
+event time in **milliseconds since the Unix epoch**, matching the convention 
of other
+Camel components (JMS, Kafka, file, ...).
+
+In every earlier release the raw PubNub timetoken (a count of 100-nanosecond 
intervals
+since the epoch, a 17-digit number) was placed directly into 
`CamelMessageTimestamp`.
+The header value has changed: it is now `timetoken / 10_000`.
+
+The raw timetoken is still available on the `CamelPubNubTimeToken` header.
+
 === camel-salesforce - REST and raw request URLs must stay on the configured 
instance
 
 The REST client `queryMore` operation and the raw client `makeRequest` 
operation now validate the request URL they
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PubNubEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PubNubEndpointBuilderFactory.java
index 3a03a7ddf60d..5502088a0c86 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PubNubEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/PubNubEndpointBuilderFactory.java
@@ -895,9 +895,10 @@ public interface PubNubEndpointBuilderFactory {
             return "CamelPubNubUUID";
         }
         /**
-         * The PubNub timetoken of the received message or presence event, the
-         * same value as CamelPubNubTimeToken: a count of 100-nanosecond units
-         * since the epoch (not milliseconds).
+         * The timestamp of the received message or presence event in
+         * milliseconds since the epoch, derived from the PubNub timetoken
+         * (CamelPubNubTimeToken) by dividing by 10,000 (timetokens count
+         * 100-nanosecond units).
          * 
          * The option is a: {@code Long} type.
          * 

Reply via email to