I'm trying to write a Postgres trigger such that when a configuration table is updated, a backend component is notified and can handle the change. I know that Oracle has the concept of a web/HTTP trigger, where you can execute an HTTP GET from the Oracle instance itself to a URL that can then handle the request at the application layer. I'm wondering if Postgres (v. 9.0.5) has the same feature, or comes with anything similar (and, subsequently, how to set it up/configure it)?
You could call a Python stored procedure with PL/Python from your trigger and make your http get request using Python's standard libraries.
Related
I am using sqlite in a multi process scenario. The sqlite library was compiled with the threadsafe serialized mode (-DSQLITE_THREADSAFE=1).
I want to be notified on datachanges and found sqlite3_update_hook. Every process would register it's own update hook to be notified of changes to the database.
The question now is: If a process A modifies the database, will the update hook of process B be called? Or do hooks only work within the same process or the same connection?
Sadly, the documentation is not very clear about that.
The documentation says:
The sqlite3_update_hook() interface registers a callback function with the database connection identified by the first argument
The database connection is a local object; the hook will not fire for any other connection, in this or another process.
I have a Java Servlet which writes a message to the database. Some other tier picks up this message from the DB and processes it and updates the status of this message in the database. Meanwhile in the servlet, I have to keep polling the database to get an update on status of the message which was written earlier.
How can I implement a Callback instead of polls so that unnecessary database queries are avoided?
I suppose you're talking about server push technologies. I suggest you to use HTML5 websockets for this. Use your same servlet with a websocket to communicate between both ends.
There are so many examples out there.
Java WebSockets - In this example he uses jetty, but you can
use jboss or tomcat for this.
StackOverFlow post describe the same.
pushing data for multiple clients from a server via websockets
try above links and it is worth for trying.
Are Meteor.methods they only way to call server-side functions from the client?
http://docs.meteor.com/#/full/meteor_methods
the docs don't make it clear that they are they only way, but the fact that they exist seems to imply they are the only way. What is their purpose?
There are several ways to communicate back and forth between the server and client in Meteor :
Using Meteor.methods to perform Remote Method Invokation on the server, these calls are initiated by the client, ask for a computation to be performed on the server and receive a result.
Using the Pub/Sub mechanism, the server publishes a set of data and the client is subscribing to a subset of this data, being notified in real-time of data-updates taking place in the server and thus receiving modifications.
Using plain old HTTP requests with the HTTP module.
So Meteor.methods are not the only way to execute some code on the server upon a client request.
Their purpose is usually to update the database by providing new values for server-side collections, as a matter of fact, client-side collection inserts and updates are implemented as Meteor.methods.
The Pub/Sub mechanism is used to propagate DB updates to every connected client and to make sure they receive only the minimal subset they need.
The HTTP communication is used by the server to send the initial source code (HTML/JS/CSS) of the app on load time as well as performing standard operations such as requesting and downloading a file.
I would like to use Rebus for integration with third-party application by adding triggers to that application's database so the triggers would insert records in format of Rebus message containing information about changes in database (operation type: insert, update, delete, table name and row id). Tell me please is there some way to do this easily or I would need to create stored procedure myself by looking into https://github.com/rebus-org/Rebus/blob/master/src/Rebus/Transports/Sql/SqlServerMessageQueue.cs Send method?
Alternatively I could just fire the exe with parameters from the trigger but it is not transactional.
Also I've seen this issue https://github.com/rebus-org/Rebus/issues/119 but I guess it's dead idea.
Maybe there is other recommended approach?
Update: I just realized body of Rebus message is serialized so it would be insane to do that in SQL (and even not possible without SQL-CLR) so maybe the only way would be to create custom transport with ReceiveMessage method accepting messages in my own format?
Thanks in advance :)
I've had excellent results integrating with "stuff happening in SQL Server" by using SQL Server Service Broker - not directly (i.e. as a Rebus transport implementation), but as a message queue that I could poll from the outside.
Whenever something interesting happened in the database, a trigger would query some tables and select the result set out for xml auto into an XML message that would be sent to a service broker queue.
I then had a Rebus endpoint with a System.Timers.Timer that would poll the broker queue and bus.SendLocal the received XML as a string - this way, everything from parsing the XML and on would be based on Rebus messages, retries, and error queues, and the customary reliability that follows :)
I have a requirement where third party software running on a desktop will write to a local database and I need to send some of that information to a remote web service. I don't have any control over the thirdparty software that is doing the insert but I can read the database.
My approach is to have a windows service check the local table every second for an insert, if there is an insert send the webservice request. I don't like checking every second but this whole process needs to happen in a short amount of time after the insert. Is there a better way to go about this? Some kind of listener? I don't think I can use triggers.
This will be .NET and SQL Server if that matters.
Try using the SQLDependency class. Implement the onChange method of the class to handle your processing. The following article describes the process of configuring your environment and has some sample code for this.
http://www.codeproject.com/Articles/144344/Query-Notification-using-SqlDependency-and-SqlCach