我基于此链接通过两个SQL Server实例创建服务代理 enter link description here
一切正常,所以我的消息由serverA发送,如您所见:
case class Test(action: String, storeResult: Option[Boolean] = Some(true), returndata: Option[Boolean] = Some(true))
implicit val testReads: Reads[Test] =
(
(JsPath \\ "action").read[String](minLength[String](1)) and
((JsPath \\ "store_result").read[Boolean] or Reads.pure(true)).map(x=>Some(x)) and
((JsPath \\ "returndata").read[Boolean] or Reads.pure(true)).map(x=>Some(x))
) (Test.apply _)
在服务器B中,我使用以下代码接收消息:
Declare @ConversationHandle uniqueidentifier
Begin Transaction
Begin Dialog @ConversationHandle
From Service SenderService
To Service 'ReceiverService'
On Contract SampleContract
WITH Encryption=off;
SEND
ON CONVERSATION @ConversationHandle
Message Type SenderMessageType
('<test>test</test>')
Commit
此代码接收消息,但是为了使用此代码处理消息,我必须每次(手动)运行上面的代码。我想让它自动化,我的意思是如果收到消息,上面的查询会自动执行。
我是否应该在1 = 1条件下创建存储过程来处理它?</ p>