Recognizing MSSQL Service Broker sender side error messages

落花浮王杯 提交于 2020-01-06 20:07:33

问题


I have SQL Service Broker set up between two servers over network and it is working alright. I'm implementing error processing at the moment. I have stored procedures attached to both queues to process messages.

In the cases when sending a message fails, such as when attempting to send malformed XML, the message stays in the sender queue. The transmission status is

Service Broker received an error message on this conversation. Service Broker will not transmit the message; it will be held until the application ends the conversation.

When querying the queue (stored procedures turned off for debugging) with select * from sys.transmission_queue, the is_conversation_error and is_end_of_dialog fields are 0 and message_type_name is the same I used when sending, instead of the usual error type.

Is there a way to recognize such messages in the queue? My automatic sender queue is processing them as normal messages at the moment.


回答1:


A malformed XML error will send back to your dialog an error message. This will be enqueued in your application queue and your app has to deal with it, as it must deal with any error message in its queue.

Note that you are confusing the sender queue with the transmission_queue. The sender queue is an ordinary queue created with CREATE QUEUE, and is the queue associated with your sending service. The error message I'm talking about is deposited in your sender queue and you can retrieve it with RECEIVE. The transmission_queue is an internal table owned by system that contains messages pending delivery. You cannot RECEIVE from the transmission_queue.

Judging from your post I guess your application is missing handling of messages in the sender queue. Even if your logical message flow is always from service 'A' to service 'B', you must have message handling for 'A' service queue as well. If nothing else, it is necessary for handling errors.



来源:https://stackoverflow.com/questions/38436673/recognizing-mssql-service-broker-sender-side-error-messages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!