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


DORA Report Reveals Widespread Reliance On AI
30/09/2025

90% of professional developers now use AI at work, up 14% from 2024, spending a median of two hours per day working with AI tools. Nearly two-thirds rely on AI for at least half their workflow, and fo [ ... ]



Petition Microsoft To Defer Windows 10 End of Support
03/10/2025

With 10 days to go until Microsoft ends free support for Windows 10, Windows 7 has seen an uptick in its market share, while Windows 11 has seen a slight downturn. A new petition is asking Microsoft t [ ... ]


More News

 

pico book

 

Comments




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



Last Updated ( Monday, 19 November 2018 )