The purpose of this article is to explain the necessary steps to connect to a Message Broker (for sending and receiving messages) with the Message Broker API. For this, you have to use the Connect methods of MessageBrokerProvider External Object.
The provider supported for now is Azure Service Bus.
The following code is the one used to connect to a Service Bus queue:
&receiverOptions = new() // BrokerReceiverOptions, AzureServiceBus
&receiverOptions.Identifier = "ReceiverId"
&senderIdentifier = "SenderId"
&isSessionEnabled = false
&receiverOptions.PrefetchCount = 10
&MessageBroker = AzureServiceBus.MessageBrokerProvider.Connect(&queueName,&queueConnection,&isSessionEnabled,&receiverOptions,&senderIdentifier,&errorMessages,&isOK) //MessageBroker, GeneXusMessagingMessageBroker
//Then process errorMessages
&MessageBroker.Dispose()
The following code is the one used to connect to a Service Bus Topic:
&receiverOptions = new() // BrokerReceiverOptions, AzureServiceBus
&receiverOptions.Identifier = "ReceiverId"
&senderIdentifier = "SenderId"
&isSessionEnabled = false
&receiverOptions.PrefetchCount = 10
&MessageBroker = AzureServiceBus.MessageBrokerProvider.Connect(&topicName,&SubscriptionName,&connectionString,&IsSessionEnabled,&receiverOptions,&senderIdentifier,&errorMessages,&isOK)
//MessageBroker, GeneXusMessagingMessageBroker
//Then process errorMessages
&MessageBroker.Dispose()