SlideShare a Scribd company logo
API Façade Pattern with
Apache Synapse
Hiranya Jayathilaka
hiranya@apache.org
Apache Synapse
 A lightweight, open source Enterprise Service Bus (ESB)
 Visit http://synapse.apache.org
 Connect and integrate heterogeneous systems
What is an ESB?
Key Features of Synapse
 Message routing
 Message filtering
 Message transformation
 Message enrichment
 Protocol switching
 Load balancing
 Fail-over routing
 QoS enforcement
 Service virtualization
 Traffic throttling
 Task scheduling
Supported Protocol/Standards
 Communication protocols (Transports)
 HTTP/S, E-Mail (POP/IMAP), JMS,AMQP, FIX, FTP and other file
transfer protocols, RawTCP and UDP and more…
 Message formats (Content exchange formats)
 XML, SOAP, JSON, HTML, Plain text, Hessian, HL7,Various
binary formats and more…
 Other
 JDBC/SQL,WSDL and otherWS-* standards, REST, SNMP, JMX
Synapse Messaging Model
 Several types of configurable and composable constructs
 Mediators
 Sequences
 Proxy Services
 APIs
 Endpoints
 Templates
 Message stores and processors
Mediators
 Smallest configurable message processing unit in Synapse
 Synapse ships with a wide range of built-in mediators
Mediator
Input
Message
Output
Message
Config
Sequences
 An ordered list of mediators
 Provides the “message flow” abstraction
Log
Mediator
Header
Mediator
Send
Mediator
APIs/Proxy Services
 Connects a client application to a backend service
 Comprised of several sequences
 In sequence – Processes requests from client
 Out sequence – Processes responses from the service
 Fault sequence – Handles errors
Client
Application
Backend
Service
API/Proxy Service
In Sequence
Out Sequence
Synapse Configuration
 XML-based metalanguage
 Simple and intuitive – Protocol and message format agnostic
programming model
 Supports the familiar constructs of a programming language
 If-Then, Switch-Case,Try-Catch
 Reusable function-like constructs
 Hot deploy and hot update
API Façade Pattern
 Expose a non-RESTful application through a REST API
 Example use cases
 Expose a SOAP service as a RESTful service
 Expose a database as a service
 Expose a legacy system as a service
Demo
RESTClient
SOAP
Service
Synapse/ESB
Questions?
References
 Apache Synapse – http://synapse.apache.org
 WSO2 ESB - http://wso2.com/products/enterprise-service-bus/
 Demo artifacts - https://github.com/hiranya911/rest-gateway-
demo
 Demo documentation - https://rest-gateway-
demo.readthedocs.org/en/latest/
 API façade pattern -
http://asanka.abeysinghe.org/2013/04/pragmatic-approach-to-api-
facade-pattern.html

More Related Content

API Facade Pattern with Apache Synapse

  • 1. API Façade Pattern with Apache Synapse Hiranya Jayathilaka hiranya@apache.org
  • 2. Apache Synapse  A lightweight, open source Enterprise Service Bus (ESB)  Visit http://synapse.apache.org  Connect and integrate heterogeneous systems
  • 3. What is an ESB?
  • 4. Key Features of Synapse  Message routing  Message filtering  Message transformation  Message enrichment  Protocol switching  Load balancing  Fail-over routing  QoS enforcement  Service virtualization  Traffic throttling  Task scheduling
  • 5. Supported Protocol/Standards  Communication protocols (Transports)  HTTP/S, E-Mail (POP/IMAP), JMS,AMQP, FIX, FTP and other file transfer protocols, RawTCP and UDP and more…  Message formats (Content exchange formats)  XML, SOAP, JSON, HTML, Plain text, Hessian, HL7,Various binary formats and more…  Other  JDBC/SQL,WSDL and otherWS-* standards, REST, SNMP, JMX
  • 6. Synapse Messaging Model  Several types of configurable and composable constructs  Mediators  Sequences  Proxy Services  APIs  Endpoints  Templates  Message stores and processors
  • 7. Mediators  Smallest configurable message processing unit in Synapse  Synapse ships with a wide range of built-in mediators Mediator Input Message Output Message Config
  • 8. Sequences  An ordered list of mediators  Provides the “message flow” abstraction Log Mediator Header Mediator Send Mediator
  • 9. APIs/Proxy Services  Connects a client application to a backend service  Comprised of several sequences  In sequence – Processes requests from client  Out sequence – Processes responses from the service  Fault sequence – Handles errors Client Application Backend Service API/Proxy Service In Sequence Out Sequence
  • 10. Synapse Configuration  XML-based metalanguage  Simple and intuitive – Protocol and message format agnostic programming model  Supports the familiar constructs of a programming language  If-Then, Switch-Case,Try-Catch  Reusable function-like constructs  Hot deploy and hot update
  • 11. API Façade Pattern  Expose a non-RESTful application through a REST API  Example use cases  Expose a SOAP service as a RESTful service  Expose a database as a service  Expose a legacy system as a service
  • 14. References  Apache Synapse – http://synapse.apache.org  WSO2 ESB - http://wso2.com/products/enterprise-service-bus/  Demo artifacts - https://github.com/hiranya911/rest-gateway- demo  Demo documentation - https://rest-gateway- demo.readthedocs.org/en/latest/  API façade pattern - http://asanka.abeysinghe.org/2013/04/pragmatic-approach-to-api- facade-pattern.html