Yellow.4 marjan nikolovski hunting rabbits and event-driven programming

Preview:

DESCRIPTION

Solving problems with event-driven architecture, pub-sub concepts, cross-boundaries event-driven communication and building event-driven applications with RabbitMQ in .NET Covered technologies: .NET 4.0, RabbitMQ

Citation preview

Hunting rabbits and event-driven programming

Marjan Nikolovski

{Agenda‹ Basics and introduction to EDA‹ Messaging patterns‹ Internal and cross boundaries messaging‹ Products and technologies‹ Demo

Basics and introduction to EDA‹ So what is an event ?

‹ Event-driven behavior as part of our life‹ What is EDA ?

‹ Event-driven behavior as part of out apps‹ Current apps situation‹ To event-driven behavior situation

‹ How can we establish event-driven architecture ?‹ Layering introduced in event-driven apps

‹ Why we want to build event-driven apps?

{

So what is an event ?{‹ An event is an occurrence within a particular system or domain; it is

something that has happened, or is contemplated as having happened in that domain.

‹ Characteristics‹ Unique ‹ Time relevant

Event-driven behavior as part of our life{

On new salary

received

Go shopping

On account empty

Wait for next

salary

What is EDA ?{‹ WIKI says: Event-driven architecture (EDA) is a software architecture

pattern promoting the production, detection, consumption of, and reaction to events.

Event producer

Event processor

Event consumer

Event-driven behavior as part of out apps{

Event-driven apps

Observation

Predictive processing

Information dissemination

Dynamic operational behavior

Active diagnostics

Current apps situationRequest – response scenario{

Current apps situationRequest – response scenario{

Current apps situationPull (time based)scenario{

To event-driven behavior situationEvent scenario{

Don’t call us, we will call you

To event-driven behavior situationEvent scenario{

To event-driven behavior situationEvent scenario{

To event-driven behavior situationEvent scenario{

How can we establish event-driven architecture ?{‹ Good analyses

‹ Stick to Open/Closed and Single responsibility principles‹ Define the domain

‹ Define:‹ Who are event producers‹ Who are event consumers

‹ Introduce event dispatcher (the mediator)‹ Determine event channel‹ Everyone do what they are supposed to do, everything else they

delegate to other involved parties via the event dispatcher

Layering introduced in event-driven apps{‹ Event publisher

‹ Any client that generates events‹ Event mediation and Event channels

‹ Event distribution‹ Events transport via memory, raw, xml, rest, protobuff …

‹ Event subscriber‹ Any client that consumes the events

‹ Choose event processing strategy‹ Simple processing (forwarding)‹ Event streaming (creating events from streamed data and send it to subscribers)‹ Complex event processing (pattern detection on events)

Layering introduced in event-driven apps{

Prod

ucer

s

Med

iatio

n an

d ch

anne

ls

Cons

umer

s

Why we want to build event-driven apps?{‹ Pros

‹ Exploit parallelism‹ Better system design - each event has its own processor (single responsibility)‹ Reduce dependencies in the system‹ Reduce coupling‹ Easier testing‹ Real time monitoring‹ Scalability‹ Maintainability

‹ Cons‹ Highly abstract concept

Messaging patterns{‹ Publish-subscribe aka PubSub‹ Topic based PubSub‹ Point-to-point‹ Request-reply‹ Store and forward‹ Pipeline

Publish-subscribe aka PubSub{Publisher

Topic

Subscriber Subscriber

Consumes the event Consumes the event

Publish an event

Topic based PubSub{

Publisher

Topic

Subscriber Subscriber

Consumes the event Consumes the event

Publish an event

SubtopicSubscriber

Consumes the event

Point-to-point{

Publisher SubscriberQueue

Request-reply{

Publisher/Subscriber SubscriberTopic

Subscriber

Subscriber

Store and forward{

Publisher/Subscriber SubscriberTopic

Subscriber

Subscriber

Data

Pipeline{

Publisher SubscriberTopic Subscriber Subscriber

Internal and cross boundaries messaging{‹ Internal messaging via in memory event dispatcher

‹ Decorate the subscribers in the system‹ Decorate the receivers in the system‹ Develop custom event dispatcher that will dispatch the producer events to the

consumer‹ Cross boundaries messaging via

‹ Any full-duplex communication‹ Web/Url callbacks‹ Web based push notifications - long pooling AJAX request‹ Queue‹ Custom messaging software

Products and technologies{‹ XMPP based products

‹ Ejabberd‹ AMQP based products

‹ RabbitMQ‹ OpenAMQP‹ Apache QPID

‹ STOMP based products‹ ActiveMQ

‹ JMS‹ Other

‹ MSMQ‹ Azure Service Bus‹ ZeroMQ

AMQP protocol{‹ Advanced message queuing protocol for message-oriented middleware

‹ Queuing‹ Routing (point to point, PubSub)‹ Reliable‹ Secure

‹ Interoperability on protocol level instead of API level‹ So how does it work behind the scenes:

‹ Exchanges‹ Queues‹ Bindings‹ Messages

{

Publisher

Publisher

Publisher

Consumer

Consumer

Exchange

Exchange

Queue

QueueBinding

Binding

RabbitMQ Broker

Message exchange{

Bindings

Exchange

Queues

Topic Fanout Direct

Q1 Q2 Q3 Q4 Q5 Q6

System.Logs.* System.Interupts.* SomeKey

{

Questions? Complete electronic evaluation forms

on the computers in the hall and enter to win!– Telerik Ultimate Collection– RedGate .NET Reflector VSPro– ComponentOne Enterprise Studio Suite– Pluralsight yearly subscriptions– CodeSmith Tools Generator Pro Personal– JetBrains ReSharper– Semos Education Training Voucher– and many more…