PostgreSQL学习第十四篇 listen与notify
发布时间:2020-12-13 16:58:38 所属栏目:百科 来源:网络整理
导读:PostgreSQL提供了client端之间通过服务器端进行消息通信的机制。这种机制是通过listen和notify命令来完成的。session1:postgres=# listen postgres;LISTENpostgres=# listen limingpostgres-# ;LISTENsession2:postgres=# notify postgres,'hello word';NO
PostgreSQL提供了client端之间通过服务器端进行消息通信的机制。这种机制是通过listen和notify命令来完成的。 session1: postgres=# listen postgres; LISTEN postgres=# listen liming postgres-# ; LISTEN session2: postgres=# notify postgres,'hello word'; NOTIFY postgres=# notify liming,'hello liming'; NOTIFY postgres=# session1; postgres=# select 1; --随便执行了一个命令 ?column? ---------- 1 (1 row) Asynchronous notification "postgres" with payload "hello word" received from server process with PID 12241. Asynchronous notification "liming" with payload "hello liming" received from server process with PID 12241. postgres=# listen和notify的相关命令: 1. listen:监听消息通道 2. unlisten:取消先前的监听 3. notify:发送消息到消息通道中 4. pg_notify():与notify命令功能相同 5. pg_listening_channels():调用此函数可以查询当前session已注册了哪些消息监听 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |