0

我正在从 2.6 升级到 4.0。在 2.6 中,我让我的网站将消息发送到 Publisher 服务。Publisher 服务然后将消息发布给一个或多个订阅者。

但是,在 4.0 中,必须发送 IMessage 并发布一个 IEvent。我无法发送 IEvent。据我所知,这给我留下了两个选择。要么创建两条完全相同的消息,一条实现 IMessage(用于向发布者发送命令),另一条实现 IEvent(用于向订阅者发布),或者发布不可自动发现的 IMessage,并确保所有订阅者明确指定他们想要的消息。

显然,第二种方法是唯一可行的方法(如果可能的话),但我希望还有另一种方法。在那儿?

4

2 回答 2

0

ok, so the issue is that we are not doing things quite as expected yet. I believe the proscribed sequence is

a) web input

b) command to publisher

c) publisher does something like save data

d) publisher publishes some new even "Hey I just saved!"

However what we are doing is a) web input

b) web app saves data

c) web app notifies publisher

d) publisher alerts all subscribers

In our case the command and the event are the exact same message. One is not supposed to publish an event from a web app for several reasons as mentioned HERE. So we are merely passing the message to a service and letting the service publish it.

The answer to my dilemma is to use a IMessage for the message ( this gets it to the publisher fine ) and then in our publishers and subscribers say

.DefiningEventsAs(t => t.Namespace != null && t.Namespace.StartsWith("blahblahblah.Messages.Publishing"));

now the subscribers auto subscribe to my IMessage which of course is in the above namespace.

于 2013-09-27T20:14:58.970 回答
0

(我假设 Web 服务器和您的后端服务(发布者)在同一个域上)

您可能有两条消息,一条来自我们网站上的操作(例如 CreateAccount)的命令必须是 IMessage(顺便说一下,您可以使用不显眼的模式),以及第二条消息(IEvent)类似于 AccountCreated ,它将在 CreatAccount 处理程序完成工作后发布。

如果您想直接从您的网站发布事件,您可以在您的网络服务器上托管一个端点并从那里发布一个 IEvent...

Andreas Öhlund 有一篇关于这个主题的简短博客:http: //andreasohlund.net/2011/12/08/introducing-ievent-and-icommand/

于 2013-09-27T13:06:09.863 回答