为什么我的工作流服务 (4.0) 变量在 DoWhile 活动中变为空?
我有一个 WF 服务,我正在尝试将接收活动设置为“订阅”和“取消订阅”。我正在使用 此 WF Durable Duplex 教程 作为基础,因为我的服务执行对客户端的回调。基本上,可以将其视为聊天服务。
我可以很好地向两个接收活动发出客户呼叫。发生的情况是客户端的回调地址被传递到服务上的 Subscribe() 。该地址作为变量存储在 WF 服务中,一切看起来都按预期工作。
当客户端调用 Unsubscribe() 时,我在调试期间在地址 var 上设置的手表将其显示为 null
。那么什么给出呢?
这是我的 WF 服务布局的基本设置...
一切都包含在 DoWhile 活动中。其中有一个 Pick 活动和两个 Pick 分支。第一个分支用于订阅活动。它有一个接收-发送回复活动,将客户端传递的字符串分配给 WF 地址变量。第二个分支处理取消订阅。触发器是请求活动,并且再次传入客户端地址。
从那里它进入一个以 If 开头的序列。它检查unsubscribeAddress
是否等于已订阅的address
。如果是,则会将 address
设置为 String.Empty
并向客户端发送一条成功消息。
为什么作用域为封装 DoWhile 活动的变量会隐式分配为 null?我试图让它工作,这样我就可以从那里实现多个客户端订阅者,并处理调用多个客户端回调的触发器。
CONCAT 编辑: 我在 DoWhile 级别设置了一个断点,一旦调用 Unsubscribe()
,我的 var 就为空。当调用 Subscribe()
时,手表会一直显示 var 中的值。直到我与客户Unsubscribe()
。我应该使用 While 活动吗?
I have a WF service that I'm trying to setup receive activities to "Subscribe" and "Unsubscribe". I'm using This WF Durable Duplex Tutorial as a basis because my service performs callbacks to clients. Basically, think of it as a chat service.
I can make client calls to the two receive activities just fine. What happens is the callback address of the client is passed in to Subscribe() on the service. The address is stored as a variable in the WF service and everything looks like it would work as to be expected.
When a client calls Unsubscribe(), my watch I have set on the address var during debugging shows it as null
. So what gives?
Here's the basic setup of my WF service layout...
Everything is enveloped in a DoWhile activity. Inside of that is a Pick activity and two Pick branches. The first branch is for subscribing activities. It has a receive-sendreply activity that assigns the string passed by the client to the WF address var. The second branch handles unsubscribing. The trigger is the Request activity and the client address is again passed in.
From there it goes into a sequence, starting with an If. It checks to see if the unsubscribeAddress
equals the address
already subscribed. If it does, then it sets the address
to String.Empty
and sends a success message back to the client.
Why would a variable that's scoped to the enveloping DoWhile activity be implicitly assigned to null? I'm trying to get this to work so I can implement multiple client subscribers from there and work on triggers that invoke callbacks to multiple clients.
CONCAT EDIT: I set a breakpoint at the DoWhile level and my var is null once Unsubscribe()
is called. When Subscribe()
is invoked, the watch shows a value in the var all the way through. Until I Unsubscribe()
with a client. Should I be using a While Activity instead?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果没有看到工作流程,我只能做出一些猜测,但我要寻找的东西是:
Without seeing the workflow I can only make a few guesses but the things I would look for are:
尝试将类设为私有 {get; set;} 并看看问题是否仍然出现,这是我在不查看实际源代码的情况下所能做的最好的事情,因为从您所描述的情况来看,我看不到任何问题。
try making a class scoped private {get; set;} and see if the problem still rears its head, thats the best I can do without seeing the actual source code as from what you described I cant see any issues.
哇,好可怕的东西。我之前必须手动编辑 xamlx 文件,当我切换回活动设计器时,我为 SendReplyToReceive 编辑的引用保存得很有趣。它看起来就像我有两个 Unsubscribe() ,不仅如此,每个分支的相关句柄也在分支之间交叉。
我现在一切都准备好了。为了解决这个问题,我删除了所有消息传递活动,将新的 ReceiveAndSendReply 活动放入分支 1 的操作块中。然后,我将 Receive 活动拖到分支 1 的触发器中,并按照之前的方式对其进行配置。我对分支 2 执行了相同的操作,只不过我将 SendReplyToReceive 活动放置在验证匹配地址的 If 活动下方。
Wow, ok scary stuff. I had to hand edit the xamlx file earlier and the references I edited for the SendReplyToReceive saved funny when I switched back to the activity designer. It made it look like I had two
Unsubscribe()
's and not only that but the correlation handles for each branch were crossing between branches.I'm all set now. To fix the issue I removed all the messaging activities, dropped in a new
ReceiveAndSendReply
activity into branch 1's action block. Then I dragged the Receive activity to the Trigger for branch 1 and configured it as I had before. I did the same for branch 2, except I placed the SendReplyToReceive activity below my If activity that validates matching addresses.