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.Collections.Concurrent; | |
| using System.Diagnostics; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| /// <summary> | |
| /// Used to control the rate of some occurrence per unit of time. | |
| /// </summary> | |
| /// <remarks> |
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
| static class StartableEndpointExtensions | |
| { | |
| public static async Task<IEndpointInstance> StartWithRetry( | |
| this IStartableEndpoint startableEndpoint, | |
| int maxAttempts = 10 | |
| ) | |
| { | |
| var attempts = 0; | |
| while (true) | |
| { |
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; | |
| class ShippingSpeedMetricCollector | |
| : Saga<ShippingSpeedData> | |
| , IAmStartedByMessages<OrderCreated> | |
| , IHandleMessages<OrderCancelled> | |
| , IHandleMessages<OrderShipped> | |
| { |
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
| // Enable debug logging in NServiceBus | |
| LogManager.Use<DefaultFactory>().Level(LogLevel.Debug); | |
| // Create first change logger using type full name, to allow for filtering specific exceptions and/or namespaces when using NLog or log4net | |
| var isDebugEnabled = LogManager.GetLogger("FirstChanceException").IsDebugEnabled | |
| var appDomain = AppDomain.CurrentDomain; | |
| appDomain.UnhandledException += (sender, ea) => LogManager.GetLogger("UnhandledException").Fatal(ea.ExceptionObject.GetType().Name, (Exception)ea.ExceptionObject); | |
| if(isDebugEnabled) appDomain.FirstChanceException += (sender, ea) => LogManager.GetLogger("FirstChanceException." + ea.Exception.GetType().FullName).Debug(ea.Exception.Message, ea.Exception); |
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.Collections.Concurrent; | |
| using System.Collections.Generic; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| using Raven.Client; | |
| /// <summary> | |
| /// This class allows performing high throughput document store operations, using a batching mechanism | |
| /// That mechanism collects up to 128 documents into a single batch and stores them in a single operation, reducing |
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
| if (args.Length == 1 && args[0] == "install") | |
| { | |
| await Console.Out.WriteLineAsync("Running installers...").ConfigureAwait(false); | |
| var endpointConfiguration = CreateConfiguration(); | |
| endpointConfiguration.EnableInstallers(); | |
| await Endpoint.Create(endpointConfiguration).ConfigureAwait(false); | |
| return; // Exit application, we are not going to start the endpoint and process messages | |
| } |
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
| // Via send options. | |
| var sendOptions = new SendOptions(); | |
| sendOptions.SetHeader("StackTrace", System.Environment.StackTrace); | |
| await context.Send(myMessage, sendOptions).ConfigureAwait(false); | |
| // Via outgoing message mutator, requires registering the mutator via the endpoint configuration. | |
| class AddStackTraceMutator : IMutateOutgoingTransportMessages | |
| { | |
| public Task MutateOutgoing(MutateOutgoingTransportMessageContext context) |
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.Collections.Generic; | |
| using System.Configuration; | |
| using System.Data.Common; | |
| using System.Data.SqlClient; | |
| namespace NServiceBus | |
| { | |
| using Transport.SQLServer; |
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
| Get-MsmqQueue | select QueueName, MessagesInQueue, BytesInQueue, JournalMessageCount | |
| Get-MsmqOutgoingQueue | select DestinationQueueFormatName, MessageCount, State, EodNoAckCount, EodNoReadCount |
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
| class AddStackTraceMutator : IMutateOutgoingTransportMessages | |
| { | |
| public Task MutateOutgoing(MutateOutgoingTransportMessageContext context) | |
| { | |
| context.OutgoingHeaders["StackTrace"] = System.Environment.StackTrace; | |
| return Task.CompletedTask; | |
| } | |
| } | |
| endpointConfiguration.RegisterMessageMutator(new AddStackTraceMutator ()); |