Skip to content

integration.amqp.overview

Brian Greco edited this page Jan 23, 2021 · 11 revisions

AMQP Overview

The NetFusion.AMQP plugin is based on the AmqpNetLite open-source library NuGet package. This plugin provides the following features:

  • Consistent configuration similar to other plugins.
  • Integrates with the base NetFusion.Messaging plugin allowing for similar configuration to other messaging technologies.
  • Provides an implementation of the IMessagePublisher interface allowing commands and domain-events to be published to an AMQP compliant broker.
  • Provides extension points for AMQP known items such as Subscriptions but for their creation is not part of the AMQP standard. While AMQP can subscribe to subscriptions, it does not implement the creation of the subscriptions.

Configuration

The NetFusion.AMQP NuGet containing the AMQP plugin must be referenced and added to the composite-container by calling the AddAmqp method:

public void ConfigureServices(IServiceCollection services)
{
    services.CompositeContainer(_configuration, new SerilogExtendedLogger())

        .AddAmqp()

        .AddPlugin<InfraPlugin>()
        .AddPlugin<AppPlugin>()
        .AddPlugin<DomainPlugin>()
        .AddPlugin<WebApiPlugin>()
        .Compose();

    services.AddControllers(); 
}

The examples provided are based on Azure Service Bus which is AMQP compliant.

The following show an example configuration:

{
  "netfusion": {

    "amqp": {
      "hosts": [
        {
          "hostName": "claims-bus",
          "hostAddress": "claims-bus.servicebus.windows.net",
          "username": "Service-Bus-User",
          "password": "Service-Bus-User-Password"
        }
      ]
    }
  }
}

The above settings correspond to an Azure Service Bus Namespace. After the namespace is created, select the namespace from the list of services listed for the assigned resource group. Obtain the above settings as follows:

  1. Select the created Service Bus Namespace.
  2. From the left side menu, select Shared access policies.
  3. Next, select the policy named, RootManageSharedAccessKey.
  4. To the right, a panel will display containing the above settings.

Note the following:

  • The hostAddress can be found within the beginning of the Primary/Secondary Connection String value.
  • The password can be found within the Primary/Secondary Key values.

IMAGE

With an Azure Service Bus Namespace, Queues and Topics are created to which messages can be published. The examples in this documentation will be based on the domain for an insurance company's claims handling. The following will be created within this namespace:

  • claim-submissions: Queue to which new claims are published for processing.
  • claim-status-notification: Topic to which messages are published when their status is updated.

Create the above Queue within the claims-bus namespace as follows:

  1. Navigate to the claims-bus namespace.
  2. From the left menu, select the Queues option.
  3. From the toolbar, select the add Queue button.
  4. A panel will display used to defined the queue:

IMAGE

Create the above Topic within the claims-bus namespace as follows:

  1. Navigate to the claims-bus namespace.
  2. From the left menu, select the Topics option.
  3. From the toolbar, select the add Topic button.
  4. A panel will display used to defined the topic:

IMAGE

Topic's also require that a subscription be created on the defined topic. Note that the following will manually create a subscription. However, in a real business solution, consumers will usually defined subscriptions specific to their needs.

Create a subscription on the ClaimStatusNotification topics as follows:

  1. Select Topics from the left menu.
  2. Select the topic named: claim-status-notification.
  3. Select the add Subscriptions button on the toolbar.
  4. Enter the following in the displayed panel:

IMAGE

The above created namespace, queue, topic, and subscription will be referenced in the Publisher and Subscriber sections.

Queue vs. Topic

The different between a queue and a topic in Azure Service Bus is that a message published to a topic is delivered to all subscriptions created on the topic. Whereas a queue delivers the message to only one subscriber and therefore is only handled once. For this reason, Commands are sent to queues and domain-events are published to topics.

Clone this wiki locally