0

If I send notifications before starting to listen i.e.

notify test, 'test message';
listen test;

I loose that notifications. How can I persist them for later fetching? Actually, I need this notifications for tables updates, so it is preferably not to start spezialized messaging system like RMQ etc.

1
  • I'm voting to close this because nothing more about it can be said then what I said. It doesn't do that. None of the docs would lead you to believe it does that. Dec 2 '17 at 19:48
4

You can't replay them. If no one is listening, they're gone. Start up your own communication daemon to catch them. Then you can do whatever you want.

12
  • Yes, I will start my own daemon, but I can't guarantee it will work without interruptions. I want secure myself from losing messages.
    – AstraSerg
    Dec 1 '17 at 10:25
  • 2
    Then don't use listen/notify. Insert into a table called messages and have something read them and reap them. Dec 1 '17 at 16:47
  • 1
    Hope, this is not the only solution
    – AstraSerg
    Dec 1 '17 at 17:02
  • 2
    There is no hope. It's the wrong tool for the job. It's just not what NOTIFY/LISTEN does. If you need the message stored in another table (queue), you need to create another table and write to it. Or, use an audit table. There are lots of methods that probably do what you want, but LISTEN/NOTIFY has nothing to do with it. Dec 1 '17 at 19:27
  • 1
    Yes. I am, because they'll read from the buffer anyway. While 50ms isn't a problem, I would probably be a bit more reasonable. Unless you need that resolution. Dec 4 '17 at 15:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.