how to enable a procedure when a message arrives

  • I have set up a service broker to handle some non critical things in an asynchronous way, to save time on client side.

    I can do everything : setup a message type, contract, queues, and services.

    Sending a message succeeds, receiving the message via a procedure works fine. (procedure is called procx)

    Now I want to be able to not call the procedure over and over again manually upon arrival of a message, so I try to enable the procedure call via activation on the queue.

    executed code :

    ALTER QUEUE stock_inventory_update_receiver_queue

    WITH ACTIVATION

    ( STATUS = ON,

    MAX_QUEUE_READERS = 10,

    PROCEDURE_NAME = procx,

    EXECUTE AS OWNER

    );

    after that, sending a message still works, but it seems like the procedure is not called, because the message remains in the receiver queue. (It is supposed to be read (destructively) in the procedure.)

    The data that is supposed to be written is not in the database as well, which strengthens my belief that the procedure just did not fire.

    If I try to do a manual read after that (RECIEVE...)

    RECEIVE CONVERT(NVARCHAR(max), message_body) AS message

    FROM stock_inventory_update_receiver_queue

    I get the following error :

    Msg 9617, Level 16, State 1, Line 6

    The service queue "stock_inventory_update_receiver_queue" is currently disabled.

    Upon activating the queue and reading

    ALTER QUEUE stock_inventory_update_receiver_queue WITH STATUS = ON;

    RECEIVE CONVERT(NVARCHAR(max), message_body) AS message

    FROM stock_inventory_update_receiver_queue

    The manual recieve works again.

    sending a new message, again disables the queue

    So this means that the enabling of the procedure call

    1. doesn't work/does not trigger the procedure

    2. disables my queue

    I am getting the suspicion that i might be blocked by security, or that the 'enabling' requires something else to be 'enabled/disabled'

    The creation of the message type, queue,... happens without authorisation.

    Can someone pinpoint the problem?

  • Did you ever resolve this problem?

    We're suffering with a similar issue - if we manually force the queue to enabled and run the process queue code, it works. There are no errors. But, if we switch the queue on, post a message it switches the queue off.

  • no solution found until now, I'm afraid.

    I tried several other fora as well, but with no success.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply