Official Content

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.

Connecting to Azure Service Bus Queue

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()

Connecting to Azure Service Bus Topic

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()

Variables defined in the samples

   
&receiverOptions BrokerReceiverOptions, AzureServiceBus
&MessageBroker MessageBroker, GeneXusMessagingMessageBroker
&errorMessages Messages

 

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