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:
-
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
-
On the next page, click Integration. Type Service Bus in the search bar and click Enter.
Click Create
From the list appears, find Service Bus and click Create. Next click Service Bus.
-
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.
- If you wish, you can also apply tags in the next window.
- When ready updating the details, click the Review/create button. The details of your queue shall be displayed after validation.
- Click Create to complete the process.
-
You are taken to the Overview page of your queue. Your queue shall be deployed.
-
Once the deployment is done, click Go to Resource.
-
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
-
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
-
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>"
}
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:
-
On your service bus namespace Overview page, click Queue.
Create an Azure Service Bus Queue
-
In the pop-up that appears on the right, name your queue and specify its properties. Click Create.
-
You can find your queue from the list under Entities that you can access via the left-hand menu.
Queue list
-
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.
-
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.
-
When you click the message, you can get the message body.
Message body.
Further, you can copy the message and check message body using a Json formatter (e.g. https://jsonformatter.org/).
Alternatively, you can use Service Bus Explorer to manage your queues and see the details inside the queues.