Created
July 11, 2017 13:17
-
-
Save ramonsmits/2291cb57acb4659d4efcb693e79048fc to your computer and use it in GitHub Desktop.
Log the message ID's from the messages that have been dispatched to the transport
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Threading.Tasks; | |
| using NServiceBus.Logging; | |
| using NServiceBus.Pipeline; | |
| /// <code> | |
| /// endpointConfiguration.Pipeline.Register(behavior: new LogDispatchedMessageIdBehavior(), description: LogDispatchedMessageIdBehavior.Description); | |
| /// </code> | |
| class LogDispatchedMessageIdBehavior : Behavior<IBatchDispatchContext> | |
| { | |
| public const string Description = "Log the message ID of the message that has been dispatched."; | |
| static readonly ILog Log = LogManager.GetLogger(nameof(LogDispatchedMessageIdBehavior)); | |
| public override Task Invoke(IBatchDispatchContext context, Func<Task> next) | |
| { | |
| var messageIds = string.Join(", ", context.Operations.Select(x => x.Message.MessageId)); | |
| Log.InfoFormat("Dispatching messages {0}", messageIds); | |
| return next(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment