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


JetBrains Makes WebStorm and Rider Free for Non-Commercial Use
24/10/2024

JetBrains has launched a non-commercial license for its JavaScript and TypeScript IDE, WebStorm, and for Rider, its cross-platform .NET and game development IDE.



Extend NGINX With The New JavaScript Module
28/10/2024

Inject middleware functionality into NGINX with the expressive power of Javascript. NGINX JavaScript or NJS for short is a dynamic module under which you can use scripting for hooking into the NGINX e [ ... ]


More News

 

espbook

 

Comments




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



Last Updated ( Monday, 19 November 2018 )