简体   繁体   中英

SQL Service broker disable after database restart

I am a newbie at SQL Service Broker so pardon my ignorance.

We have a SQL Service broker that needs to be enabled again after the database has restarted. How can we get to be automatically enabled after the sql service restart?

Also we are able to send messages when the broker is disabled and it throws no SQL error. We can search the queue and it has nothing (neither of the queues - see below).

Once we enable the broker all the messages appear on the queue. Is that a normal behavior or some missconfiguration.

See below for the configuration of the service broker.

Thank you,

Greg

ALTER DATABASE our_database SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE



CREATE MESSAGE TYPE IncomingFileMessage
VALIDATION = NONE;


CREATE CONTRACT IncomingMessageContract
(IncomingFileMessage SENT BY ANY);

CREATE QUEUE ReceivingQueue

CREATE QUEUE IncomingMessageQueue


CREATE SERVICE ReceivingMessageService
ON QUEUE ReceivingQueue (IncomingMessageContract);

CREATE SERVICE IncomingMessageService
ON QUEUE IncomingMessageQueue (IncomingMessageContract);

You do not need to do anything to re-enable the broker after a service start up. Once enabled it stays enabled until is explicitly disabled or the database is restored. In fact is very likely the database is already enable when you created it.

As to where are the messages sent while the broker is disabled: look in sys.transmission_queue . Storing sent messages when there is a delivery problem (in this case, broker being disabled) is normal behavior.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM