Official Content

With the Message Broker API, you can send messages to Azure Service Bus.

Message attributes are represented as a collection of a MessageProperty SDT that is a collection (property / value), as shown below.

image_2022916111427_1_png

To send a message, use the MessageBroker external object after having connected to Azure Service Bus with the AzureServiceBus.MessageBrokerProvider external object.
The message to send is set up using the Message SDT, where you can optionally specify custom and broker message attributes.

The same happens with the received messages, which arrive with a set of broker and custom properties that are loaded in the MessageAttributes item of the Message SDT.

The message properties supported by Azure Service Bus are listed here.

Sample

&Message = new() //Message, GeneXusMessagingMessageBroker
&Message.MessageId = !"123456"
&Message.MessageBody = !"test1 send one message"

//Custom Properties

&MessageProperty = new() //MessageProperty, GeneXusMessagingMessageBroker
&MessageProperty.PropertyKey = !"key1"
&MessageProperty.PropertyValue = !"Value1"
&Message.MessageAttributes.Add(&MessageProperty)

&MessageProperty = new() 
&MessageProperty.PropertyKey = !"key2"
&MessageProperty.PropertyValue = !"Value2"
&Message.MessageAttributes.Add(&MessageProperty)

//Broker Properties 

&MessageProperty = new()
&MessageProperty.PropertyKey = !"subject"
&MessageProperty.PropertyValue = !"TestSubject"
&Message.MessageAttributes.Add(&MessageProperty)

&MessageProperty = new()
&MessageProperty.PropertyKey = !"sessionid"
&MessageProperty.PropertyValue = !"sessionIdTest"
&Message.MessageAttributes.Add(&MessageProperty)

&success = &MessageBroker.SendMessage(&Message,&errorMessages) //MessageBroker, GeneXusMessagingMessageBroker


Checking the message sent using the Service Bus Explorer:

image_2022916112646_1_png

Availability

This feature is available since GeneXus 18 upgrade 1.

 

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant