0

I have following setup:

  1. Event hub
  2. Service bus topic with a single subscription that accepts all messages from the topic (for my POC)
  3. Above service bus subscription is setup with sessions enabled
  4. Stream analytics (SA) job that moves the events from event hub (the input) into service bus topic (the output). Here is my SA query:
    SELECT *, LOWER(source) as Partner
    INTO [sb-output]
    FROM [test-input]
  1. The above job also sets the partition key for service bus. Used following json in the System Properties of [sb-output] based on the documentation at https://learn.microsoft.com/en-us/azure/stream-analytics/service-bus-topics-output#custom-metadata-properties-for-output:
    { "PartitionKey" : "Partner" }

What I did:

  1. Sent an event to event hub without partition key. This was successful.
{
    "specversion": "1.0",
    "id": "c8c4faad-9f53-4e43-95ca-c318d673660a",
    "type": "CustomerChanged",
    "time": "2020-09-09T22:25:40.0148301Z",
    "source": "ABCD",
    "subject": "system-1",
    "datacontenttype": "application/json",
    "dataschema": "1.0",
    "data": {
        "customerNumber": "7879875212123",
        "firstName": "John",
        "lastName" : "Kennedy"
    }
}
  1. The SA successfully moved the event from event hub to service bus.
  2. The service bus subscription succcessfully received the message as shown below:
    {
        "specversion": "1.0",
        "id": "c8c4faad-9f53-4e43-95ca-c318d673660a",
        "type": "CustomerChanged",
        "time": "2020-09-09T23:22:13.3647825Z",
        "source": "ABCD",
        "subject": "system-1",
        "datacontenttype": "application/json",
        "dataschema": "1.0",
        "data": {
            "customerNumber": "7879875212123",
            "firstName": "John",
            "lastName": "Kennedy"
        },
        "EventProcessedUtcTime": "2020-09-09T23:22:14.3776603Z",
        "PartitionId": 0,
        "EventEnqueuedUtcTime": "2020-09-09T23:22:14.3080000Z",
        "Partner": "abcd"
    }
  1. As can be seen, the property Partner is at the end of the message.
  2. However the Service Bus Explorer tool shows me that the PartitionKey property has not been set to "abcd" but to some other random string.

Troubleshooting:

  1. To make sure that I can send a message to service bus topic with a specific PartitionKey key, I wrote a sample code that submits the message to service bus topic by explicitly setting the session id property on the message. The service bus explorer showed me that both SessionId as well as PartitionKey properties are set to the correct value.

  2. In ASA output configuration, tried to set following system properties json. Neither worked.

{ "SessionId" : "Partner" }

{ "PartitionKey" : "Partner", "SessionId" : "Partner" }

  1. In ASA output configuration, tried setting both Property Columns (to Partner) as well as System Property Columns (to { "PartitionKey" : "Partner" }). That did not work.

Question:

  1. What am I doing wrong with ASA output configuration that is circumventing the propagation of PartitionKey value from my custom field to service bus message?
  2. Also is there a reason why the System Property Columns does not show the json text that I entered after saving?
Raghu
  • 2,859
  • 4
  • 33
  • 65
  • MS is working on a fix. Until then, they suggested following work around: { "PartitionKey" : "Partner", "SessionId" : "Partner", "Label": "Partner" } in system properties. I tested this and it works. – Raghu Oct 02 '20 at 22:20
  • Would you like to post that as an answer so you can mark this question as answered? – CHEEKATLAPRADEEP Oct 06 '20 at 10:15

1 Answers1

0

Sharing the answer as per the comment by the original poster:

Currently, Microsoft is working on a fix.

Until then, you can use the suggested work around: { "PartitionKey" : "Partner", "SessionId" : "Partner", "Label": "Partner" } in system properties.

CHEEKATLAPRADEEP
  • 12,191
  • 1
  • 19
  • 42
MayankBargali
  • 712
  • 5
  • 8