Azure Service Bus Messaging with Dynamics AX 2012 (part 1)


Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of D:\home\site\wwwroot\webapp\includes\

As Dynamics AX becomes more prominent in your overall IT landscape, integration scenarios will become more challenging.  We all know the joys of scheduled maintenance in terms of AX, as it is best practice to take your production system offline and deploy updates in the form of modelstores. 

While a good reboot is often a healthy thing, we like to prevent the “We’re down for maintenance, come back soon!” messages on any of our customer-facing software like a website, mobile, and supply chain applications to name a few.

To best allow for components of an overall systems architecture to be offline, one should implement de-coupling via Queues.  Queues are exactly what they sound like, a middle-tier that accepts, stores, and relays messages from one software to another.  This allows a website for example to continue to accept sales orders, while a backend shipping system may be offline for maintenance.  This prevents any nasty error messages being presented to customers, and also allows having multiple backend worker threads processing a centralized queue for higher performance and throughput.

Focusing on Dynamics AX 2012 R3 (although it is generally applicable to any release of 2012), I’ll show you how to Create a Queue, utilize .NET Interop to marshal messages from the queue into an X++ object, and create a SysOperation framework class which taps into the multi-threading capabilities of the batch framework for high throughput.

Assuming you already have signed up for an account with Azure (it's free to start!), navigate to your management portal and create a new Service Bus resource:

You'll want to dedicate a new namespace.  A namespace can have many queues, as a logical  unit.  

Configure the queue as you wish, I have a hard time imagining a queue size larger than 1GB being truly necessary but hey! It's up to you. Azure has a lot of great side benefits here, with duplicate message detection, and allowing you to capture expired messages in to the dead letter sub-queue for follow up.

After the system has setup your new Service Bus namespace and queue, go in to the Configuration tab of the namespace.  Here you can create a new shared access key that can manage the entire namespace and all queues, topics, and event hubs therein. 

In the next post, we'll review NuGet and how to access these resources in Visual Studio.