3

2つのプロジェクトを異なるプロセスで実行し、RMQを別のマシンにデプロイしています。

これが私の発行元コードです

Bus.Initialize(config =>
            {
                config.UseRabbitMq();
                config.UseRabbitMqRouting();
                config.UseControlBus();
                config.EnableMessageTracing();
                config.EnableRemoteIntrospection();
                config.ReceiveFrom("rabbitmq://debug:debug@data.sampleserver.com:5672/bus/response-queue");
            });

            Console.ReadLine();

            int i = 0;

            while (i < 20)
            {
                i += 1;

                Console.WriteLine("Publishing...");
                Bus.Instance.Publish(new Message
                    {
                        Body = String.Format("Body = {0}", i)
                    });

                Console.ReadLine();
            }

            Console.ReadLine();

これが私の加入者コードです:

Bus.Initialize(config =>
            {
                config.UseRabbitMq();
                config.UseRabbitMqRouting();
                config.ReceiveFrom("rabbitmq://debug:debug@data.sampleserver.com:5672/bus/response-queue");
                config.UseControlBus();
                config.EnableMessageTracing();
                config.UseHealthMonitoring(10);
            });

            var service = HostFactory.New(config =>
            {
                config.SetServiceName("survey");
                config.SetDisplayName("survey");
                config.SetDescription("Survey service");

                config.Service<Service>(s =>
                {
                    s.ConstructUsing(sv => new Service(Bus.Instance));
                    s.WhenStarted(sv => sv.Start());
                    s.WhenStopped(sv => sv.Stop());
                });
            });

            Task.Factory.StartNew(() =>
            {
                try
                {
                    service.Run();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            });

サーバーには、次のサブスクリプションがあります。

public Service(IServiceBus serviceBus)
        {
            _serviceBus = serviceBus;
            _serviceBus.SubscribeHandler<Message>(Handle);
        }

        void Handle(Message message)
        {
            Console.WriteLine("Receive a new message with body {0}", message.Body);
        }

パブリッシャーから一連のメッセージを送信すると、サブスクライバーに正常に到達するメッセージはごくわずかです。それらのほとんどはresponse-queue-errorに分類されます。

私はmasstransitを初めて使用し、その内部で何が起こっているのか理解できず、どうすればそれを理解できるのか理解できません。

この状況でお勧めできることはありますか?

4

1 に答える 1

5

あなたの例のパブリッシャーとサブスクライバーが同じキューでリッスンしていることに気付きました。一般に、すべてのエンドポイントを別々のキューに配置する必要があります。MassTransitは、タイプに基づいてメッセージのルーティングを処理します。

于 2012-07-10T18:22:01.563 に答える