在同一个数据库实例上有两个不同的数据库A和B,A通过SSB应用程序向B的一个SSB队列中发送消息,但是发送消息的结果是有时成功,有时候失败。
发送的代码如下:
1 BEGIN TRANSACTION 2 --启动发起方会话 3 DECLARE @ConversationHandle UNIQUEIDENTIFIER; 4 BEGIN DIALOG @ConversationHandle 5 FROM SERVICE MsgDBUserInitiatorService 6 TO SERVICE N'MsgDBUserTargetService' 7 ON CONTRACT MsgContract 8 WITH ENCRYPTION = OFF; 9 10 SEND ON CONVERSATION @ConversationHandle MESSAGE TYPE MsgDBInitiatorType(@MsgContent); 11 END CONVERSATION @ConversationHandle WITH CLEANUP 12 13 --更新机构短信数目 14 UPDATE dbo.ServiceMsgStorage SET UsageCount=UsageCount-@TotalCount,UpdateTime=GETDATE(),UpdateBy=@CreateBy WHERE OrganizationId=@OrgId 15 --写短信量扣除日志 16 DECLARE @XmlDocument int 17 EXEC sp_xml_preparedocument @XmlDocument OUTPUT, @MsgContent 18 INSERT INTO dbo.ServiceMsgStorageLog(OrganizationId,MsgCount,SchoolId,LogType,CreateBy) 19 SELECT *,1 AS LogType,@CreateBy AS CreateBy FROM OPENXML (@XmlDocument, '/Msg/Body/Storage',2) 20 WITH (OrgId INT '@OrgId',Storage INT '@Count',SchoolId INT '@SchoolId') 21 EXEC sp_xml_removedocument @XmlDocument 22 COMMIT TRANSACTION
请园中各位哥帮忙看一下,谢谢