Skip to content

Instantly share code, notes, and snippets.

View andreasohlund's full-sized avatar

Andreas Öhlund andreasohlund

View GitHub Profile
namespace NServiceBus.Persistence.Raven.Tests
{
using System;
using System.IO;
using System.Messaging;
using System.Threading;
using System.Transactions;
using NUnit.Framework;
using global::Raven.Client;
using global::Raven.Client.Document;
[Fact]
public void NSBTest()
{
this.kernel.Bind<Foo>().ToSelf().InTransientScope();
this.kernel.Bind<Foo>().ToSelf().WhenAnyAnchestorNamed("Container").InNamedScope("Container");
this.kernel.Bind<ChildContainer>().ToSelf().Named("Container").DefinesNamedScope("Container");
var instance1 = this.kernel.Get<Foo>();
instance1.Should().NotBeNull();
@andreasohlund
andreasohlund / Log4net.xml
Created February 20, 2012 08:46
nservicebus.course.lognet
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
<section name="MessageForwardingInCaseOfFaultConfig" type="NServiceBus.Config.MessageForwardingInCaseOfFaultConfig, NServiceBus.Core" />
</configSections>
<log4net debug="false">
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="myLog.txt"/>
@andreasohlund
andreasohlund / RunCustomInstall.cs
Created January 26, 2012 09:07
Blog.CustomHosting.RunInstallers
Configure.Instance
.ForInstallationOn<NServiceBus.Installation.Environments.Windows>()
.Install()
Configure.With()
.DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith("Commands"))
.DefiningEventsAs(t => t.Namespace != null && t.Namespace.EndsWith("Events"))
.DefiningMessagesAs(t => t.Namespace != null && t.Namespace.EndsWith("Messages"))
.DefiningEncryptedPropertiesAs(p => p.Name.StartsWith("Encrypted"));
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core"/>
</configSections>
<UnicastBusConfig>
<MessageEndpointMappings>
<add Messages="Messages.Request, Messages" Endpoint="server" />
</MessageEndpointMappings>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<log4net debug="false">
<appender name="console" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] &lt;%X{auth}&gt; - %m%n"/>
var bus = Configure.With()
.DefaultBuilder()
.XmlSerializer()
.MsmqTransport()
.UnicastBus()
.SendOnly();
bus.Send(new TestMessage());
@andreasohlund
andreasohlund / gist:1415466
Created December 1, 2011 09:56
SendToSites
/// <summary>
/// Sends the messages to all sites with matching
/// site keys registered with the gateway.
/// The gateway is assumed to be located at the master node.
/// </summary>
/// <param name="siteKeys"></param>
/// <param name="messages"></param>
/// <returns></returns>
ICallback SendToSites(IEnumerable<string> siteKeys,
params object[] messages);
@andreasohlund
andreasohlund / gist:1385596
Created November 22, 2011 12:51
UoW.Handler
public class PlaceOrderHandler : IHandleMessages<PlaceOrder>
{
readonly IDocumentSession session;
public PlaceOrderHandler(IDocumentSession session)
{
this.session = session;
}
public void Handle(PlaceOrder message)