【问题标题】:Automatonymous Quick Start does not compile自动快速启动不编译
【发布时间】:2019-05-29 20:47:44
【问题描述】:

请看下面的代码,我摘自最新的快速入门教程:

//the messages
public class BasicRequest :
    CorrelatedBy<Guid>
{
    public Guid CorrelationId { get;set; }
    public string Text { get; set; }
}
public class BasicResponse :
    CorrelatedBy<Guid>
{
    public Guid CorrelationId { get; set; }
    public string Text { get; set; }
}

//the responder
public class Program
{
    public static void Main()
    {
        Bus.Initialize(sbc =>
        {
            sbc.UseMsmq();
            sbc.VerifyMsmqConfiguration();
            sbc.UseMulticastSubscriptionClient();
            sbc.ReceiveFrom("msmq://localhost/message_responder");
            sbc.Subscribe(subs=>
            {
                subs.Handler<RequestMessage>(msg=> Bus.Instance.MessageContext<RequestMessage>().Respond(new BasiceResponse{Text = "RESP"+msg.Text}));
            });
        });
    }
}

//the requester
public class Program
{
    public static void Main()
    {
        Bus.Initialize(sbc =>
        {
            sbc.UseMsmq();
            sbc.VerifyMsmqConfiguration();
            sbc.UseMulticastSubscriptionClient();
            sbc.ReceiveFrom("msmq://localhost/message_requestor");
        });

        Bus.Instance.PublishRequest(new RequestMessage(), x =>
        {
            x.Handle<ResponseMessage>(message => Console.WriteLine(message.Text));
            x.SetTimeout(30.Seconds());
        });
    }
}

我从这里获取代码:https://automatonymous.readthedocs.io/en/latest/overview/request.html

我得到的错误是:

1) 总线不包含初始化定义

2) 找不到RequestMessage

很多其他网页引用了 Bus.Initialise:https://automatonymous.readthedocs.io/en/latest/overview/saga.html

【问题讨论】:

    标签: c# masstransit


    【解决方案1】:

    您似乎发现了超越古代的文献。您正在使用 MSMQ 的事实清楚地表明它是多年不支持的 MassTransit 版本。

    在 MassTransit 中使用状态机的文档: http://masstransit-project.com/MassTransit/advanced/sagas/automatonymous.html

    在 MassTransit 中使用状态机的示例: https://github.com/MassTransit/TheCoffeeShop

    https://github.com/phatboyg/Demo-Registration

    使用最新版本的 MassTransit 会更好。

    【讨论】:

    • 我正在尝试集成这样的分散聚集模式:dotnetcodr.com/2014/05/12/…(但使用公共交通)。 Mass Transit 似乎没有“回复”属性。
    • 因此,我认为可以做到这一点的唯一方法(使用 Mass Transit)是让发送者使用 RPC 单独调用每个接收者,如下所示:github.com/toddmeinershagen/Demo.ScatterGather/blob/master/src/…(见第 33 行,即发送者知道所有的接收器)。问题在于发送者必须知道接收者。我是否正确理解了这一点?谢谢。
    • 您似乎偏离了方向,您可能会在 Gitter.Im 聊天室中获得更好的帮助。但是您可以发布消息并让普通消费者处理对该事件的任何响应,您只需要自己跟踪它们即可。在这种情况下,使用 saga 似乎没有帮助。
    • 如果您可以发布任何文档的链接来解释如何设置消费者来响应特定事件的响应,那么我将不胜感激?我一定会检查 Gitter.Im - 谢谢。
    • 你能看看我的另一个问题吗:stackoverflow.com/questions/56516412/…?我刚刚意识到你是 Gitter 的 Phatboy。
    猜你喜欢
    • 1970-01-01
    • 2012-10-10
    • 1970-01-01
    • 2012-06-10
    • 1970-01-01
    • 2020-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多