NServiceBus – Getting Started Sean Feldman Highco Consulting Ltd / Particular Software
Messages – Commands and Events Known destination (unicast) Instructs recipient to perform an action Indicates sender knowledge of recipient Event Unknown destinations (multicast) Immutable representation of something that occurred in the past Command and Events are messages with Semantic Meaning. NServiceBus enforces the semantic of command and events.
Messaging Patterns
Request / Response A message is sent to a specific destination The sender perfectly knows the receiver Knows where the receiver is Knows what to send The receiver of the message can reply back The receiver Does not necessarily know directly where the request is coming from Knows what the sender expects: what to reply There is coupling between the sender and the receiver
Publish / Subscribe An actor in the system acted on something The actor can broadcast an event to the entire system The publisher is not interested in who is subscribed for the event Another actor in the system can be interested in an event The actor will subscribe to the event(s) interested in Subscription is responsibility of the interested side to receive events The subscriber knows the publisher, not the opposite A copy of an event is delivered to each subscriber* There is less coupling between the publisher and the subscriber * Persistence based vs broker based pub/sub
Message Handlers
Message Handlers A handler is the “container” (class) that hosts our code Each time a message is received a handler is invoked A handler is stateless: Each time a message is received a new handler is created and invoked* A handler either succeeds or fails and that affects what will happen to the processed message * Stateful scenarios with Sagas – topic for a whole another meetup
Endpoints & Hosting
Endpoints & Hosting Handlers are grouped by service (a logical concept) Services are hosted in Endpoints Endpoint instances run on Windows machines Windows Services Self hosted Leverage the NServiceBus.Host (Self) hosted in any application type: web, console, WPF, etc.
Transports
Transports Oracle MSMQ AmazonSQS RabbitMQ SQL Server Azure Storage Queues Azure Service Bus http://docs.particular.net/platform/extensions#transports
Persistence
Persistence MongoDB NHibernate PostgreSQL RavenDB DocumentDB Azure Storage http://docs.particular.net/platform/extensions#transports
A Story of a Lost Notification Book I
Demo / Temporal Coupling Register a new user. When registration is done, send a welcome notification.
Demo / Pub-Sub Marketing is interested in newly created users
Show me the code
Thank you Learn to design better systems Get access to 2 full days of Udi Dahan's Advanced Distributed Systems Design video course. Sign up here: http://go.particular.net/.NETCalgary Access code: Calga Expiration date: Nov 3rd