-1

I am using the Microsoft ODBC driver on a Linux system to connect to SQL Server 2012 on Windows to use the Query Notification feature. I run my C code and can see my subscription appear in sys.dm_qn_subscriptions as I expect, then my code sends a WAITFOR and blocks - fine so far. Then I do a transaction that will trigger the notification, and I get it - still fine. What I would like to do is then process the notification and loop around again to WAITFOR but after the first notification my subscription no longer appears in the DMV. My question is, is this the intended behaviour and I should re-subscribe every time, or is something weird happening?

1 Answer 1

1

The query notification is removed after the message is sent so you'll need to re-subscribe if you want to continue to receive notifications. Here's the relevant excerpt from the doc you referenced.

Notifications are sent only once. For continuous notification of data change, a new subscription must be created by re-executing the query after each notification is processed.

1
  • Don't know how I missed that - thanks! I must have read that page a dozen times...
    – Gaius
    Nov 29, 2017 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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