Example #1
0
        /// <summary>
        /// process event as an asynchronous operation.
        /// </summary>
        /// <param name="channel">The channel.</param>
        /// <param name="ea">The <see cref="BasicDeliverEventArgs"/> instance containing the event data.</param>
        /// <returns>Task.</returns>
        /// <remarks>
        /// <para>作者    :jason</para>
        /// <para>创建时间:2018-12-19</para>
        /// <para>最后更新:jason</para>
        /// <para>更新时间:2018-12-19</para>
        /// </remarks>
        private async Task ProcessEventAsync(IModel channel, BasicDeliverEventArgs ea)
        {
            var eventName = ea.RoutingKey;
            var eventType = EventTypes.GetValueOrDefault(eventName);

            if (eventType == null)
            {
                return;
            }

            var eventData = Serializer.Deserialize(ea.Body, eventType);

            await TriggerHandlersAsync(eventType, eventData);

            channel.BasicAck(ea.DeliveryTag, multiple: false);
        }