My favorites | Sign in
Project Logo
                
Search
for
Updated Oct 25, 2008 by dru.sellers
SampleCode  

Requirements

Assemblies Needed To Get Started

MassTransit.ServiceBus.dll
MassTransit.ServiceBus.MSMQ.dll

An IoC Container is required

We currently have support for Castle, and StructureMap with Ninject on the way.

We are going to use Castle's Windsor

MassTransit.WindsorIntegration.dll
Castle.Core.dll
Castle.MicroKernel.dll
Castle.Windsor.dll
Castle.DynamicProxy2.dll

Read up on configuring Castle

whew! Once all of this is set up you can use typical IoC programming patterns to get access to the ServiceBus instance, or you can pull it out of the container like so.

IServiceBus bus = container.Resolve<IServiceBus>();

How to subscribe to a message

MT has 2 different ways to subscribe to messages in 0.2

bus.Subscribe(Of T)(component as T)
bus.AddComponent(Of T)

We will get into what we mean by component in just a bit

TBD: What is a component

How to publish a message

IServiceBus bus = container.Resolve<IServiceBus>();
bus.Publish(new MyMessage);

How to build a message

[Serializable]
public class YourMessage
{
    //put your stuff here
    //this message should be an *immutable*
    //value object so use readonly fields
    //and readonly properties - 1
}

1. Greg Young on Messages are Value Objects


Sign in to add a comment
Hosted by Google Code