Ejemplo n.º 1
0
        /// <summary>
        /// First argument to the InvokeAsync method must be the MessageContext
        /// being passed along the pipeline.
        /// Othe arguments for this method are where it makes sense to create new objects
        /// per message rather than 1 object created for the constructor injection.
        /// As in constructor dependency inject, dependencies must be wired up with the IoC
        /// container as part of application startup
        /// </summary>
        /// <param name="context">The message context being passed along the pipeline</param>
        /// <param name="invokeDependency">A dependency to instantiate per message rather than per middleware object</param>
        /// <returns></returns>
        public Task InvokeAsync(MessageContext context, IInvokeDependency invokeDependency)
        {
            _logger.LogDebug("InvokeAsync called");

            // You can access the message from RabbitMQ here:
            var messageFromRabbit = context.GetRabbitMqMessage();

            // Add any processing, ETL, transforms, filtering etc.

            // Call some dependencies, maybe?
            _dependency.RunSomeMethod(invokeDependency.GetSomeValue());

            return(_next(context));
        }