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


Microsoft Is Ending Support For Windows Android Subsystem
07/03/2024

Microsoft has announced that it is ending support for running Android applications under Windows 11. The support will cease next year. This announcement was followed rapidly by Amazon announcing the e [ ... ]



Master Large Language Model Ops
20/03/2024

New technology brings with it more career opportunities. You may never have imagined becoming an LLMOps consultant,  but there's now a Coursera Specialization which provides preparation for this  [ ... ]


More News

 

raspberry pi books

 

Comments




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



Last Updated ( Monday, 19 November 2018 )