Created
November 15, 2016 09:41
-
-
Save SzymonPobiega/530a09e45bcad122b07e7261c89d50ee to your computer and use it in GitHub Desktop.
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
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<configSections> | |
<section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" /> | |
<section name="TransportConfig" type="NServiceBus.Config.TransportConfig, NServiceBus.Core" /> | |
</configSections> | |
<MessageForwardingInCaseOfFaultConfig ErrorQueue="error" /> | |
<TransportConfig MaxRetries="0" MaximumConcurrencyLevel="1" MaximumMessageThroughputPerSecond="0" /> | |
</configuration> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<packages> | |
<package id="NServiceBus" version="5.2.4" targetFramework="net452" /> | |
<package id="NServiceBus.RabbitMQ" version="3.5.0" targetFramework="net452" /> | |
<package id="RabbitMQ.Client" version="4.1.0" targetFramework="net452" /> | |
</packages> |
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 NServiceBus; | |
using NServiceBus.Features; | |
using NServiceBus.Settings; | |
namespace ServiceControlFailureCollapsing | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
using (var p = Bus.Create(CreateConfig("P")).Start()) | |
using (var s1 = Bus.Create(CreateConfig("S1")).Start()) | |
using (var s2 = Bus.Create(CreateConfig("S2")).Start()) | |
{ | |
s1.Subscribe<MyEvent>(); | |
s2.Subscribe<MyEvent>(); | |
p.Publish(new MyEvent()); | |
} | |
Console.ReadLine(); | |
} | |
static BusConfiguration CreateConfig(string endpoint) | |
{ | |
var subConfig1 = new BusConfiguration(); | |
subConfig1.EndpointName(endpoint); | |
subConfig1.UseTransport<RabbitMQTransport>().ConnectionString("host=localhost"); | |
subConfig1.UsePersistence<InMemoryPersistence>(); | |
subConfig1.DisableFeature<AutoSubscribe>(); | |
subConfig1.DisableFeature<SecondLevelRetries>(); | |
return subConfig1; | |
} | |
} | |
class MyEventHandler : IHandleMessages<MyEvent> | |
{ | |
public ReadOnlySettings Settings { get; set; } | |
public void Handle(MyEvent message) | |
{ | |
throw new Exception(Settings.LocalAddress().Queue); | |
} | |
} | |
class MyEvent : IEvent | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment