You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: content/messages/index.textile
+53-2
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ redirect_from:
18
18
Messages contain the data that a client is communicating, such as the contents of a chat message. Clients publish messages on "channels":/channels, and these messages are received by clients that have "subscribed":/pub-sub#subscribe to them. This pattern is otherwise known as pub/sub, as publishers and subscribers are completely decoupled.
19
19
20
20
<aside data-type='note'>
21
-
<p>Messages are counted in 2KiB chunks. See "what counts as a message":https://faqs.ably.com/how-does-ably-count-messages. </p>
21
+
<p>Messages are counted in 5KiB chunks. See "what counts as a message":https://faqs.ably.com/how-does-ably-count-messages. </p>
22
22
</aside>
23
23
24
24
h2(#properties). Message properties
@@ -31,7 +31,7 @@ The following are the properties of a message:
31
31
- clientId := The "ID of the client":/auth/identified-clients that published the message.
32
32
- connectionId := The ID of the connection used to publish the message.
33
33
- timestamp := The timestamp of when the message was received by Ably, as milliseconds since the Unix epoch.
34
-
- extras := A JSON object of arbitrary key-value pairs that may contain metadata, and/or ancillary payloads. Valid payloads include those related to "Push Notifications":/push, "deltas":/channels/options/deltas and and headers.
34
+
- extras := A JSON object of arbitrary key-value pairs that may contain metadata, and/or ancillary payloads. Valid payloads include those related to "Push Notifications":/push, "deltas":/channels/options/deltas and headers.
35
35
- encoding := This is typically empty, as all messages received from Ably are automatically decoded client-side using this value. However, if the message encoding cannot be processed, this attribute contains the remaining transformations not applied to the data payload.
36
36
37
37
h2(#conflation). Message conflation
@@ -70,3 +70,54 @@ Use the following steps to configure message conflation for a channel, or channe
70
70
<aside data-type='note'>
71
71
<p>Message conflation is mutually exclusive with "server-side batching":/messages/batch#server-side on a channel, or channel namespace.</p>
72
72
</aside>
73
+
74
+
h2(#routing). Message routing and conflation syntax
75
+
76
+
Ably uses common syntax to select which messages are routed to integrations and for assessing which messages to apply conflation to. The following properties and features use this syntax:
77
+
78
+
* @routingKey@ for "AMQP":/general/firehose/amqp-rule and "Kafka":/general/firehose/kafka-rule integrations
79
+
* @partitionKey@ for "AWS Kinesis":/general/firehose/kinesis-rule integrations
80
+
* @conflationKey@ for "message conflation":#conflation
81
+
82
+
h3(#interpolation). Interpolation
83
+
84
+
As part of the syntax, interpolation is available to use the properties of a message to create the routing or conflation key.
85
+
86
+
The following properties can be used as variables:
87
+
88
+
- @channelName@ := The name of a channel.
89
+
- @message.name@ := The name of the message.
90
+
- @message.id@ := The unique ID of the message.
91
+
- @message.clientId@ := The ID of the client that published the message.
92
+
- @message.extras.headers['<header-name>']@ := The value of the specified header in the @message.extras@ field.
93
+
94
+
Interpolation uses the @#{...}@ syntax, for example @channel-name-identifier-#{channel-1}@.
95
+
96
+
<aside data-type='note'>
97
+
<p>For a Kafka rule, the @routingKey@ includes both the topic and message routing key joined by a colon, for example @topic:key@, or with interpolation @topic-#{channelName}:message-key-#{message.name}@. So either, or both, can be dynamic. This split is done after any interpolation, but since Kafka topics cannot contain a colon, this does not introduce any ambiguity.</p>
98
+
</aside>
99
+
100
+
h3(#filters). Filters
101
+
102
+
Interpolation can optionally be followed by a filter using pipe syntax.
103
+
104
+
The following filters are supported:
105
+
106
+
- hash := Transforms the variable into a stringified 32-bit fingerprint. It takes an optional numerical argument, the base to use when stringifying, which defaults to 16.
107
+
- moduloHash := Similar to hash, but runs the result through a modulo function before stringifying. This is useful for bucketing. It takes one mandatory argument; the number of buckets, and one optional argument; the base to use when stringifying, which defaults to 16.
108
+
109
+
If using a filter, you can specify a tuple of two or more variables as the input to the filter. It should be comma-separated and delimited with parentheses.
110
+
111
+
h3(#examples). Routing and conflation syntax examples
112
+
113
+
The following are examples of using interpolation and filters to create a routing or conflation key:
114
+
115
+
* Hashed channel name as hex: @#{channelName | hash}@
116
+
* Hashed channel name as decimal: @#{channelName | hash(10)}@
0 commit comments