Hi,
apologize if this is in the wrong category. We are using the connector to stream json events into a Kinesis Data Stream. Until now we have subscribed only to one single topic in the queue connected to Kinesis, and it has been working fine.
Now we need to subscribe to more than one topics in one queue.
Question is how the Kinesis receiver side can tell which topic each event belongs to?
The destination in the binding names only the queue, like this:
There are some header options in the user guide but the documentation could be improved.
Anyone knows if there is any header, or other option, making it possible to include the topic (service/ledger/something/casino/) in the payload or as a partition key for the receiving Data Stream dp-kinesis-casino
Maybe it is included already but we are not finding it?
Unfortunately, the connector removes the topic header (solace_destination) before any transform runs, which is why we only got null values when trying.
We raised a support issue and now got a complete working solution from Solace
If anyone else using the solace-pubsub-connector-aws-kinesis:1.0.1 is having the same problem, here is the answer we got:
Kinesis Data Streams records don’t support headers. Each record has only the message data and a partition key, so the topic name has to go into one of those two places.
The connector removes the topic header (solace_destination) before your transforms run, which is why you couldn’t use it. It can still be read from the original Solace message, which the connector keeps internally. The expression below reads the topic from there and puts it in a header called aws_partitionKey, which Kinesis uses as the partition key. Header transforms run before payload transforms, so you can also add the topic to the JSON body.
Example configuration:
Add the transform-headers and transform-payloads sections below to each workflow in your application.yml. Your existing settings can stay as they are.
solace:
connector:
workflows:
0:
enabled: true
acknowledgment:
publish-async: true
transform-headers:
expressions:
# Use the Solace topic as the Kinesis partition key
aws_partitionKey: "T(org.apache.commons.lang3.reflect.FieldUtils).readField(headers['acknowledgmentCallback'], 'messageContainer', true).message.destination.name"
transform-payloads:
expressions:
# Send the message as clean JSON (no prefix)
- transform: "#isPayloadBytes(payload) ? payload : payload.toString().getBytes(T(java.nio.charset.StandardCharsets).UTF_8)"
expressions:
- transform: "#isPayloadBytes(payload) ? payload : payload.toString().getBytes(T(java.nio.charset.StandardCharsets).UTF_8)"