• Each service has its own input queue. • When a service needs to send a message, the bus looks up the desKnaKon somehow. • How desKnaKons are looked up depends on whether the service is sending or publishing.
How to do these things IRL • Commercial – NServiceBus • Free alternaKves – MassTransit – RhinoESB – Rebus(*)
NServiceBus • Currently in version 3.0 • Licensing – <= 2.0 are free – >= 2.5 cost money
Show me the code • Now let’s see how “Request/reply” looks with NServiceBus – We have a pre8y unreliable web service, umm “Whatchamacallit”, that we want to call. – We build an integraKon service with NServiceBus that works as a messaging façade towards the web service. – Our system requests stuﬀ from the façade, the façade replies.
Show me the code • Now, let’s see an example with some Pub/sub acKon – We have a service that processes something, “Somekindofprocessor”, when it receives a ProcessSomething command. – In order to process stuﬀ, it needs to get the important string from our unreliable web service from before. – When processing is done, it should publish the result, allowing any other interested services to react to this.
The real world is a place... • ...where we can’t always process messages in a stateless manner like this... • ...where mulKple things need coordinaKon and will not always succeed/fail as a whole...
Enter the saga! • A model for long-‐lived transacKons. • “A long-‐lived transacKon is a saga if it can be wri8en as a sequence of transacKons that can be interleaved with other transacKons.” • For some reason, Mike Amundsen keeps a copy of the original whitepaper PDF here: h8p://www.amundsen.com/downloads/sagas.pdf
Sagas • Implemented with an implementaKon of ISagaEntity, TEntity and deriving a message handler from Saga<TEntity>. • All handled messages should somehow be correlated with the sata data.
Sagas • Use them to – implement short conversaKons – implement long conversaKons – handle Kmeouts – implement idempotency
Thanks for listening! firstname.lastname@example.org @mookid8000 h8p://mookid.dk/oncode
Image credits “It’s the same mouth, just ﬂipped”: h8p://humor-‐image.com/its-‐the-‐same-‐mouth-‐just-‐ﬂipped/ Thanks for lepng me borrow your awesome images – if you ever meet me, I’ll buy you guys and girls a beer. Seriously, I will.
A particular slide catching your eye?
Clipping is a handy way to collect important slides you want to go back to later.