Intro to Notification Service: Receiving, Inspecting and Processing Notification Messages

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

Introduction

In FME Server you can use the notification service to push data in and out of FME Server in the form of a message when an event occurs. This can be achieved by defining a topic, setting up the subscription and reviewing the notification. For more detailed information on how the Notification Service works please review the documentation.

Downloads

CreateNotification.fmwt

Part 1: Defining a Topic

A topic gives publishers a target for sending notifications to and gives subscribers a source to receive notifications from. Topics can be defined using the following steps:

1. Open the FME Server Web User Interface at http://<server>:<port>/fmeserver and log in.

2. Click Notifications > Topics > New.

3. Give the topic a name such as NotificationTutorial, and optionally a description.

4. Click OK to create the topic.

At this point, you can start sending notifications to the new topic, but there is no subscription setup to accept the notification messages.

Part 2: Sending a Notification to FME Server

Notifications can be sent to FME Server using the FME Server REST API or FMEServerNotifier transformer. In most cases, a publication (defined in the Web User Interface) will send a message to a topic. However, the Test Topic option can be used when developing the solution:

1. Click Notifications > Topics.

2. Select the topic you created previously, NotificationTutorial, and click Test Topic.

3. Enter some text to send in a notification message and click OK.

testtopic.png

Test the NotificationTutorial topic

Part 3: Receiving a Notification

Inspecting a Notification

Common message formats include XML and JSON. Inspecting and understanding the contents of a notification message is key to being able to build a workspace that can process notifications.

Messages can be inspected using the Topic Monitoring ability in the Web User Interface:

1. In a new browser window/tab, open Notifications > Topic Monitoring, this window needs to stay open for Topic Monitoring to continue running.

2. Select the topic you want to monitor, NotificationTutorial, and click the play buttonjuowgyNc5XfHmBxLzKZGf6iFP9PFzW5i9uptQS0Y8xhsYTJJ4suwawnROLBEuUeSRreEsh5iKWbI-HQgX0X7SAP60BxTGRJqz3IqpxavH1kk_jrE111maHDajt80Q9xHfC4d_9Y to start monitoring the topic. Any messages sent to the topic will be displayed.

4. In a different window/tab, go to Notifications > Topics and use the Test Topic option mentioned previously to send a message.

topicmonitoring.png

Test Topic message in Topic Monitoring


Processing a Notification

An FME workspace is used to process notification messages. What you do with the message is up to you. You could write it to a database. You could pass it on to another service. You could tweet the message. You could compare it to other data and decide to take an action. You are only limited by your imagination.

Sample Notification Message

To create the workspace you need a sample message that can be utilized in transformers throughout the workspace - this message is often JSON or XML. A quick way to generate the sample message is to use Topic Monitoring, mentioned previously, or you can copy a sample from somewhere else, and then save the sample message into a text file.

Creating The Workspace

In order to process the messages you will need to follow these steps:

1. In FME Workbench, open up the CreateNotification.fmwt workspace and skip to step 5 or create a new workspace that reads the sample notification message using a Text File reader. Ensure that you set the Text File reader parameter 'Read Whole File at Once' to 'Yes'.

textfileparam.png

Text File Reader parameters

2. The source dataset path is published by default; leave it published. This will allow you to map the message from the topic into the workspace.

3. If your notification message is in JSON or XML format, then you can use a JSONFlattener or XMLFlattener transformer to convert the hierarchical model to a relational model (i.e. feature) and expose the attributes that are created.

4. Add in any additional transformers you want and a writer if required.

5. Publish the workspace to FME Server in a repository called “training” and call the workspace “NotificationWorkspace”. There are two options for setting up Registered Services:

  • Option 1: Do not register with any services, click Yes when the No Services Currently Selected dialog appears. Continue on to Configuring the Subscription.
  • Option 2: Register with the Notification Service. Click Edit… and for Subscribe to Topic select the NotificationTutorial, then move on to Test the Subscription, the subscription will be listed as username.repository.workspace

notificationservicesubname.png

Naming convention of Subscription when registering with the Notification Service


Configuring the Subscription

To have the workspace process messages you need to create a workspace subscription:

1. Click Manage Notifications > Subscriptions.

2. Click New to create a new subscription. Give it a name such as NotificationSubscription.

3. Under Protocol, select FME Workspace.

4. Select the topic you defined previously, NotificationTutorial, for the Topics Subscribed To parameter.

_ho9GhXzPVFRIb2v7VZehRNqKSvabf7I-vzVL859fWXRju-CxzXyJxNO_NnDxBDFFjDarD0eW4OrzyttKOfpHSBacLjPwhEM5vkFDQg1VKq1uZdWpXK5VNirWF6ldwaTawYhnwc

Set up the Subscription name, protocol and topics

5. Under Protocol Settings, set the Repository as training and the Workspace as NotificationTutorial. Ensure that Get Value from Topic Message is enabled.

subscriptionparam.png

Set up the repository, workspace and ensure Get Value from Topic Message is enabled

6. Click OK to create the subscription. The subscription will be listed as NotificationSubscription.

Test the Subscription

1. Use the Test Topic option to send a message

testsubscription.png

Testing the subscription

2. Check the Jobs page to confirm that the workspace ran successfully. This will be the same result for both Option 1 or 2 when setting up the Subscription.

jobs.png

Successfully run workspace in the Jobs page

loggerresults.png

Results of the test logged by the logger in the NotificationWorkspace.fmw job log

Congratulations! You have now successfully created a subscription that will run a workspace when a specific topic is triggered!

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.