Skip to main content

Event Mesh Gateway

The Event Mesh Gateway connects Solace Agent Mesh (SAM) to your existing event mesh infrastructure. Through its asynchronous interfaces, applications within your event mesh can seamlessly access and utilize Solace Agent Mesh capabilities.

This tutorial shows you how to build an Event Mesh Gateway that automatically generates and adds concise summaries to Jira bug reports, making them easier to understand at a glance.

Prerequisites

This tutorial assumes you have an existing Jira application integrated with your event mesh that:

  1. Publishes a "jira_created" event to topic jira/issue/created/<jira_id> when a new Jira issue is created
  2. Listens for "jira_update" events on topic jira/issue/update to update existing issues

You will create an Event Mesh Gateway that:

  1. Monitors for new Jira issues.
  2. Automatically generates a concise summary.
  3. Creates an event to update the original Jira issue with this summary.

This creates a streamlined workflow where bug reports are automatically enhanced with clear, AI-generated summaries.

Setting Up the Environment

First, you need to install Solace Agent Mesh and the Solace Agent Mesh (SAM) CLI, and then you'll want to create a new Solace Agent Mesh project

For this tutorial, you will need to create or use an existing Solace Event Broker or event mesh created using PubSub+ event brokers.

Creating the Event Mesh Gateway

Once you have your project set up, you can add the plugin to Solace Agent Mesh:

solace-agent-mesh plugin add solace-event-mesh --pip -u git+https://github.com/SolaceLabs/solace-agent-mesh-core-plugins#subdirectory=solace-event-mesh

Next, create an instance of Event Mesh Gateway. The following command will create the configuration for a new gateway (named jira) as well as the input and output configuration for the event mesh interface:

solace-agent-mesh add gateway jira --interface solace-event-mesh

Expected output:

Created the following gateway template files:
- ./configs/gateways/jira/gateway.yaml
- ./configs/gateways/jira/solace-event-mesh.yaml

Configuring the Event Mesh Gateway

The Event Mesh Gateway configuration is located in ./configs/gateways/jira/solace-event-mesh.yaml. You will modify its input and output processors to meet the requirements.

Input Processor

First, let's configure the input processor, with the instruction to create summaries from newly created Jira tickets:

  - event_mesh_input_config: &event_mesh_input_config
identity: jira_event_mesh
event_handlers:
- name: jira_event_handler
subscriptions:
- topic: jira/issue/created/>
qos: 1
input_expression: >
template:Create a concise summary for the newly created jira: title:{{text://input.payload:title}} body:{{text://input.payload:body}} id:{{text://input.payload:id}}. Return a json file with fields `id`, `type` (value is "summary") and `summary`.
payload_encoding: utf-8
payload_format: json
output_handler_name: jira_summary_emitter

This input processor subscribes on the topic for newly created JIRAs (jira/issue/created/>), and creates a prompt using an input_expression that instructs Solace Event Mesh to create a summary of the Jira based on the title and body fields in the event. The response is returned as a JSON file.

Output Processor

Next, you configure the output processor to publish the summary to the update topic:

  - event_mesh_output_config: &event_mesh_output_config
output_handlers:
- name: jira_summary_emitter
attach_file_as_payload: true
topic: jira/issue/update
payload_encoding: none
payload_format: text

The jira_summary_emitter output handler takes the json file with the summary, and adds it to the event payload. The event topic is jira/issue/update. By default, the file contents are added in base64 encoded format, so no additional payload encoding is required.

Configuring the Gateway

To ensure the gateway functions as a programmatic interface, configure it to return JSON responses only. Update the system_purpose in ./configs/gateways/jira/gateway.yaml

      system_purpose: >
This is a programmatic interface. Return all responses as valid JSON objects without any additional formatting or markdown.

Building and Running the Event Mesh Gateway

Now, you can build and run the Event Mesh Gateway:

sam run -be

For more information, see Solace Agent Mesh CLI.

Testing the Event Mesh Gateway

Now that the system is running, let's test the Event Mesh Gateway.

  1. Open the Try Me! tab of the Solace PubSub+ Broker Manager.

  2. Connect both the Publisher and Subscriber panels by clicking their respective Connect buttons.

  3. In the Subscriber panel:

    • Enter jira/issue/update in the Topic Subscriber field
    • Click Subscribe
  4. In the Publisher panel:

    • Use the topic jira/issue/created/JIRA-143321
    • In the Message Content field, enter:
{
"id": "JIRA-143321",
"title": "Exception when reading customer record",
"body": "I got a DatabaseReadException when trying to get the data for customer ABC. The error indicated that the customer didn't exist, while they are our biggest customer!"
}

Next, click Publish.

After a few seconds, you will see a new message in the Subscriber messages with topic jira/issue/update and a body similar to below:

ewogICAgImlkIjogIkpJUkEtMTQzMzIxIiwKICAgICJ0eXBlIjogInN1bW1hcnkiLAogICAgInN1bW1hcnkiOiAiRGF0YWJhc2VSZWFkRXhjZXB0aW9uIGVuY291bnRlcmVkIHdoaWxlIHJldHJpZXZpbmcgY3VzdG9tZXIgQUJDIGRhdGEiCn0=

Base64 decoding this message payload produces the json body with the expected field, id, typeand summary.

{
"id": "JIRA-143321",
"type": "summary",
"summary": "DatabaseReadException encountered while retrieving customer ABC data"
}