为什么我的工作流服务 (4.0) 变量在 DoWhile 活动中变为空?

发布于 2024-09-05 22:48:42 字数 1059 浏览 1 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

牛↙奶布丁 2024-09-12 22:48:42

如果没有看到工作流程,我只能做出一些猜测,但我要寻找的东西是:

  1. 变量的范围是序列还是 DoWhile 活动内部的某些内容?顺便说一句,将其更改为 While 活动没有任何好处,唯一的区别是在开始或结束时测试条件。
  2. 该变量是否在其他地方使用并以这种方式清除。尝试重命名它,看看会产生什么结果。
  3. 是否有游戏中的持续性以及不持续性的类型>我认为它要么是字符串,要么是 Uri,两者都应该可以使用。
  4. 关联是否存在问题?您的取消订阅消息是否正在由不同的工作流程处理?确保 CanCreateInstance 设置为 false。

Without seeing the workflow I can only make a few guesses but the things I would look for are:

  1. Is the variable scoped to a sequence or something that is inside of the DoWhile activity? BTW there is no benefit ti changing it to a While activity, the only difference is that the condition is tested at the beginning or the end.
  2. Is the variable used somewhere else and cleared that way. Try renaming it and see what gives.
  3. Is there persitence in play and is the type not persisted> I assume its either a string or a Uri and both should be good to go.
  4. Is there a problem with correlation and is your Unsubscribe message being processed by a different workflow? Mare sure the CanCreateInstance is set to false.
惜醉颜 2024-09-12 22:48:42

尝试将类设为私有 {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.

木森分化 2024-09-12 22:48:42

哇,好可怕的东西。我之前必须手动编辑 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文