You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Common/Common/Collections/MessageJob.cs

26 lines
686 B

2 years ago
using Connected.Collections.Concurrent;
using Connected.Collections.Queues;
using Connected.ServiceModel;
namespace Common.Collections;
internal sealed class MessageJob : DispatcherJob<IQueueMessage>
{
public MessageJob(IContextProvider provider)
{
Provider = provider;
}
public IContextProvider Provider { get; }
protected override async Task OnInvoke(IQueueMessage args, CancellationToken cancellationToken)
{
//TODO: need to do proper conversions
using var ctx = Provider.Create();
var type = Type.GetType(args.Queue);
var client = ctx.GetService(type) as IQueueClient<QueueArgs>;
await client.Initialize();
await client.Invoke(args, args.Arguments);
}
}