Skip to content

Instantly share code, notes, and snippets.

View mookid8000's full-sized avatar
💭
Pressing buttons.

Mogens Heller Grabe mookid8000

💭
Pressing buttons.
View GitHub Profile
@mookid8000
mookid8000 / gist:fec9386fddb609b2ab31
Created September 18, 2014 09:39
Rebus sends to nonexistent queue
try
{
var startableBus = Configure.With(new BuiltinContainerAdapter())
.Logging(l => l.None())
.Transport(t => t.UseMsmqInOneWayClientMode())
.CreateBus();
using (var bus = startableBus.Start())
{
bus.Advanced.Routing.Send("NO_CHANCE_THAT_THIS_QUEUE_EXISTS", "hello there!");
using System;
using System.Threading;
using System.Threading.Tasks;
using Rebus.Logging;
namespace Rebus.Threading
{
/// <summary>
/// <see cref="Task"/>-based background timer thingie, that will periodically call an async <see cref="Func&lt;Task&gt;"/>
/// </summary>
}
}
}
}
break;
}
}
}
}
Dictionary<string, bool> usedGuids = new Dictionary<string, bool>();
private string CreateUniqueGuid()
{
string newGuid = Guid.NewGuid().ToString();
if (usedGuids.ContainsKey(newGuid))
{
throw new Exception();
}
@mookid8000
mookid8000 / gist:905204
Created April 6, 2011 05:48
Subscribe to types discovered via reflection
foreach(var derivedMessageType in GetAllMessageTypes().Where(t => typeof(IBaseMessage).IsAssignableFrom(t))
{
bus.GetType().GetMethod("Subscribe").MakeGenericMethod(derivedMessageType).Invoke(bus, new object[0]);
}
@mookid8000
mookid8000 / gist:905531
Created April 6, 2011 12:00
NServiceBus app.config example
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="MsmqTransportConfig" type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
</configSections>
<MsmqTransportConfig InputQueue="someClient"
ErrorQueue="error"
NumberOfWorkerThreads="1"
@mookid8000
mookid8000 / gist:905536
Created April 6, 2011 12:03
NServiceBus bus config sample
var bus = Configure.With()
.DefaultBuilder()
.XmlSerializer()
.MsmqTransport().IsTransactional(false)
.UnicastBus().LoadMessageHandlers()
.CreateBus()
.Start();
@mookid8000
mookid8000 / gist:905624
Created April 6, 2011 13:21
NServiceBus endpoint config example publisher
public class EndpointConfiguration : IConfigureThisEndpoint,
IWantCustomLogging,
IWantCustomInitialization
{
public void Init()
{
Configure.With()
.DefaultBuilder()
.XmlSerializer()
.MsmqTransport()
@mookid8000
mookid8000 / gist:951560
Created May 2, 2011 12:52
NServiceBus still doesn't seem to release tracked components
public class EndpointConfiguration : IConfigureThisEndpoint,
AsA_Server,
IWantCustomInitialization,
IWantToRunAtStartup
{
readonly IWindsorContainer container;
public EndpointConfiguration()
{
container = new WindsorContainerDecorator()
@mookid8000
mookid8000 / gist:1137706
Created August 10, 2011 18:28
being explicit about message types
public interface ICommand : IMessage {}
public interface IEvent : IMessage {}
public interface IRequest : IMessage {}
public interface IReply : IMessage {}