using Connected.Collections.Concurrent; using Connected.Collections.Queues; using Connected.ServiceModel; namespace Common.Collections; internal sealed class MessageJob : DispatcherJob { 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; await client.Initialize(); await client.Invoke(args, args.Arguments); } }