Skip to content

Instantly share code, notes, and snippets.

@andreasohlund
Created May 7, 2014 10:11
Show Gist options
  • Select an option

  • Save andreasohlund/1dec391188c5d494e05b to your computer and use it in GitHub Desktop.

Select an option

Save andreasohlund/1dec391188c5d494e05b to your computer and use it in GitHub Desktop.
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