SendToAzureServiceBus

The SendToAzureServiceBus activity sends messages to the Azure Service Bus. Service bus messages are sent asynchronously, i.e., you place a message on the queue, and at some point a subscriber/listener of that queue will handle the message.

For the SendToAzureServiceBus activity, the workflow logic cannot depend on getting an immediate result from the process –- all you will know is that the message was successfully queued. If you want to get or post data and want to know the result immediately (synchronously), use the Http activity. The Http activity will execute (send) a request and you will get a response from the Url end-point that is being posted to. For more information, see example Http vs. SendToAzureServiceBus.

SendToAzureServiceBus properties

Properties

SendToAzureServiceBus Properties
Property Value Required Notes
DisplayName String No Specify a name for the activity or accept the default.
Message InArgument<String> Yes The message sent to the Azure Service Bus.
QueueOrTopicPath InArgument<String> Yes The queue or topic path for the Azure Service Bus.
ResponseBody OutArgument<String> No The response body returned from the server.
ResponseStatusCode OutArgument<HttpStatusCode> No The response status code. Represents the HTTP response status code issued by the server in response to the request (e.g., 200, 401, 500, etc.). Initializes a new instance of the Http class.
ServiceNamespace InArgument<String> No The service namespace. See Note.
SharedAccessKey InArgument<String> No The shared access key. See Note.
SharedAccessKeyName InArgument<String> No The name of the shared access key. See Note.

The properties ServiceBusNamespace, SharedAccessKey, and SharedAccessKeyName are not required; however, if they are not provided, the activity will pull these settings from the web.config appSettings section. This is to allow workflows to be reused from environment to environment without modification.

Below is an example of the web.config app settings:

<add key="azureServiceBus:serviceNamespace" value="nexus-student-integration-bus" />

<add key="azureServiceBus:sharedAccessKeyName" value="SendSharedAccessKey" />

<add key="azureServiceBus:sharedAccessKey" value="ZRXqcCfXQaGMi0FXTp6iNtFjMXKG+adnZTO3CcNAqDA=" />

alert  Clients using their own Azure Subscription (customer side) need to specify the Service Bus settings applicable to their environment.

Examples

Send Message

The following workflow example shows how the activity can be used to send messages to the Azure Service Bus.

The workflow Cmc.Nexus.Crm.Entities.TaskEntity_SavedEvent_Sample%20-%20Azure%20Service%20Bus.xaml is available on GitHub.

Example Send to Azure Service Bus

  1. The SerializeToJson activity serializes an input argument object named "entity" and produces the output string named "message".

    SerializeToJson properties

  2. The SendToAzureServiceBus activity uses the serialized "message" string as input argument and creates the output argument named "tasks".

    Example Send to Azure Service Bus

Http vs. SendToAzureServiceBus

To demonstrate the difference between the Http and SendToAzureServiceBus activities, we created a workflow that multiplies two numbers (24 x 365) and returns the result (8,760).

  • The Http activity returns the result immediately to a workflow variable.

  • The SendToAzureServiceBus activity sends the result to the service bus where it is processed by an application that is listening for messages. Then response is sent to the email address specified in the request.

    In more complex scenarios, the response from the service bus listener process could be a call back into another system –- or the service bus listener would forward the message to a 3rd party application to be posted to that system.

The workflow uses the following variables:

Http Activity

Http Example

The Http activity:

  • Uses the string assignments (nbr1 and nbr2) as input arguments in the Body property.
  • Defines the input as MediaType = "application/json".
  • Invokes the "POST" method.
  • Creates the output argument named "httpResponseBody".
  • Creates the output argument named "httpResponseStatus" whose value is checked in the If Condition.
  • Sends the output to a Uri on an Azure web site that hosts an API.

The API multiplies the numbers 2 numbers in the request Body (nbr1 and nbr2) and returns the result.

Http Properties

 

SendToAzureServiceBus Activity

SendToAzureServiceBus Properties

The SendToAzureServiceBus activity:

  • Sends the string assignments (nbr1 and nbr2) and "emailTo" variable to the Azure Service Bus.
  • Specifies the path for the Azure Service Bus as "mathqueue".
  • Specifies the user's service name space and access key in Azure.

In Azure, the message is placed in the "mathqueue" and processed.

SendToAzureServiceBus Properties

When the service bus request is processed, an email is sent to the user.

SendToAzureServiceBus Properties