none
notify when message arrives

    Question

  • Using a stored procedure, message was created and sent to a queue. Then control was retun back to user to complete other task. Now, how would I know if there is a message arrived in the target queue? Do I need to run a service for this? Is there any inbuild mechanism in Service Broker?

    Thursday, July 25, 2013 2:54 PM

Answers

  • Now, how would I know if there is a message arrived in the target queue? Do I need to run a service for this? Is there any inbuild mechanism in Service Broker?

    What process will be consuming the message?  If your objective is to process the message via T-SQL asynchronously, you can create a stored procedure with queue activation to process the message.

    I think we can provide better suggestions if you provide more details of what you are trying to accomplish.  Be aware that Service Broker conversation is bidirectional dialogs so both the initiator and target need to receive messages, typically on different queues.  This will ensure conversations are properly cleaned up and avoid leakage.  There are a number of patterns (and anti-patterns) with Service Broker that vary depending on the your situation.


    Dan Guzman, SQL Server MVP, http://www.dbdelta.com


    Saturday, July 27, 2013 2:52 PM

All replies

  • may schedule a job check target queue
    Saturday, July 27, 2013 2:12 PM
  • Now, how would I know if there is a message arrived in the target queue? Do I need to run a service for this? Is there any inbuild mechanism in Service Broker?

    What process will be consuming the message?  If your objective is to process the message via T-SQL asynchronously, you can create a stored procedure with queue activation to process the message.

    I think we can provide better suggestions if you provide more details of what you are trying to accomplish.  Be aware that Service Broker conversation is bidirectional dialogs so both the initiator and target need to receive messages, typically on different queues.  This will ensure conversations are properly cleaned up and avoid leakage.  There are a number of patterns (and anti-patterns) with Service Broker that vary depending on the your situation.


    Dan Guzman, SQL Server MVP, http://www.dbdelta.com


    Saturday, July 27, 2013 2:52 PM