Create a Listener

'Listeners' is a service that allows businesses to receive real-time notifications when specific events occur on Networks and Deployed Applications. These notifications can include transactions, smart contract events, and more. By using Listeners, businesses can streamline their workflow and quickly respond to critical events as they occur.

To create a listener:

  1. Open the desired network.

  2. In the left menu, click on "Listeners".

  3. Click "Create Listener".

  4. Fill out the required details in the pop

Part 1: Event Listener Configuration

  1. Set Owner Organization

    • Specify the owner organization for the listner

  2. Select Channel

    • Pick the channel where the listener should operate.

  3. Choose Application

    • Select the application within the chosen channel you want to monitor.

  4. Select Listener Type

    • Choose between app events (e.g., asset created, asset updated) and network events (e.g., commit block, commit event).

Part 2: Events & Filter

  1. If the listener type is network, select the type of event you want to be notified about. Learn more about network events here

  1. If the listener type is "app," select the type of event to be notified about.

You can choose from asset type events, asset events, workflow events, or approval events. Learn more about app listener events.

Additionally, you add filters if you want to listener to a very specific event.

For instance, to filter events for a specific asset type where any of its data fields match a certain criterion, such as

{
	"eventData": {
		"docDefName": "invoice",
		"data": {
			"status": "completed"
		}
	}
}

Multiple conditions can be added, but it always uses "and". There is no support for "or

{
	"eventData": {
		"docDefName": "invoice",
		"data" : {
			"status": "completed",
            "payment": "pending"
		}
	}
}

Part 3: Listener URL & Authentication

  1. Select the type of URL and enter the listener URL.

  2. Select authentication type for the source URL between basic, custom or none

    • If authentication type is basic, enter the username and password

    • If authentication type is custom, enter custom key value pair(s)

    • If authentication type is none, no authentication is required to use the source URL

Once these details are entered, click 'Create Listener'


Example of a typical whole event:

{
  "channelName": "default",
  "listenerType": "App",
  "eventType": "MyEvent",
  "event": {
    "chaincode_id": "scm-vehicle",
    "tx_id": "066be7da1f984afba933e458e66ec6299b8982672194fa37b5e2d8195420b81f",
    "event_name": "UpdateAssets",
    "payload": {
      "actions": [
        {
          "name": "UpdateAsset",
          "message": "Updated asset id - m1.",
          "eventData": {
            "id": "m1",
            "docType": "asset",
            "docDefId": "6693050f49d2aa750953c939",
            "docDefName": "rawmaterial",
            "data": {
              "density": 7.8,
              "materialId": "m1",
              "modulusOfElasticity": "200 GPa",
              "name": "Steel",
              "optionalField": "present",
              "tensileStrength": "400 MPa",
              "thermalConductivity": "50 W/m·K",
              "yieldStrength": "351 MPa"
            },
            "owners": [
              {
                "orgId": "66916d82618ff9e8799b349e"
              }
            ],
            "createdAt": "2024-07-24T08:47:22.407Z",
            "updatedAt": "2024-09-20T20:28:01.706Z",
            "createdBy": {
              "orgId": "66916d82618ff9e8799b349e"
            },
            "updatedBy": {
              "orgId": "66916cf1618ff9e8799b32df"
            }
          }
        }
      ]
    }
  }
}

Last updated