Skip to content

Commit

Permalink
[WebSocket] Add redeliveryCount property to messages delivered throug…
Browse files Browse the repository at this point in the history
…h the WebSocket service (apache#8074)

### Motivation

Currently, the redeliveryCount is not passed to consumer subscribed through the WebSocket service. Redelivery count is a useful feature which should be available.

### Modifications

A property is added to `org.apache.pulsar.websocket.data.ConsumerMessage` which is populated with the value coming from the original message coming from the Java pulsar client.

### Verifying this change

This change is a trivial rework / code cleanup without any test coverage.

### Documentation

The corresponding documentation was updated.
  • Loading branch information
IvanStoilov authored Nov 5, 2020
1 parent e0e0f14 commit 3ff3b31
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ private void receiveMessage() {
dm.payload = Base64.getEncoder().encodeToString(msg.getData());
dm.properties = msg.getProperties();
dm.publishTime = DateFormatter.format(msg.getPublishTime());
dm.redeliveryCount = msg.getRedeliveryCount();
if (msg.getEventTime() != 0) {
dm.eventTime = DateFormatter.format(msg.getEventTime());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ private void receiveMessage() {
dm.payload = Base64.getEncoder().encodeToString(msg.getData());
dm.properties = msg.getProperties();
dm.publishTime = DateFormatter.format(msg.getPublishTime());
dm.redeliveryCount = msg.getRedeliveryCount();
if (msg.getEventTime() != 0) {
dm.eventTime = DateFormatter.format(msg.getEventTime());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class ConsumerMessage {
public String payload;
public Map<String, String> properties;
public String publishTime;
public int redeliveryCount;
public String eventTime;

public String key;
Expand Down
8 changes: 6 additions & 2 deletions site2/docs/client-libraries-websocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ Server will push messages on the WebSocket session:
"messageId": "CAAQAw==",
"payload": "SGVsbG8gV29ybGQ=",
"properties": {"key1": "value1", "key2": "value2"},
"publishTime": "2016-08-30 16:45:57.785"
"publishTime": "2016-08-30 16:45:57.785",
"redeliveryCount": 4
}
```

Expand All @@ -168,6 +169,7 @@ Key | Type | Required? | Explanation
`messageId` | string | yes | Message ID
`payload` | string | yes | Base-64 encoded payload
`publishTime` | string | yes | Publish timestamp
`redeliveryCount` | number | yes | Number of times this message was already delivered
`properties` | key-value pairs | no | Application-defined properties
`key` | string | no | Original routing key set by producer

Expand Down Expand Up @@ -239,7 +241,8 @@ Server will push messages on the WebSocket session:
"messageId": "CAAQAw==",
"payload": "SGVsbG8gV29ybGQ=",
"properties": {"key1": "value1", "key2": "value2"},
"publishTime": "2016-08-30 16:45:57.785"
"publishTime": "2016-08-30 16:45:57.785",
"redeliveryCount": 4
}
```

Expand All @@ -248,6 +251,7 @@ Key | Type | Required? | Explanation
`messageId` | string | yes | Message ID
`payload` | string | yes | Base-64 encoded payload
`publishTime` | string | yes | Publish timestamp
`redeliveryCount` | number | yes | Number of times this message was already delivered
`properties` | key-value pairs | no | Application-defined properties
`key` | string | no | Original routing key set by producer

Expand Down

0 comments on commit 3ff3b31

Please sign in to comment.