は2つの以上のステートフルなサービス間のキューを共有することが可能であり、あるいは私が直接自身の内部キューにメッセージを置くために、TCP/HTTPを経由して、それを呼び出すために必要なのですか?共有キュー
たとえば、私は条件に基づいてキューに順序を置く私の最初のサービスを持っていると言う:
public sealed class Service1 : StatefulService
{
public Service1(StatefulServiceContext context, IReliableStateManagerReplica reliableStateManagerReplica)
: base(context, reliableStateManagerReplica)
{ }
protected override async Task RunAsync(CancellationToken cancellationToken)
{
var customerQueue = await this.StateManager.GetOrAddAsync<IReliableQueue<Order>>("orders");
while (true)
{
cancellationToken.ThrowIfCancellationRequested();
using (var tx = this.StateManager.CreateTransaction())
{
if (true /* some logic here */)
{
await customerQueue.EnqueueAsync(tx, new Order());
}
await tx.CommitAsync();
}
}
}
}
は、その後、私の第2のサービスは、そのキューから読み取って処理を継続します。
public sealed class Service2 : StatefulService
{
public Service2(StatefulServiceContext context, IReliableStateManagerReplica reliableStateManagerReplica)
: base(context, reliableStateManagerReplica)
{ }
protected override async Task RunAsync(CancellationToken cancellationToken)
{
var customerQueue = await this.StateManager.GetOrAddAsync<IReliableQueue<Order>>("orders");
while (true)
{
cancellationToken.ThrowIfCancellationRequested();
using (var tx = this.StateManager.CreateTransaction())
{
var value = await customerQueue.TryDequeueAsync(tx);
if (value.HasValue)
{
// Continue processing the order.
}
await tx.CommitAsync();
}
}
}
}
私はずっとこの上の文書の中に、私はGetOrAddAsync
方法は、URIに取ることができますが、私はこれがどのように動作するかのか、あなたも、クロスのサービスを行うことができれば何も例を見ないてきたことがわかります見ることができませんか?
この背後にある考え方は、我々は再試行メッセージしようとしたとき、我々は矛盾した状態にならないように、別々のキューへの処理を分割することです。
ええ、それはコマンドベースのアプローチに比べてパブ/サブウェイのようなものです。明確化のためにありがとう。 –