1
0
mirror of synced 2024-11-24 19:53:10 +01:00
Tapeti/Tapeti.Transient/TransientGenericBinding.cs
Mark van Renswoude fed377992b [ci skip] Done with XML documentation for now
Made a few classes internal that were supposed to be
2019-08-15 11:26:55 +02:00

58 lines
1.5 KiB
C#

using System;
using System.Threading.Tasks;
using Tapeti.Config;
namespace Tapeti.Transient
{
/// <inheritdoc />
/// <summary>
/// Implements a binding for transient request response messages.
/// Register this binding using the WithTransient config extension method.
/// </summary>
internal class TransientGenericBinding : IBinding
{
private readonly TransientRouter router;
private readonly string dynamicQueuePrefix;
/// <inheritdoc />
public string QueueName { get; private set; }
/// <inheritdoc />
public TransientGenericBinding(TransientRouter router, string dynamicQueuePrefix)
{
this.router = router;
this.dynamicQueuePrefix = dynamicQueuePrefix;
}
/// <inheritdoc />
public async Task Apply(IBindingTarget target)
{
QueueName = await target.BindDynamicDirect(dynamicQueuePrefix);
router.TransientResponseQueueName = QueueName;
}
/// <inheritdoc />
public bool Accept(Type messageClass)
{
return true;
}
/// <inheritdoc />
public Task Invoke(IMessageContext context)
{
router.HandleMessage(context);
return Task.CompletedTask;
}
/// <inheritdoc />
public Task Cleanup(IMessageContext context, ConsumeResult consumeResult)
{
return Task.CompletedTask;
}
}
}