Ejemplo n.º 1
0
        public MessageProcessorHandle Process(IRequestMessage requestMessage)
        {
            var handle = new MessageProcessorHandle(requestMessage);

            queue.Post(handle);
            return(handle);
        }
Ejemplo n.º 2
0
        private async Task OnProcess(MessageProcessorHandle handle)
        {
            try {
                var messageType = handle.RequestMessage.GetType();
                if (!registry.TryGet(messageType, out var processFunc))
                {
                    throw new ApplicationException($"No Message Processor was found matching message type '{messageType.Name}'!");
                }

                var result = await processFunc(transceiver, handle.RequestMessage);

                handle.SetResult(result);
            }
            catch (Exception error) {
                handle.SetException(error);
            }
        }