Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for notification usage #46

Open
geohuz opened this issue Jan 21, 2022 · 4 comments
Open

Example for notification usage #46

geohuz opened this issue Jan 21, 2022 · 4 comments
Assignees

Comments

@geohuz
Copy link

geohuz commented Jan 21, 2022

Is there any example code for pg notification?

@dboris
Copy link

dboris commented Jan 27, 2022

See usage in prompt.ml: dump_notification

@mmottl
Copy link
Owner

mmottl commented Jan 27, 2022

Thanks, @dboris, yes, prompt.ml and prompt_gtk.ml contain some example code.

@mmottl mmottl closed this as completed Jan 27, 2022
@geohuz
Copy link
Author

geohuz commented Aug 17, 2024

I'm sorry to come back this later, I'm afraid the mechanism in the "dump_notifcation" is not the same as the async listen and notify on channel. As stated in https://www.postgresql.org/docs/16/libpq-notify.html , which is basically clients run PQexec(conn, "LISTEN testChannel"), and on the server or other end point you execute the select pg_notify('testChannel', 'Hi there').

PostgreSQL offers asynchronous notification via the LISTEN and NOTIFY commands. A client session registers its interest in a particular notification channel with the LISTEN command (and can stop listening with the UNLISTEN command). All sessions listening on a particular channel will be notified asynchronously when a NOTIFY command with that channel name is executed by any session. A “payload” string can be passed to communicate additional data to the listeners.

@mmottl mmottl reopened this Nov 5, 2024
@mmottl
Copy link
Owner

mmottl commented Nov 5, 2024

Sorry for the late reply. I don't have time to investigate this right now, but please feel free to propose any changes that will make the code consistent with the expected functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants