Job
コンシューマーにはメッセージのハンドラーがないようです。
あなたの場合、2つのバスインスタンスが必要になるように思えます. which willの実装を持つコンシューマーインスタンスと、 which IHandleMessages<Job>
willの実装を持つbus.Reply(new ReplyMsg {...})
プロデューサーインスタンスで、応答ハンドラーで実行する必要があることは何でも実行します。IHandleMessages<ReplyMsg>
bus.Send(new Job{...})
要求/応答を示すサンプル コードに興味がある場合は、Rebus サンプル リポジトリにある統合サンプルを参照してください。これには、クライアント間で単純な要求/応答が行われています (これは、クライアントのプロデューサーに対応します)。ケース) および IntegrationService (コンシューマーに対応)。
次のコード スニペットは、その方法を示しています。
var producer = new BuiltinContainerAdapter();
var consumer = new BuiltinContainerAdapter();
consumer.Handle<Job>(job => {
...
consumer.Bus.Reply(new ReplyMsg {...});
});
producer.Handle<ReplyMsg>(reply => {
....
});
Configure.With(producer)
.Transport(t => t.UseSqlServer(connectionString, "producer.input", "error")
.EnsureTableIsCreated())
.MessageOwnership(o => o.FromRebusConfigurationSection())
.CreateBus()
.Start();
Configure.With(consumer)
.Transport(t => t.UseSqlServer(connectionString, "consumer.input", "error")
.EnsureTableIsCreated())
.MessageOwnership(o => o.FromRebusConfigurationSection())
.CreateBus()
.Start();
// for the duration of the lifetime of your application
producer.Bus.Send(new Job {...});
// when your application shuts down:
consumer.Dispose();
producer.Dispose();
Job
app.config には、次の場所にマップするエンドポイント マッピングが必要ですconsumer.input
。
<rebus>
<endpoints>
<add messages="SomeNamespace.Job, SomeAssembly" endpoint="consumer.input"/>
</endpoints>
</rebus>
コードが機能しない理由がわかったと思います。さらに詳しく説明する必要がある場合はお知らせください:)
上記のコードが実際に実行できることを証明するために、リクエスト/リプライのサンプルをRebus サンプル リポジトリに追加しました(....
もちろん、etc を削除した場合 - このコードを使用するには C# の基本的な理解が必要です)。 )