Created
May 7, 2014 10:11
-
-
Save andreasohlund/1dec391188c5d494e05b 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
| using System; | |
| using NServiceBus.Pipeline; | |
| using NServiceBus.Pipeline.Contexts; | |
| namespace TTBRDemo | |
| { | |
| using NServiceBus; | |
| class EndpointConfig : IConfigureThisEndpoint, AsA_Server | |
| { | |
| } | |
| class MyTTBRStrategy:IBehavior<SendLogicalMessageContext> | |
| { | |
| public void Invoke(SendLogicalMessageContext context, Action next) | |
| { | |
| if (context.MessageToSend.MessageType == typeof (MyMessage)) | |
| { | |
| context.MessageToSend.Metadata.TimeToBeReceived = TimeSpan.FromSeconds(10); | |
| } | |
| next(); | |
| } | |
| } | |
| class MyTTBRStrategyConfig:PipelineOverride | |
| { | |
| public override void Override(BehaviorList<SendLogicalMessageContext> behaviorList) | |
| { | |
| behaviorList.Add<MyTTBRStrategy>(); | |
| } | |
| } | |
| class MyMessageHandler:IHandleMessages<MyMessage> | |
| { | |
| public void Handle(MyMessage message) | |
| { | |
| Console.Out.WriteLine("Got it"); | |
| } | |
| } | |
| class Sender:IWantToRunWhenBusStartsAndStops | |
| { | |
| public IBus Bus { get; set; } | |
| public void Start() | |
| { | |
| Bus.SendLocal(new MyMessage()); | |
| } | |
| public void Stop() | |
| { | |
| } | |
| } | |
| class MyMessage:IMessage | |
| { | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment