Connecting To The Outside World with Perl and Database Events
Written by Nikos Vaggalis   
Monday, 19 November 2018
Article Index
Connecting To The Outside World with Perl and Database Events
The Internals
The Perl
Conclusion

Watch it in action

To prove that everything is working as expected, I'm opening two terminal sessions side by side.The first one is just running the Perl daemon in the foreground and the second is going to perform the inserting of the values into table PatientVisit, simulating the data entry through the GUI form, which is an action that ought to activate the rule based subsystem, producing a HL7 message at the daemon's session end.

 

 

The End

The use case has deliberately been kept simple to just give a sense of the underlying concepts, but it can be applied to scenarios of any level of complexity and business case. For example, calling a web service at the end is just an option; it could very well have been posting a message to a RabbitMQ queue, or it could be notifying a webhook, just as Skor does. Skor is a utility for Postgres that calls a webhook with row changes as JSON whenever an INSERT, UPDATE or DELETE event occurs on a particular table.It works using a pg_notify trigger function and a tiny C program that listens to the notifications and calls the configured webhook with a JSON payload.

In essence, what I've just gone through is behind the scenes of the type of mechanism that Skor encapsulates, but even more elaborate and fine-grained, and instead of Postgres I've used Ingres and in place of C, Perl.

To wrap it up, database events give your database a voice of its own. In contrast to what is usually happening, that is applications calling the database, the database is now able to call out to them. Which makes me ponder, is this a form of reactive programming? Is it event driven under the Observer pattern? Is it push or pull? Which kind of programming model does this approach fall in, and does terminology actually matter anyway?

If you know the answer and want to help me achieve peace of mind, leave a comment using the discussion form at the end of the article.

dbevent logo

 

 

Accompanying code:

patient_event_A01.pl

patient_event_gateway.pl

insert_data.sql

create_rule_sp_dbevn.sql

create_tables.sql

Related Articles

Health Level 7 (HL7) with Perl 

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Spot With AI - The New Robotics
29/12/2024

It was just last week I complained that despite the advances in AI robots seems to be just as stupid as ever. Now  I have found a video of Spot embracing AI in a way that is a step on the way to  [ ... ]



Meta's MultiModal, MultiLingual Translator
21/01/2025

Meta has taken us a long way towards creating a Babel Fish, a tool that helps individuals translate speech between any two languages. This is thanks to SEAMLESSM4T which is open-source for non-co [ ... ]


More News

 

espbook

 

Comments




or email your comment to: comments@i-programmer.info



Last Updated ( Monday, 19 November 2018 )