Пример #1
0
        public async Task RouteMessageAsync(Message msg)
        {
            //TODO: Fix Message Key to something more elegant
            var versionedMessageType = new VersionedMessageType {
                MessageType = msg.MessageType, Version = msg.Version
            };

            if (_routingDictionary.TryGetValue(versionedMessageType.Key, out var pipelines))
            {
                //TODO: Run loop in parallel
                foreach (var pipeline in pipelines)
                {
                    await pipeline.ProcessMessageAsync(msg);
                }
            }
            else if (_unhandledEventPipeline != null)
            {
                //default pipeline
                await _unhandledEventPipeline?.ProcessMessageAsync(msg);
            }
        }
Пример #2
0
        public async Task RouteMessageAsync(Message msg)
        {
            //TODO: Fix Message Key to something more elegant
            var versionedMessageType = new VersionedMessageType {
                MessageType = msg.MessageType, Version = msg.Version
            };

            if (_routingDictionary.TryGetValue(versionedMessageType.Key, out var pipelines))
            {
                //TODO: Run loop in parallel
                foreach (var pipeline in pipelines)
                {
                    await pipeline.ProcessMessageAsync(msg);
                }
            }
            else
            {
                Console.WriteLine($"No pipeline found for message type: {msg.MessageType}, version: {msg.Version}");
                //TODO Implement unhandled pipeline here
                //await _unhandledEventPipeline?.ProcessMessageAsync(msg);
            }
        }