public StaticHeaders() { #region header-static-endpoint EndpointConfiguration configuration = new EndpointConfiguration(); configuration.AddHeaderToAllOutgoingMessages("MyGlobalHeader", "some static value"); #endregion }
static async Task Main() { Console.Title = "Samples.Headers"; var endpointConfiguration = new EndpointConfiguration("Samples.Headers"); endpointConfiguration.UseTransport <LearningTransport>(); endpointConfiguration.RegisterMessageMutator(new MutateIncomingMessages()); endpointConfiguration.RegisterMessageMutator(new MutateIncomingTransportMessages()); endpointConfiguration.RegisterMessageMutator(new MutateOutgoingMessages()); endpointConfiguration.RegisterMessageMutator(new MutateOutgoingTransportMessages()); #region global-all-outgoing endpointConfiguration.AddHeaderToAllOutgoingMessages("AllOutgoing", "ValueAllOutgoing"); #endregion var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); #region sending var myMessage = new MyMessage(); await endpointInstance.SendLocal(myMessage) .ConfigureAwait(false); #endregion Console.WriteLine("Press any key to exit"); Console.ReadKey(); await endpointInstance.Stop() .ConfigureAwait(false); }
void StaticHeaders(EndpointConfiguration endpointConfiguration) { #region 5to6header-static-endpoint endpointConfiguration.AddHeaderToAllOutgoingMessages("MyGlobalHeader", "some static value"); #endregion }
static async Task AsyncRun() { Console.Title = "Samples.Headers"; var endpointConfiguration = new EndpointConfiguration("Samples.Headers"); endpointConfiguration.UseSerialization <JsonSerializer>(); endpointConfiguration.EnableInstallers(); endpointConfiguration.UsePersistence <InMemoryPersistence>(); endpointConfiguration.SendFailedMessagesTo("error"); endpointConfiguration.RegisterComponents(components => { components.ConfigureComponent <MutateIncomingMessages>(DependencyLifecycle.InstancePerCall); components.ConfigureComponent <MutateIncomingTransportMessages>(DependencyLifecycle.InstancePerCall); components.ConfigureComponent <MutateOutgoingMessages>(DependencyLifecycle.InstancePerCall); components.ConfigureComponent <MutateOutgoingTransportMessages>(DependencyLifecycle.InstancePerCall); }); #region global-all-outgoing endpointConfiguration.AddHeaderToAllOutgoingMessages("AllOutgoing", "ValueAllOutgoing"); #endregion var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); try { #region sending var myMessage = new MyMessage(); await endpointInstance.SendLocal(myMessage) .ConfigureAwait(false); #endregion Console.WriteLine("Press any key to exit"); Console.ReadKey(); } finally { await endpointInstance.Stop() .ConfigureAwait(false); } }
private static async Task AsyncMain() { const string endpointName = "PocService"; Console.Title = endpointName; var endpointConfiguration = new EndpointConfiguration(endpointName); endpointConfiguration.UseTransport <MsmqTransport>(); endpointConfiguration.UseSerialization <JsonSerializer>(); endpointConfiguration.UsePersistence <InMemoryPersistence>(); endpointConfiguration.SendFailedMessagesTo("error"); endpointConfiguration.EnableInstallers(); endpointConfiguration.AddHeaderToAllOutgoingMessages(PocHeaders.TenantId, "1"); EndpointInstance = await Endpoint.Start(endpointConfiguration).ConfigureAwait(false); await RunLoop().ConfigureAwait(false); await EndpointInstance.Stop().ConfigureAwait(false); }
static async Task AsyncRun() { Console.Title = "Samples.Headers"; var endpointConfiguration = new EndpointConfiguration("Samples.Headers"); endpointConfiguration.UseSerialization<JsonSerializer>(); endpointConfiguration.EnableInstallers(); endpointConfiguration.UsePersistence<InMemoryPersistence>(); endpointConfiguration.SendFailedMessagesTo("error"); endpointConfiguration.RegisterComponents(components => { components.ConfigureComponent<MutateIncomingMessages>(DependencyLifecycle.InstancePerCall); components.ConfigureComponent<MutateIncomingTransportMessages>(DependencyLifecycle.InstancePerCall); components.ConfigureComponent<MutateOutgoingMessages>(DependencyLifecycle.InstancePerCall); components.ConfigureComponent<MutateOutgoingTransportMessages>(DependencyLifecycle.InstancePerCall); }); #region global-all-outgoing endpointConfiguration.AddHeaderToAllOutgoingMessages("AllOutgoing", "ValueAllOutgoing"); #endregion var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); try { #region sending var myMessage = new MyMessage(); await endpointInstance.SendLocal(myMessage) .ConfigureAwait(false); #endregion Console.WriteLine("Press any key to exit"); Console.ReadKey(); } finally { await endpointInstance.Stop() .ConfigureAwait(false); } }
static async Task Main() { //required to prevent possible occurrence of .NET Core issue https://github.com/dotnet/coreclr/issues/12668 Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Console.Title = "Samples.Headers"; var endpointConfiguration = new EndpointConfiguration("Samples.Headers"); endpointConfiguration.UsePersistence <LearningPersistence>(); endpointConfiguration.UseTransport <LearningTransport>(); endpointConfiguration.RegisterComponents(components => { components.ConfigureComponent <MutateIncomingMessages>(DependencyLifecycle.InstancePerCall); components.ConfigureComponent <MutateIncomingTransportMessages>(DependencyLifecycle.InstancePerCall); components.ConfigureComponent <MutateOutgoingMessages>(DependencyLifecycle.InstancePerCall); components.ConfigureComponent <MutateOutgoingTransportMessages>(DependencyLifecycle.InstancePerCall); }); #region global-all-outgoing endpointConfiguration.AddHeaderToAllOutgoingMessages("AllOutgoing", "ValueAllOutgoing"); #endregion var endpointInstance = await Endpoint.Start(endpointConfiguration) .ConfigureAwait(false); #region sending var myMessage = new MyMessage(); await endpointInstance.SendLocal(myMessage) .ConfigureAwait(false); #endregion Console.WriteLine("Press any key to exit"); Console.ReadKey(); await endpointInstance.Stop() .ConfigureAwait(false); }