Skip to main content

Message Publishers with Azure

Axinom Encoding Service sends events to defined endpoints when a job’s state changes. Each such event contains useful information. It is up to your application to listen for these events and to define the handling behavior.

To start receiving events during job processing, you should specify target endpoints in the API request’s MessagePublishers section. Azure Service Bus is one option that you could use. Messages are published to Azure Service Bus Queues. You need to create a Azure Service Bus with a preferred name.

Creating a Service Bus

To create a service bus and get the connection string:

  1. On the Azure website, click the three bars in the top left corner to open the menu. From the menu, click Create a resource.

    Start creating a resource

    azure_create_resource

  2. On the next page, click Integration. Type Service Bus in the search bar and click Enter.

    Click Create

    azure_integration_sb

    From the list appears, find Service Bus and click Create. Next click Service Bus.

    azure_integration_sb

  3. In the Create namespace page, provide your project and instance details. Note that you can name your queue whatever you like in the Namespace name field. However, it should be unique. Please also note that Azure will automatically change it to lowercase.

    1. If you wish, you can also apply tags in the next window.
    2. When ready updating the details, click the Review/create button. The details of your queue shall be displayed after validation.
    3. Click Create to complete the process.
  4. You are taken to the Overview page of your queue. Your queue shall be deployed.

  5. Once the deployment is done, click Go to Resource.

  6. Next, find the correct connection string for the Azure service bus queue you created. In the left-hand menu, under Settings, click Shared access policies. In the example below, it is called RootManageSharedAccessKey.

    Find the policy from the list

    azure_shared_access_policies

  7. According to the policy you select, you can select the connection string. The keys and connection strings are displayed on the right. Copy the value by clicking the relevant icon on the row.

    The primary and secondary key have been excluded from this example but you should see your values

    azure_connection_string

  8. Use the key and endpoint to fill in the MessagePublishers section of the econding job. The snippet below is an example. Replace the service bus name and secret key with actual values.

    {
    "Type": "AzureServiceBusQueue",
    "Connection": "Endpoint=sb://<azure_service_bus_name>.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=<your_secret_key>"
    }
note

We recommend you to use credentials protection with the CredentialsProtection property. For instance, in the connection string above, you need to use credentials protection for the Shared Access key.

Creating an Azure Service Bus Queue

For each message type, you need to create a new queue with the "queue" postfix in its name. There are 14 events related to encoding and you have to create queues for each event. For instance, for the message of the type "jobcreated", there will be a queue called the "jobcreated***queue***". In addition, a message has a custom property "OriginalMessageType", which reflects the message type, for example, "JobCreated".

To create a queue:

  1. On your service bus namespace Overview page, click Queue.

    Create an Azure Service Bus Queue

    azure_create_queue

  2. In the pop-up that appears on the right, name your queue and specify its properties. Click Create.

  3. You can find your queue from the list under Entities that you can access via the left-hand menu.

    Queue list

    azure_queue_list

  4. When you run your encoding job with the correct connection string is correct and you have queues with correct names, messages will appear inside the queues. To see the messages inside a queue, you need to select a queue.

    Messages inside a queue.

    messages-inside-the-queue-azure

  5. You can see the details of the message queue if you click the queue, then click Service Bus Explorer, click Peek from start under Peek Mode.

    Message details.

    message-details-azure

  6. When you click the message, you can get the message body.

    Message body.

    message-details-json-view-azure

Further, you can copy the message and check message body using a Json formatter (e.g. https://jsonformatter.org/).

tip

Alternatively, you can use Service Bus Explorer to manage your queues and see the details inside the queues.