自动命名快速入门无法编译

时间:2019-05-29 08:54:54

标签: c# masstransit

请参阅下面的代码,该代码是我从最新的快速入门教程中摘录的:

//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

1 个答案:

答案 0 :(得分:0)

您似乎已经找到了远古的文档。您正在使用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会更好。