Migrating to an Event-Driven Architecture Example

The following sections provide an example of how you can use a Microgateway to migrate from a traditional request/reply architecture to an event-driven architecture.

Under a traditional request/reply architecture, adding a new event-driven service means taxing every existing microservice to support at least two message exchange patterns (events and request/reply). Because a Microgateway can translate incoming events into REST HTTP requests, you can add new event-driven applications without having to interfere with existing services. In addition, you can have both environments in operation until you are ready to remove the older services.

Overview

In this example, we'll create a Solace PubSub+ software event broker, configure a Microgateway on it, and publish an event containing a specified IP address to the event broker using a sample browser-based application. The Microgateway on the event broker translates the event into a REST HTTP request before sending it to a Geo Finder application. Once received, the Geo Finder application responds to the request with geographical information about the IP address.

The browser-based event publisher represents a new event-driven microservice you are adding to your environment, and the Geo Finder application represents an existing REST HTTP endpoint.

Before You Begin

It's assumed you have:

  • Windows 10 Pro, or Mac OS X Yosemite 10.10.3 or higher.
  • Docker for Mac, or Docker for Windows installed, with at least 2 GiB of memory dedicated to Docker Engine. For more information about allocating memory and swap space, refer to Docker for Windows or Docker for Mac settings page.
  • Google Chrome as your current browser.

Step 1: Create a PubSub+ Software Event Broker

To create a PubSub+ software event broker for this example:

  1. Start Docker Engine and open a command-line terminal.

  2. Download the singleNode.yml Docker compose template file:

    curl https://raw.githubusercontent.com/SolaceLabs/solace-docs-assets/master/microgateway/singleNode.yml -O
  3. Create a PubSub+ software event broker using the compose file:

    The compose file in this example publishes a number of container ports to the same ports on your host machine. If any of these ports are in use, the event broker will not activate.

    docker-compose -f singleNode.yml up -d

    If the event broker creation is successful, the following output is displayed in the terminal:

    Creating pubSubStandardSingleNode ... done

Step 2: Configure a Microgateway on the PubSub+ Software Event Broker

Before your event broker can process events, you need to configure a Microgateway on a message VPN.

You can configure your event broker using one of the following methods:

To learn more about the components that constitute a Microgateway, refer to Traffic Management to Microservices Example.

Configure a Microgateway using SEMP

To configure a Microgateway on your event broker using the sample management application below (which uses SEMP requests to set up each component):

  1. Click Run Pen to load the application.
  2. Click Setup.

If the configuration is successful, the following is displayed in the Response field:

default VPN exists  --> creating queue gtwQ
created queue gtwQ
changed VPN mode to gateway
added topic subscription to gtwQ
added RDP to gtwQ
binding RDP to gtwQ
created rest consumer for rdp  gtwRdp

If the Response field does not display any information, you may need to wait a minute for the event broker to finish activating and try again.

See the Pen Solace PubSub+ Configure MicroGateway by Solace Cloud (@solacecloud) on CodePen.

Configure a Microgateway using the Solace CLI

To configure a Microgateway on your event broker using the Solace CLI:

  1. Enter the following docker exec command to access your event broker's CLI.

    docker exec -it pubSubStandardSingleNode /usr/sw/loads/currentload/bin/cli -A
  2. Enter the following commands.

  3. Enter the following show command to verify that the event broker is ready to process requests (both the Admin State and Oper State flags are Up).

Step 3: Publish an Event

To publish an event with the sample application provided below:

  1. Click Run Pen to load the application.
  2. Click Connect to connect to your event broker.
  3. Enter an IP address in the IP (get geo location) field.
  4. Click Request to publish the event through your event broker to the Geo Finder endpoint.

The geographical information associated with the IP address you passed into the request is displayed in the Response field.

See the Pen Event Driven Microservice (Solace PubSub+) by Solace Cloud (@solacecloud) on CodePen.

Step 4: Cleanup

To remove the event broker and clean up all associated resources, enter the following docker-compose command:

docker-compose -f singleNode.yml down -v

Next Steps

At this point you'll have created a Solace PubSub+ software event broker, configured a Microgateway on it, and published an event through the event broker to an existing REST HTTP endpoint.

This example should provide you with some ideas as to how you can use a Solace Microgateway to add event-driven applications to an existing request/reply architecture as part of your migration to an event-driven architecture.

From here, we encourage you to review the following topics to learn more about other capabilities that are enabled with the Microgateway feature: