SlideShare una empresa de Scribd logo
1 de 21
Book Author: Nicolai M. Josuttis
                 Chapter Ten: Message Exchange Patterns




IT-Slideshares                       http://it-slideshares.blogspot.com/
10.1 Introduction to MEPs
 There are different ways to exchange data between distributed systems.
 One fundamental approach to dealing with these differences is to
  categorize the way chunks of data are exchange.
    These chunks of data are called messages.
 By categorizing different ways of exchanging messages , we get the so-
  called message exchange patterns.
    MEPs define the sequence of messages in a service call or service operation,
     specifying the order, direction and cardinality of those messages.
    Note :
         MEPs are general concepts to describe communications between different systems (or
          nodes).
10.2 Basic MEPs
 There are different approaches to categorizing MEPs.
 This section start with two basic patterns and explain some others
  based on these patterns.
10.2.1 Request / Response




   Probably the most importance pattern for SOA is request/response.
   In this pattern, the consumer send a request message to the service provider and waits for the provider to send
    a response message (See Figure 10.1)
   From the consumer’s point of view , such a service call is like a remote procedure call (RPC) .
        The consumer is blocked until the response arrives.
   The Advantage of this pattern :
        Make code pretty simple.
        The response is delivered to the same process instance that trigger the initial request.
   The drawback of this pattern :
        You cannot do anything else while you are waiting for the response.
        If the provider is not available or something goes wrong , the consumer might never get the response and end up waiting
         forever in a blocked state.
   Note that you might also arrange to do something else while waiting for the response.
        Request / Callback pattern. (Section 10.3.1)
10.2.2 One-Way




 There is an alternative that ‘s even simpler from a consumer’s point of view : send a
  message , and you’re done.
 This one-way pattern is often also called “fire and forget” (See Figure 10.2)
 The Request / Response pattern is just a composition of two one-way messages.
 However , this is not necessarily the case, for two reasons.
     From a consumer’s point of view, a combination of two one-way messages would lead to an
      asynchronous or non-blocking request/response (or request/callback) pattern.
     From an infrastructure’s (ESB’s) point of view, sending two one-way messages would
      require the sender of the first request to be able to receive the second one-way request
      (which logically is the service provider’s response)
10.2.3 Request/Response Versus Two One-
Way Messages.




 If the consumer process needs the response for its further processing, it is
  importance that the response is delivered to the specific process instance that
  performed the initial request (See Figure 10.3)
 Example :
     A CRM service might need to know about a customer’s actual payment behavior to
       determine whether to allow a certain contract option.
          It calls a service of the billing system.
          It needs the response in order to continue to perform the initial service.
          So , it’s importance that the response is routed to the original CRM service instance
     In this case, the consumer must block and wait for the reply.
10.2.3 Request/Response Versus Two One-
Way Messages.(Cont)




 With the specific initial consumer can continue to do its work without getting
  the response, it is not important that the response be delivered to the process
  instance that performed the initial request.
 You can consider the response message to be another service request back to
  the system that initiated the first request (see Figure 10.4)
 Example :
     A CRM service might enable an invoice out-site the usual payment intervals.
        This service might send a corresponding request to the billing system.
        It might call another service in the CRM system to store the new invoice number and date there.
10.2.3 Request/Response Versus Two One-
Way Messages.(Cont)




 Figure 10.5 shows the corresponding sequence diagram for this scenario.
 You can insert message queues in your infrastructure (ESB) , so that one a message
  is sent it is persisted and can’t get lost.
     This is the core of message-oriented middleware (MOM) such as MQ and JMS.
 If you have no support for the request/response pattern in your infrastructure ,
  you’ll have to program in the ability for the providing side of the requesting system
  to find instance to deliver the response to.
10.3 More Complicated MEPs
 There are many possible extensions to and variations of
  these fundamental MEPs.
 This section will discuss some of the most typical ones.
10.3.1 Request /Callback
 Often a process/thread needs some data or confirmation , but doesn’t need to be
  blocked until it arrives  This pattern may be called non-blocking
  request/response , asynchronous request/response , or just request/callback.
 The consumer might define a so-called “callback function” which is a function
  /procedure that is called when the response arrives.
 Dealing with asynchronous responses usually leads to more complicated code.
     The response may return in a different order.  his is usually by introducing correlation
      IDs that are passed with the requests and delivered with the responding replies.
     You have to make sure that the context for each response is still valid and contains all the
      information required to process the response.
     You might have to deal with the fact that no responses arrive for some requests
 The big advantage of this kind of message exchange is that it introduces a form of
  loose coupling :
     Service providers do not have to be available when requests are sent , and consumers can
       continue to work while awaiting responses.
 Each approach has its pros and cons  It can be difficult to decide whether to use
  synchronous or asynchronous request/response scenarios.
10.3.2 Publish/ Subscribe
 One-way messages may be sent that do not require responses.
     To inform another system that something has happened or changed.
     These kind of message are often called notifications.
     Following the usual business process modeling is usually to send notifications.
        A general design that defines that a system must notify a specific other system when certain
         condition arise.
        E.g : When a billing system has sent a new bill to a customer , a message may be sent to the CRM
         system to inform CRM system about a new invoice number.
 This is another famous pattern that enables a system to register or subscribe for
  certain notifications or event  This pattern is usually called the observer or
  publish/subscribe pattern.
 In SOA infrastructure you often only see the second part of this pattern : The
  notification.
 The subscription might be part of the business process modeling that leads to
  service design.
 Note : at runtime , a one-way message is sent from the provider to each
  consumer.
10.4 Dealing with Reliability and Errors
 Here are some problems you might encounter when
 something goes wrong.
   The service provider detects an error and sends back a
    fault message instead of a typical response message.
   The service provider is unavailable and therefore cannot
    receive the message.
   The transport layer for the message might not be
    reliable.
       Messages might get lost over the network.
 Dealing with these situations can make message
 exchange patterns a lot more complicated.
10.4.1 Fault Messages




 If the service provider (or any other process receiving messages and sending responses)
  detects an error, instead of sending back the usual response message , it will send back a
  fault message (See Figure 10.6)
 Usually , you can define special attributes for these fault messages.
 Whether and how faults are handled in special cases has to do with the protocol you use.
 E.g
       Web Services allow you to specify and deal with special fault messages that are returned by
        providers in the event that (expected and modeled) errors occur.
10.4.2 Technical Errors
   If there is a technical problem that prevents a message from being delivered , the sender must be
    notified.




   A message exchange that is reliable from both points of view must involve a double confirmation (See
    Figure 10.7)
   With synchronous communications , these kinds of checks are usually part of the infrastructure.
        The sender of a message should get an appropriate exception if the message could not be delivered successfully.
   With asynchronous communication , things can become more complicated
        One typical approach is to persistently store all outgoing messages in a message queue , which tries to deliver
         them at set intervals.
   Another typical way of dealing with these situations is to retry sending the message until a
    corresponding response arrives. (View Note)
10.5 Dealing with Different MEP Layers
 Message exchange pattern always depend on the characteristics of the transport
  layer or protocol they use.
 But one layer above or below, things might look totally different .
 E.g :
     You can provide asynchronous message exchange patterns on synchronous protocols
      ,and vice versa.




 Even if your transport layer is not reliable , you still can provide an API with a
  reliable interface (See Figure 10-8)
10.5 Dealing with Different MEP Layers
   From a SOA point of view, the interesting issue is which MEPs the protocol supports and which MEPs
    the APIs support.
      If the ESB is protocol driven , the consumer might be responsible for programming aspects such as retries.
      If the ESB is API-driven , however the infrastructure team is responsible for providing APIs for different MEPs.
      In this case , the SOA infrastructure might provide the ability to specify the number of retries and timeout period
       between retries.
   Of course, things can become even more complicated.
        Example , a retry might be sent because the response took long to arrive , not because either the request or the
         response was lost. In this case, the consumer will have to deal with multiple responses. (Figure 10.9)




   Idempotency is a major concern in this scenario.
10.6 Event-Driven Architecture
 What is Event-Driven Architecture (EDA)?
      EDA is a software architecture pattern promoting the production, detection, consumption of,
       and reaction to events.
      EDA is a technique to integrate components and applications by sending and receiving event
       notifications.
      Emitting and consumption of events
      Publish-subscribe pattern
      Asynchronous processing
      De-coupling of supplier and consumer
      Non-deterministic behaviour
 What is an event ?
      ”...a notable thing that happens...”
      A message signifying that an identifiable event has happened
      Common event information
      Event type specific data
      Event instance specific data
      For example, an event notifying consumers that a barrier has been placed on a phone company
       customer might result in all systems that deal with this customer disabling all functionality for
       the customer.
10.6 Event-Driven Architecture
 Basic Architecture

                                      Event Processing
                                           Rules



                    Publishing        Event Processing             Subscriber
                     Services             Engine                    Services




                                                                   Subscribe to event
              Publish event


                                 Event instance
                                                  Event instance
                                                                       Event Subscriber
          Event Publisher
10.6 Event-Driven Architecture
 Event processing styles : there are these general styles of event processing : Simple
  , stream, and complex and these styles are often used together in a mature event-
  driven architecture.
     Simple event processing - Herein, a notable event in the system, initiates certain down
      stream actions. For example, a simple alerting mechanism, or a message-based publish-
      subscribe mechanism.
     Stream Events Processing – Herein, applications publish a stream of events to
      subscribers based on ordinary and notable events. For example, RFID transmissions.
     Complex Events Processing – This is a more advanced form of events processing, and by
      definition is a high-volume, programmatic analysis of events to identify patterns and
      correlations across multiple heterogeneous event sources. This involves interpretation of
      events, pattern definition and matching, in addition to correlation techniques. For
      example, identification of suspicious transaction patterns in real-time, based on customer
      transactions.
 EDA is the perfect answer for systems to operate in an unpredictable and
  asynchronous environment.
 EDA designed systems facilitate more responsiveness to events that take
  place in real life.
     EDA offers a high level of decoupling, and applications must be designed to respond to
      and to publish events.
10.6 Event-Driven Architecture
 The resulting process model
    The resulting process model of an EDA might be different from ( or a special case of)
     the process model of SOA.
         Instead of composing basic services into composed service or process services, you get something
          that can be called a “business process chain” (See Figure 10.10)
10.7 Summary
 Services use different message exchange patterns (MEPs) that define the order,
    direction, and cardinality of messages sent around until a specific service
    operation is done.
   The basic MEPs are request/response and one-way. Also important are the
    request/ callback (asynchronous or nonblocking request/response) and
    publish/subscribe patterns, and higher patterns dealing with error handling.
   MEPs are layer-specific. For SOA, the MEPs on the protocol and API layers are
    important.
   Events are a special type of one-way messages. They lead to event-driven
    architecture (EDA), which can be considered a special case or supplementation
    of SOA.
   One-way messages and events lead to (business) process chains, which is
    another way of implementing business processes. Instead of orchestrated
    services, where there is a central controller for the whole process, you get
    choreographed services, where each service triggers the next step(s) of the
    business process.

Más contenido relacionado

La actualidad más candente

Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Peter R. Egli
 
Cloud deployment models
Cloud deployment modelsCloud deployment models
Cloud deployment modelsAshok Kumar
 
object oriented methodologies
object oriented methodologiesobject oriented methodologies
object oriented methodologiesAmith Tiwari
 
Soa business centric and soap basic
Soa business centric and soap basicSoa business centric and soap basic
Soa business centric and soap basicJothi Lakshmi
 
SOAP - Simple Object Access Protocol
SOAP - Simple Object Access ProtocolSOAP - Simple Object Access Protocol
SOAP - Simple Object Access ProtocolAnushka Patil
 
Architecture of Mobile Computing
Architecture of Mobile ComputingArchitecture of Mobile Computing
Architecture of Mobile ComputingJAINIK PATEL
 
Web services and SOA
Web services and SOAWeb services and SOA
Web services and SOASubin Sugunan
 
Seven step model of migration into the cloud
Seven step model of migration into the cloudSeven step model of migration into the cloud
Seven step model of migration into the cloudRaj Raj
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patternsAmit Kabra
 
Importance & Principles of Modeling from UML Designing
Importance & Principles of Modeling from UML DesigningImportance & Principles of Modeling from UML Designing
Importance & Principles of Modeling from UML DesigningABHISHEK KUMAR
 
Service oriented architecture characteristics of soa
Service oriented architecture characteristics  of soaService oriented architecture characteristics  of soa
Service oriented architecture characteristics of soasmithaps4
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns pptAman Jain
 

La actualidad más candente (20)

Web controls
Web controlsWeb controls
Web controls
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)
 
Cloud deployment models
Cloud deployment modelsCloud deployment models
Cloud deployment models
 
object oriented methodologies
object oriented methodologiesobject oriented methodologies
object oriented methodologies
 
Web services SOAP
Web services SOAPWeb services SOAP
Web services SOAP
 
Soa business centric and soap basic
Soa business centric and soap basicSoa business centric and soap basic
Soa business centric and soap basic
 
SOAP - Simple Object Access Protocol
SOAP - Simple Object Access ProtocolSOAP - Simple Object Access Protocol
SOAP - Simple Object Access Protocol
 
Architecture of Mobile Computing
Architecture of Mobile ComputingArchitecture of Mobile Computing
Architecture of Mobile Computing
 
SOAP-based Web Services
SOAP-based Web ServicesSOAP-based Web Services
SOAP-based Web Services
 
Web services and SOA
Web services and SOAWeb services and SOA
Web services and SOA
 
Distributed System
Distributed SystemDistributed System
Distributed System
 
Struts
StrutsStruts
Struts
 
Seven step model of migration into the cloud
Seven step model of migration into the cloudSeven step model of migration into the cloud
Seven step model of migration into the cloud
 
Introduction to design patterns
Introduction to design patternsIntroduction to design patterns
Introduction to design patterns
 
SOA Unit I
SOA Unit ISOA Unit I
SOA Unit I
 
Middleware Technologies ppt
Middleware Technologies pptMiddleware Technologies ppt
Middleware Technologies ppt
 
Importance & Principles of Modeling from UML Designing
Importance & Principles of Modeling from UML DesigningImportance & Principles of Modeling from UML Designing
Importance & Principles of Modeling from UML Designing
 
Mobile Transport layer
Mobile Transport layerMobile Transport layer
Mobile Transport layer
 
Service oriented architecture characteristics of soa
Service oriented architecture characteristics  of soaService oriented architecture characteristics  of soa
Service oriented architecture characteristics of soa
 
Design patterns ppt
Design patterns pptDesign patterns ppt
Design patterns ppt
 

Similar a Lecture 10 - Message Exchange Patterns

AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES ijwscjournal
 
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES ijwscjournal
 
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES ijwscjournal
 
Apache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache CamelApache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache CamelOmi Om
 
Through-Mail Feature: An Enhancement to Contemporary Email Services
Through-Mail Feature: An Enhancement to Contemporary Email ServicesThrough-Mail Feature: An Enhancement to Contemporary Email Services
Through-Mail Feature: An Enhancement to Contemporary Email ServicesIRJESJOURNAL
 
Dynamic Interface Adaptability in Service Oriented Software
Dynamic Interface Adaptability in Service Oriented SoftwareDynamic Interface Adaptability in Service Oriented Software
Dynamic Interface Adaptability in Service Oriented SoftwareMadjid KETFI
 
Client Server Model and Distributed Computing
Client Server Model and Distributed ComputingClient Server Model and Distributed Computing
Client Server Model and Distributed ComputingAbhishek Jaisingh
 
Requirements of a Recovery Solution for Failure of Composite Web Services
Requirements of a Recovery Solution for Failure of Composite Web Services Requirements of a Recovery Solution for Failure of Composite Web Services
Requirements of a Recovery Solution for Failure of Composite Web Services dannyijwest
 
Patterns&Antipatternsof SOA
Patterns&Antipatternsof SOAPatterns&Antipatternsof SOA
Patterns&Antipatternsof SOAMohamed Samy
 
Part II - Summary of service oriented architecture (SOA) concepts, technology...
Part II - Summary of service oriented architecture (SOA) concepts, technology...Part II - Summary of service oriented architecture (SOA) concepts, technology...
Part II - Summary of service oriented architecture (SOA) concepts, technology...Mohammed Omar
 
DSNs & X.400 assist in ensuring email reliability
DSNs & X.400 assist in ensuring email reliabilityDSNs & X.400 assist in ensuring email reliability
DSNs & X.400 assist in ensuring email reliabilityIOSR Journals
 
DSNs & X.400 assist in ensuring email reliability
DSNs & X.400 assist in ensuring email reliabilityDSNs & X.400 assist in ensuring email reliability
DSNs & X.400 assist in ensuring email reliabilityIOSR Journals
 
Inter process communication
Inter process communicationInter process communication
Inter process communicationTamer Rezk
 
Differences Between Architectures
Differences Between ArchitecturesDifferences Between Architectures
Differences Between Architecturesprasadsmn
 
Lecture 9 - SOA in Context
Lecture 9 - SOA in ContextLecture 9 - SOA in Context
Lecture 9 - SOA in Contextphanleson
 
Integration Patterns With Spring integration
Integration Patterns With Spring integrationIntegration Patterns With Spring integration
Integration Patterns With Spring integrationEldad Dor
 
Lecture 15 - Technical Details
Lecture 15 - Technical DetailsLecture 15 - Technical Details
Lecture 15 - Technical Detailsphanleson
 
Synchronous and asynchronous software communication components
Synchronous and asynchronous software communication componentsSynchronous and asynchronous software communication components
Synchronous and asynchronous software communication componentsPanagiotis Tsilopoulos
 
Lecture 04 - Loose Coupling
Lecture 04 - Loose CouplingLecture 04 - Loose Coupling
Lecture 04 - Loose Couplingphanleson
 

Similar a Lecture 10 - Message Exchange Patterns (20)

AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
 
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
 
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
AVAILABILITY METRICS: UNDER CONTROLLED ENVIRONMENTS FOR WEB SERVICES
 
Apache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache CamelApache ActiveMQ and Apache Camel
Apache ActiveMQ and Apache Camel
 
Through-Mail Feature: An Enhancement to Contemporary Email Services
Through-Mail Feature: An Enhancement to Contemporary Email ServicesThrough-Mail Feature: An Enhancement to Contemporary Email Services
Through-Mail Feature: An Enhancement to Contemporary Email Services
 
Dynamic Interface Adaptability in Service Oriented Software
Dynamic Interface Adaptability in Service Oriented SoftwareDynamic Interface Adaptability in Service Oriented Software
Dynamic Interface Adaptability in Service Oriented Software
 
Client Server Model and Distributed Computing
Client Server Model and Distributed ComputingClient Server Model and Distributed Computing
Client Server Model and Distributed Computing
 
Requirements of a Recovery Solution for Failure of Composite Web Services
Requirements of a Recovery Solution for Failure of Composite Web Services Requirements of a Recovery Solution for Failure of Composite Web Services
Requirements of a Recovery Solution for Failure of Composite Web Services
 
Patterns&Antipatternsof SOA
Patterns&Antipatternsof SOAPatterns&Antipatternsof SOA
Patterns&Antipatternsof SOA
 
Part II - Summary of service oriented architecture (SOA) concepts, technology...
Part II - Summary of service oriented architecture (SOA) concepts, technology...Part II - Summary of service oriented architecture (SOA) concepts, technology...
Part II - Summary of service oriented architecture (SOA) concepts, technology...
 
DSNs & X.400 assist in ensuring email reliability
DSNs & X.400 assist in ensuring email reliabilityDSNs & X.400 assist in ensuring email reliability
DSNs & X.400 assist in ensuring email reliability
 
DSNs & X.400 assist in ensuring email reliability
DSNs & X.400 assist in ensuring email reliabilityDSNs & X.400 assist in ensuring email reliability
DSNs & X.400 assist in ensuring email reliability
 
B017211114
B017211114B017211114
B017211114
 
Inter process communication
Inter process communicationInter process communication
Inter process communication
 
Differences Between Architectures
Differences Between ArchitecturesDifferences Between Architectures
Differences Between Architectures
 
Lecture 9 - SOA in Context
Lecture 9 - SOA in ContextLecture 9 - SOA in Context
Lecture 9 - SOA in Context
 
Integration Patterns With Spring integration
Integration Patterns With Spring integrationIntegration Patterns With Spring integration
Integration Patterns With Spring integration
 
Lecture 15 - Technical Details
Lecture 15 - Technical DetailsLecture 15 - Technical Details
Lecture 15 - Technical Details
 
Synchronous and asynchronous software communication components
Synchronous and asynchronous software communication componentsSynchronous and asynchronous software communication components
Synchronous and asynchronous software communication components
 
Lecture 04 - Loose Coupling
Lecture 04 - Loose CouplingLecture 04 - Loose Coupling
Lecture 04 - Loose Coupling
 

Más de phanleson

Learning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with SparkLearning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with Sparkphanleson
 
Firewall - Network Defense in Depth Firewalls
Firewall - Network Defense in Depth FirewallsFirewall - Network Defense in Depth Firewalls
Firewall - Network Defense in Depth Firewallsphanleson
 
Mobile Security - Wireless hacking
Mobile Security - Wireless hackingMobile Security - Wireless hacking
Mobile Security - Wireless hackingphanleson
 
Authentication in wireless - Security in Wireless Protocols
Authentication in wireless - Security in Wireless ProtocolsAuthentication in wireless - Security in Wireless Protocols
Authentication in wireless - Security in Wireless Protocolsphanleson
 
E-Commerce Security - Application attacks - Server Attacks
E-Commerce Security - Application attacks - Server AttacksE-Commerce Security - Application attacks - Server Attacks
E-Commerce Security - Application attacks - Server Attacksphanleson
 
Hacking web applications
Hacking web applicationsHacking web applications
Hacking web applicationsphanleson
 
HBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table designHBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table designphanleson
 
HBase In Action - Chapter 10 - Operations
HBase In Action - Chapter 10 - OperationsHBase In Action - Chapter 10 - Operations
HBase In Action - Chapter 10 - Operationsphanleson
 
Hbase in action - Chapter 09: Deploying HBase
Hbase in action - Chapter 09: Deploying HBaseHbase in action - Chapter 09: Deploying HBase
Hbase in action - Chapter 09: Deploying HBasephanleson
 
Learning spark ch11 - Machine Learning with MLlib
Learning spark ch11 - Machine Learning with MLlibLearning spark ch11 - Machine Learning with MLlib
Learning spark ch11 - Machine Learning with MLlibphanleson
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streamingphanleson
 
Learning spark ch09 - Spark SQL
Learning spark ch09 - Spark SQLLearning spark ch09 - Spark SQL
Learning spark ch09 - Spark SQLphanleson
 
Learning spark ch07 - Running on a Cluster
Learning spark ch07 - Running on a ClusterLearning spark ch07 - Running on a Cluster
Learning spark ch07 - Running on a Clusterphanleson
 
Learning spark ch06 - Advanced Spark Programming
Learning spark ch06 - Advanced Spark ProgrammingLearning spark ch06 - Advanced Spark Programming
Learning spark ch06 - Advanced Spark Programmingphanleson
 
Learning spark ch05 - Loading and Saving Your Data
Learning spark ch05 - Loading and Saving Your DataLearning spark ch05 - Loading and Saving Your Data
Learning spark ch05 - Loading and Saving Your Dataphanleson
 
Learning spark ch04 - Working with Key/Value Pairs
Learning spark ch04 - Working with Key/Value PairsLearning spark ch04 - Working with Key/Value Pairs
Learning spark ch04 - Working with Key/Value Pairsphanleson
 
Learning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with SparkLearning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with Sparkphanleson
 
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about LibertagiaHướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagiaphanleson
 
Lecture 1 - Getting to know XML
Lecture 1 - Getting to know XMLLecture 1 - Getting to know XML
Lecture 1 - Getting to know XMLphanleson
 
Lecture 4 - Adding XTHML for the Web
Lecture  4 - Adding XTHML for the WebLecture  4 - Adding XTHML for the Web
Lecture 4 - Adding XTHML for the Webphanleson
 

Más de phanleson (20)

Learning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with SparkLearning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with Spark
 
Firewall - Network Defense in Depth Firewalls
Firewall - Network Defense in Depth FirewallsFirewall - Network Defense in Depth Firewalls
Firewall - Network Defense in Depth Firewalls
 
Mobile Security - Wireless hacking
Mobile Security - Wireless hackingMobile Security - Wireless hacking
Mobile Security - Wireless hacking
 
Authentication in wireless - Security in Wireless Protocols
Authentication in wireless - Security in Wireless ProtocolsAuthentication in wireless - Security in Wireless Protocols
Authentication in wireless - Security in Wireless Protocols
 
E-Commerce Security - Application attacks - Server Attacks
E-Commerce Security - Application attacks - Server AttacksE-Commerce Security - Application attacks - Server Attacks
E-Commerce Security - Application attacks - Server Attacks
 
Hacking web applications
Hacking web applicationsHacking web applications
Hacking web applications
 
HBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table designHBase In Action - Chapter 04: HBase table design
HBase In Action - Chapter 04: HBase table design
 
HBase In Action - Chapter 10 - Operations
HBase In Action - Chapter 10 - OperationsHBase In Action - Chapter 10 - Operations
HBase In Action - Chapter 10 - Operations
 
Hbase in action - Chapter 09: Deploying HBase
Hbase in action - Chapter 09: Deploying HBaseHbase in action - Chapter 09: Deploying HBase
Hbase in action - Chapter 09: Deploying HBase
 
Learning spark ch11 - Machine Learning with MLlib
Learning spark ch11 - Machine Learning with MLlibLearning spark ch11 - Machine Learning with MLlib
Learning spark ch11 - Machine Learning with MLlib
 
Learning spark ch10 - Spark Streaming
Learning spark ch10 - Spark StreamingLearning spark ch10 - Spark Streaming
Learning spark ch10 - Spark Streaming
 
Learning spark ch09 - Spark SQL
Learning spark ch09 - Spark SQLLearning spark ch09 - Spark SQL
Learning spark ch09 - Spark SQL
 
Learning spark ch07 - Running on a Cluster
Learning spark ch07 - Running on a ClusterLearning spark ch07 - Running on a Cluster
Learning spark ch07 - Running on a Cluster
 
Learning spark ch06 - Advanced Spark Programming
Learning spark ch06 - Advanced Spark ProgrammingLearning spark ch06 - Advanced Spark Programming
Learning spark ch06 - Advanced Spark Programming
 
Learning spark ch05 - Loading and Saving Your Data
Learning spark ch05 - Loading and Saving Your DataLearning spark ch05 - Loading and Saving Your Data
Learning spark ch05 - Loading and Saving Your Data
 
Learning spark ch04 - Working with Key/Value Pairs
Learning spark ch04 - Working with Key/Value PairsLearning spark ch04 - Working with Key/Value Pairs
Learning spark ch04 - Working with Key/Value Pairs
 
Learning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with SparkLearning spark ch01 - Introduction to Data Analysis with Spark
Learning spark ch01 - Introduction to Data Analysis with Spark
 
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about LibertagiaHướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
Hướng Dẫn Đăng Ký LibertaGia - A guide and introduciton about Libertagia
 
Lecture 1 - Getting to know XML
Lecture 1 - Getting to know XMLLecture 1 - Getting to know XML
Lecture 1 - Getting to know XML
 
Lecture 4 - Adding XTHML for the Web
Lecture  4 - Adding XTHML for the WebLecture  4 - Adding XTHML for the Web
Lecture 4 - Adding XTHML for the Web
 

Lecture 10 - Message Exchange Patterns

  • 1. Book Author: Nicolai M. Josuttis Chapter Ten: Message Exchange Patterns IT-Slideshares http://it-slideshares.blogspot.com/
  • 2. 10.1 Introduction to MEPs  There are different ways to exchange data between distributed systems.  One fundamental approach to dealing with these differences is to categorize the way chunks of data are exchange.  These chunks of data are called messages.  By categorizing different ways of exchanging messages , we get the so- called message exchange patterns.  MEPs define the sequence of messages in a service call or service operation, specifying the order, direction and cardinality of those messages.  Note :  MEPs are general concepts to describe communications between different systems (or nodes).
  • 3. 10.2 Basic MEPs  There are different approaches to categorizing MEPs.  This section start with two basic patterns and explain some others based on these patterns.
  • 4. 10.2.1 Request / Response  Probably the most importance pattern for SOA is request/response.  In this pattern, the consumer send a request message to the service provider and waits for the provider to send a response message (See Figure 10.1)  From the consumer’s point of view , such a service call is like a remote procedure call (RPC) .  The consumer is blocked until the response arrives.  The Advantage of this pattern :  Make code pretty simple.  The response is delivered to the same process instance that trigger the initial request.  The drawback of this pattern :  You cannot do anything else while you are waiting for the response.  If the provider is not available or something goes wrong , the consumer might never get the response and end up waiting forever in a blocked state.  Note that you might also arrange to do something else while waiting for the response.  Request / Callback pattern. (Section 10.3.1)
  • 5. 10.2.2 One-Way  There is an alternative that ‘s even simpler from a consumer’s point of view : send a message , and you’re done.  This one-way pattern is often also called “fire and forget” (See Figure 10.2)  The Request / Response pattern is just a composition of two one-way messages.  However , this is not necessarily the case, for two reasons.  From a consumer’s point of view, a combination of two one-way messages would lead to an asynchronous or non-blocking request/response (or request/callback) pattern.  From an infrastructure’s (ESB’s) point of view, sending two one-way messages would require the sender of the first request to be able to receive the second one-way request (which logically is the service provider’s response)
  • 6. 10.2.3 Request/Response Versus Two One- Way Messages.  If the consumer process needs the response for its further processing, it is importance that the response is delivered to the specific process instance that performed the initial request (See Figure 10.3)  Example :  A CRM service might need to know about a customer’s actual payment behavior to determine whether to allow a certain contract option.  It calls a service of the billing system.  It needs the response in order to continue to perform the initial service.  So , it’s importance that the response is routed to the original CRM service instance  In this case, the consumer must block and wait for the reply.
  • 7. 10.2.3 Request/Response Versus Two One- Way Messages.(Cont)  With the specific initial consumer can continue to do its work without getting the response, it is not important that the response be delivered to the process instance that performed the initial request.  You can consider the response message to be another service request back to the system that initiated the first request (see Figure 10.4)  Example :  A CRM service might enable an invoice out-site the usual payment intervals.  This service might send a corresponding request to the billing system.  It might call another service in the CRM system to store the new invoice number and date there.
  • 8. 10.2.3 Request/Response Versus Two One- Way Messages.(Cont)  Figure 10.5 shows the corresponding sequence diagram for this scenario.  You can insert message queues in your infrastructure (ESB) , so that one a message is sent it is persisted and can’t get lost.  This is the core of message-oriented middleware (MOM) such as MQ and JMS.  If you have no support for the request/response pattern in your infrastructure , you’ll have to program in the ability for the providing side of the requesting system to find instance to deliver the response to.
  • 9. 10.3 More Complicated MEPs  There are many possible extensions to and variations of these fundamental MEPs.  This section will discuss some of the most typical ones.
  • 10. 10.3.1 Request /Callback  Often a process/thread needs some data or confirmation , but doesn’t need to be blocked until it arrives  This pattern may be called non-blocking request/response , asynchronous request/response , or just request/callback.  The consumer might define a so-called “callback function” which is a function /procedure that is called when the response arrives.  Dealing with asynchronous responses usually leads to more complicated code.  The response may return in a different order.  his is usually by introducing correlation IDs that are passed with the requests and delivered with the responding replies.  You have to make sure that the context for each response is still valid and contains all the information required to process the response.  You might have to deal with the fact that no responses arrive for some requests  The big advantage of this kind of message exchange is that it introduces a form of loose coupling :  Service providers do not have to be available when requests are sent , and consumers can continue to work while awaiting responses.  Each approach has its pros and cons  It can be difficult to decide whether to use synchronous or asynchronous request/response scenarios.
  • 11. 10.3.2 Publish/ Subscribe  One-way messages may be sent that do not require responses.  To inform another system that something has happened or changed.  These kind of message are often called notifications.  Following the usual business process modeling is usually to send notifications.  A general design that defines that a system must notify a specific other system when certain condition arise.  E.g : When a billing system has sent a new bill to a customer , a message may be sent to the CRM system to inform CRM system about a new invoice number.  This is another famous pattern that enables a system to register or subscribe for certain notifications or event  This pattern is usually called the observer or publish/subscribe pattern.  In SOA infrastructure you often only see the second part of this pattern : The notification.  The subscription might be part of the business process modeling that leads to service design.  Note : at runtime , a one-way message is sent from the provider to each consumer.
  • 12. 10.4 Dealing with Reliability and Errors  Here are some problems you might encounter when something goes wrong.  The service provider detects an error and sends back a fault message instead of a typical response message.  The service provider is unavailable and therefore cannot receive the message.  The transport layer for the message might not be reliable.  Messages might get lost over the network.  Dealing with these situations can make message exchange patterns a lot more complicated.
  • 13. 10.4.1 Fault Messages  If the service provider (or any other process receiving messages and sending responses) detects an error, instead of sending back the usual response message , it will send back a fault message (See Figure 10.6)  Usually , you can define special attributes for these fault messages.  Whether and how faults are handled in special cases has to do with the protocol you use.  E.g  Web Services allow you to specify and deal with special fault messages that are returned by providers in the event that (expected and modeled) errors occur.
  • 14. 10.4.2 Technical Errors  If there is a technical problem that prevents a message from being delivered , the sender must be notified.  A message exchange that is reliable from both points of view must involve a double confirmation (See Figure 10.7)  With synchronous communications , these kinds of checks are usually part of the infrastructure.  The sender of a message should get an appropriate exception if the message could not be delivered successfully.  With asynchronous communication , things can become more complicated  One typical approach is to persistently store all outgoing messages in a message queue , which tries to deliver them at set intervals.  Another typical way of dealing with these situations is to retry sending the message until a corresponding response arrives. (View Note)
  • 15. 10.5 Dealing with Different MEP Layers  Message exchange pattern always depend on the characteristics of the transport layer or protocol they use.  But one layer above or below, things might look totally different .  E.g :  You can provide asynchronous message exchange patterns on synchronous protocols ,and vice versa.  Even if your transport layer is not reliable , you still can provide an API with a reliable interface (See Figure 10-8)
  • 16. 10.5 Dealing with Different MEP Layers  From a SOA point of view, the interesting issue is which MEPs the protocol supports and which MEPs the APIs support.  If the ESB is protocol driven , the consumer might be responsible for programming aspects such as retries.  If the ESB is API-driven , however the infrastructure team is responsible for providing APIs for different MEPs.  In this case , the SOA infrastructure might provide the ability to specify the number of retries and timeout period between retries.  Of course, things can become even more complicated.  Example , a retry might be sent because the response took long to arrive , not because either the request or the response was lost. In this case, the consumer will have to deal with multiple responses. (Figure 10.9)  Idempotency is a major concern in this scenario.
  • 17. 10.6 Event-Driven Architecture  What is Event-Driven Architecture (EDA)?  EDA is a software architecture pattern promoting the production, detection, consumption of, and reaction to events.  EDA is a technique to integrate components and applications by sending and receiving event notifications.  Emitting and consumption of events  Publish-subscribe pattern  Asynchronous processing  De-coupling of supplier and consumer  Non-deterministic behaviour  What is an event ?  ”...a notable thing that happens...”  A message signifying that an identifiable event has happened  Common event information  Event type specific data  Event instance specific data  For example, an event notifying consumers that a barrier has been placed on a phone company customer might result in all systems that deal with this customer disabling all functionality for the customer.
  • 18. 10.6 Event-Driven Architecture  Basic Architecture Event Processing Rules Publishing Event Processing Subscriber Services Engine Services Subscribe to event Publish event Event instance Event instance Event Subscriber Event Publisher
  • 19. 10.6 Event-Driven Architecture  Event processing styles : there are these general styles of event processing : Simple , stream, and complex and these styles are often used together in a mature event- driven architecture.  Simple event processing - Herein, a notable event in the system, initiates certain down stream actions. For example, a simple alerting mechanism, or a message-based publish- subscribe mechanism.  Stream Events Processing – Herein, applications publish a stream of events to subscribers based on ordinary and notable events. For example, RFID transmissions.  Complex Events Processing – This is a more advanced form of events processing, and by definition is a high-volume, programmatic analysis of events to identify patterns and correlations across multiple heterogeneous event sources. This involves interpretation of events, pattern definition and matching, in addition to correlation techniques. For example, identification of suspicious transaction patterns in real-time, based on customer transactions.  EDA is the perfect answer for systems to operate in an unpredictable and asynchronous environment.  EDA designed systems facilitate more responsiveness to events that take place in real life.  EDA offers a high level of decoupling, and applications must be designed to respond to and to publish events.
  • 20. 10.6 Event-Driven Architecture  The resulting process model  The resulting process model of an EDA might be different from ( or a special case of) the process model of SOA.  Instead of composing basic services into composed service or process services, you get something that can be called a “business process chain” (See Figure 10.10)
  • 21. 10.7 Summary  Services use different message exchange patterns (MEPs) that define the order, direction, and cardinality of messages sent around until a specific service operation is done.  The basic MEPs are request/response and one-way. Also important are the request/ callback (asynchronous or nonblocking request/response) and publish/subscribe patterns, and higher patterns dealing with error handling.  MEPs are layer-specific. For SOA, the MEPs on the protocol and API layers are important.  Events are a special type of one-way messages. They lead to event-driven architecture (EDA), which can be considered a special case or supplementation of SOA.  One-way messages and events lead to (business) process chains, which is another way of implementing business processes. Instead of orchestrated services, where there is a central controller for the whole process, you get choreographed services, where each service triggers the next step(s) of the business process.

Notas del editor

  1. Example of Notification : At design time a service contract might define that the CRM system gets an event from the billing system each time a customer gets a new bill. Other service contracts (for example, to an online portal) might define that other systems get the same event. As a result, when a customer gets a new bill the service provider “billing system” will automatically send a notification to all the consumers with that clause in their service contracts.
  2. With the typical way is retry sending the message until a corresponding response arrives.That is, you need to be sure that resending the message will not have unintended consequences. If, for example, you’re sending a message that adds a certain amount of money to a bank account, you want to make sure that if the message has to be resent, the effect takes place only once. If you don’t get a response to such a message, you won’t know whether it was the request or the response that failed. That is, the provider might or might not have processed the service call already.
  3. Describe of Figure 10.8The consumer calls a service . The corresponding API blocks until it receives the response (or an exception )The protocol used is not reliable  underneath this API , the code more complicated.The following steps describe sequence state in figure 10.8The first request message sent to the provider gets lost. So, after a timeout , the low-level API of the consumer performs a retry . This message is routed successfully to the service provider . Unfortunately , this time the response gets lost. So the consumer performs another retry . This attempt succeeds, and the request data is finally returned to the consumer.In this example , the consumer uses an API for a synchronous request/response MEP, while the low-level protocol is a sequence of request/callback MEPs.
  4. The following steps describe sequence state in figure 10.9The first request message got lost.A retry was sent.The retry was successful , but because the result took to long to arrive, a second retry message was sent.This message was processed by another thread of the service provider.The consumer ended up with two responses (which might not even have arrived in the expected order).
  5. Note There is a lot of discussion at the moment about whether EDA is a special form of SOA, an enhancement of SOA, or something different . For example, some analysts and companies have introduced terms such as “Advanced SOA” or “SOA 2.0” to refer to the combination of EDA and SOA (see, e.g., [GartnerEDA06], which strictly speaking compares and combines EDA with “interactive SOA”).
  6. It’s like choreography (see Section 7.6): there is no central control. Instead, the process chain is a sequence of (parallel) processing triggered by events. The good thing is that there is no need for a central controlling component, which might turn out to be a bottleneck. The bad thing is that it is more difficult to understand, document , and monitor the whole process or process instances, respectively.