Reputation: 159
I am using a Nodejs Azure function to send messages to a service bus topic. I want to use a custom property on that message to filter which subscriptions are allowed to process the messages. This is what my Azure function code looks like.
Bindings
{
"bindings": [
{
"type": "serviceBus",
"direction": "out",
"connection": "ServiceBusConnectionString",
"name": "event",
"topicName": "mytopic"
}
]
}
index.js
const event = {
id: eventId,
dataVersion: version,
eventType: eventType,
data: data,
eventTime: eventTime,
customProperties: {
number: 5
}
}
context.bindings.event = JSON.stringify(event);
The event reaches the topic but is not filtered by my subscription because number does not appear as a custom property. I verified this by creating a test filter in Azure and then looked at the message using the service bus explorer.
Can someone help me with the correct way to pass custom properties. Any references to some examples will help because the official documentation does not explain how to do this. As a reference, this page has an example of how to achieve this without using Azure functions https://github.com/Huachao/azure-content/blob/master/articles/service-bus/service-bus-nodejs-how-to-use-topics-subscriptions.md
Upvotes: 0
Views: 769
Reputation: 8694
[
{ "topic": string,
"subject": string,
"id": string,
"eventType": string,
"eventTime": string,
"data":{
object-unique-to-each-publisher
},
"dataVersion": string,
"metadataVersion": string
}
]
applicationProperties?: [key: string]: function.
Example:
MessageId?: string|int|Buffer
Upvotes: 1