Subscribe, Report and Notify: 2. Spatial Business Rules

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2017.x


As of FME Server 2019+, this functionality can be completed using FME Server Automations. For more information, please see Tutorial: Getting Started with Automations. Note that this tutorial series will no longer be updated, if you encounter an error, please contact Safe Support.


FME Desktop 2017
FME Server 2017
PostgreSQL with PostGIS extension installed
Completion of previous Subscribe, Report and Notify tutorials



Subscribing to topics is a nice start, but doesn’t utilize FME’s core competency of spatial data handling. In most cases subscriptions will have a set of business rules that determine when the a device/user will be notified, which in our case will be spatial in nature. The most basic rule is a test to see if an incoming message is located within a geofence.



Remove Previous Workspace


To avoid confusion over which notifications are coming from which workspace, open the FME Server Web User Interface and remove the 1_processs_messages.fmw workspace. You could alternatively remove the subscription in the Notifications > Subscriptions page, leaving the workspace on FME Server.

Database with Subscriptions with Geofences

1) Open the 2_create_subscription_database.fmw workspace in FME Workbench.


Modify the PostGIS writer’s connection parameters to match your PostGIS database.



3) Open the AttributeCreator transformers and change the email addresses to your own email address. For testing purposes, use the +keyword notations to make the email addresses look unique in your email client (e.g.



4. In the Navigator panel find User Parameters > Published Parameters > [SourceDataset_SPATIALITE] Source SpatiaLite Database File(s).


5. Double click the path and the Edit User Parameter ‘SourceDataset_SPATIALITE’ dialog opens. Click the ellipsis (...) and search to where you saved the downloads for this tutorial. Browse to fme/data/ and select continents.sl3 and click Open. Click OK on the Edit User Parameter ‘SourceDataset_SPATIALITE’ dialog.


6. Run the workspace to create a table called subscription_database.


This creates a spatial database with three different email addresses subscribed to three different topics in specific geographic regions (in this case different continents). Again, manually editing this database is easy enough for static or low numbers of subscriptions.

Spatial Filtering and Notifications

1) Open the 2_process_messages.fmw workspace.


2) Note the VertexCreator and CoordinateSystem transformers that convert the textual representation of the messages location into a native FME geometry.

3) Open the FeatureReader transformer and modify the PostGIS reader’s connection parameters to match your PostGIS database. The FeatureReader is like the Joiner, except it also tests spatial relationships. (Make sure to select the corresponding subscription_database associated with your Table Qualifier - i.e. "public" in this example.)




4. Click to edit the text_line reader parameters. In the Edit ‘notification_2 [TEXTLINE]’ Parameters dialog, set the Source Text File(s) to your own downloaded copy of the notification_2.txt (located in fmepedia-subscribe-report-notify-tutorial-master/fme/data/ folder)



5. Publish the workspace to FME Server

  • repository: notification_tutorial
  • the Notification Service has the same settings as the previous tutorial.
  • Click Publish.



Now you have a configuration that will:

  • Receive messages from the concert_communications, nature_news and transit_tips topics.
  • Check the database to see which email addresses are subscribed to both the topic the message was received from AND the area where the message is located.
  • Send an email notification to the subscribed email addresses.

Report a message


1) Open the FME Server REST API from the FME Server Web User Interface by clicking: Developers> REST API > API> notifications: Notifications Manager > POST /notifications/topics/<topic>/message

2) For the body parameter enter:

"subject": "this just in...",
"message": "There was a sighting of a rare <b>warbleddash lizard</b> in Argentina near the Paraguay border",

3) For the topic parameter enter: nature_news


4) Click the Try it out! button.

5) You will prompted to login if you haven’t already (Remember: username and password are the same as your FME Server account). Afterwards click Try it out! again.

6) You should receive an email to the address you specified for the nature_news topic back when you created the database.

7) Try sending another message to the nature_news topic, this one outside of the subscription area:


"subject": "Largest tree prompts fort dreams",
"message": "The largest tree ever known has been discovered in Canada. Plans for the largest tree fort ever are pending.",


8) Since there is no subscription to both the nature_news topic AND an area that covers Canada, no notification will be sent.


Now you have created a simple system for managing subscriptions to topics and geographic areas using a database!



Was this article helpful?



Please sign in to leave a comment.