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


The Feds Want Us To Move On From C/C++
13/11/2024

The clamour for safe programming languages seems to be growing and becoming official. We have known for a while that C and C++ are dangerous languages so why has it become such an issue now and is it  [ ... ]



Flutter Forked As Flock
05/11/2024

One of developers who worked on the Flutter team at Google has created an open-source form of the framework. Matt Carroll says Flock will be "Flutter+", will remain constantly up to date with Flutter, [ ... ]


More News

 

espbook

 

Comments




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



Last Updated ( Monday, 19 November 2018 )