Gaston G
Gaston G

Reputation: 396

How to set application properties in a ServiceBusMessage?

How can we add custom properties or application properties with the latest SDK azure-messaging-servicebus?

It seems something doable in the previous package com.microsoft.azure:azure-servicebu like the method setProperties(Map<String,Object> properties) but I cannot find anything with the new SDK...

It is also something doable with the .Net or Javascript SDK .

Upvotes: 1

Views: 3297

Answers (1)

Jesse Squire
Jesse Squire

Reputation: 7790

Setting application properties can be accomplished by using the ApplicationProperties map on ServiceBusMessage. For example:

ServiceBusMessage message = new ServiceBusMessage(ServiceBusMessage(BinaryData.fromString("Hello"));
        message.getApplicationProperties().put("EventType", "com.microsoft.samples.hello-event");
        message.getApplicationProperties().put("priority", 1);
        message.getApplicationProperties().put("score", 9.0);

More context can be found in the ServiceBusMessage docs.

Upvotes: 4

Related Questions