Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc. Building an Enterprise Service Bus Using Web Services and Apache Synapse v2
Paul Fremantle VP of Technology WSO2 [email protected]
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 1 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
About Me Co-founder and VP of Technology and Partnerships at WSO2 ¾ The leading Open Source Web services company Co-Chair of the OASIS WSRX Technical Committee Committer on Apache Synapse Member of the Apache Software Foundation Co-author of Building Web Services in Java 2nd Edition http://bloglines.com/blog/paulfremantle Ex IBM Senior Technical Staff Member ¾ developed the IBM Web Services Gateway ¾ Apache WSIF, Apache Axis C/C++, JWSDL/WSDL4J Apache Woden
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 2 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc. Apache Synapse The Small Print
Synapse is an effort undergoing incubation at the Apache Software Foundation (ASF), sponsored by the Web Services PMC. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects.
While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
In other words… an incubator project for the moment
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 3 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Contents What is an ESB? A Web services based ESB Connect, Manage, Transform Apache Synapse ¾Structure and model ¾Deployment ¾Configuration ¾Programming model Examples and demo
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 4 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
What is an ESB?
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 5 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
A Common ESB Definition
“Any to any data connectivity and transformation (including Web Services) built on an advanced, proven, reliable middleware infrastructure”
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 6 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
ESB Definition
“Any to any data connectivity and transformation (including Web Services) built on an advanced, proven, reliable middleware infrastructure” which means Our existing middleware re-branded as an SOA platform, with some new web services adapters at the edges
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 7 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
So what is an Enterprise Service Bus?
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 8 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
A Bus Bus
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 9 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Busbar
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 10 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Bus
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 11 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
“The Original ESB”
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 12 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
What Is Good about ESBs? SOA based integration ¾More than just message passing ¾Metadata about the contracts involved • e.g. WSDL, Schema, Policy Bus model is very powerful ¾Every message goes into the “bus” and ends up in the right place
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 13 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
So Why Comments Like This: Anne Thomas Manes: ¾ “I do not believe that an ESB is an essential component of SOA. When it comes right down to it, you don't need any new products to do SOA. After all, SOA is about design, not technology.” ¾ “For the most part, ‘ESB’ is a marketing term.” ¾ “But by 2003, a bunch of other vendors hijacked the term and applied it to their own integration products.”
Are ESBs a new lock-in point?
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 14 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Service Oriented Architecture
Service Service Service
Contract Contract Contract
ESB
Process Portal Call Center Management
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 15 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
The Only Common Data Model
Service Service Service
Contract Contract Contract
XML, XML Schema
Process Portal Call Center Management
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 16 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc. The Only Common Interaction Models
Service Service Service
Contract Contract Contract
HTTP 1.1 200 OK
Process Portal Call Center Management
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 17 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc. What Do You Need for Enterprise Integration? Connectivity Data formats Security Reliability Routing Metadata Management
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 18 Colorado Software Summit:What October 22 – 27, 2006 Do You Need for © Copyright 2006, WSO2 Inc. Enterprise Integration? Connectivity ¾ Get data and messages from A to B Data formats ¾ Understand what shape the data is in Security ¾ Ensure end-to-end confidentiality, authentication, integrity Reliability ¾ Ensure message delivery Routing ¾ Decouple systems from the physical topology Metadata ¾ Understand what systems are there and what they offer and use
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 19 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc. What Do You Get from Web Services?
Connectivity ¾ Lightweight universal connectivity ¾ HTTP, REST, SOAP, XOP/MTOM (binary data) Data formats ¾ Common data model and data description language ¾ XML, XML Schema Security ¾ Encryption, Authentication, Single Signon ¾ WS-Security, WS-Trust, WS-SecureConversation Reliability ¾ Exactly once in-order delivery ¾ WS-ReliableMessaging Routing ¾ To/From/ReplyTo headers ¾ WS-Addressing Metadata ¾ Functional and non-functional description, capabilities and requirements ¾ WSDL, WS-Policy, XML Schema
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 20 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
So What Is Synapse? A Web Service intermediary
Synapse.xml Ethernet Ethernet User Synapse mediators Extensions
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 21 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
The Synapse Pattern of an ESB
Java J2EE JMS Axis2/Java S JAXWS Axis2/J CICS Legacy management DB2 Axis/C routing transformation PHP Web validation SAP security policy IMS S S Partner .net Gateway XML REST SOAP MTOM JSON
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 22 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
A Web Services Mediation Engine
TP MT manage HT OM ST/ RE route S OAP/W /JMS SS transform XML auth XSLT, E4X SOAP/H HTTP x POJO validate TTP SOAP/ p x S a ge th e p r e g r java o S MS f l O /J AP AP JMX /W SO SS
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 23 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
What Does Synapse Do? Connect
Manage
Transform
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 24 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Connect Route messages ¾ Based on XPath, Regex, etc. Deal with mismatch ¾ Initiate/Terminate RM, WS-Sec Switch ¾ POX or REST to SOAP to JSON ¾ JMS to HTTP to SMTP Virtualisation ¾ Virtual URI to real URI mapping
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 25 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Connect Example
Synapse Real Client
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 26 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Manage Logging Tracking – adding headers Authentication and Authorisation Schema validation Failover, retry and load-balancing
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 27 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Manage Examples
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 28 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Transform XSL Transforms ¾Apply an XSLT to the SOAP message or Body JavaScript/E4X ¾E4X is a simple mapping of XML directly into JavaScript POJO ¾Write Java logic that manipulates the message JSON ÅÆ XML ¾Take in JSON/HTTP and send out XML or SOAP
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 29 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Transform Example
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 30 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Synapse’s Two Approaches Rules
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 31 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Deployment Models
Synapse
HTTP Proxy
req prov Gateway
SOAP SOAP SOAP Intermediary Intermediary Intermediary
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 32 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Deployment
Transparent proxy ¾ Configure the client to use Synapse as a proxy • Works with or without WS-Addressing headers ¾ Or use a “smart client” and set
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 33 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc. First Rule of the Synapse Programming Model “Don’t use the Synapse Programming Model”
The aim of Synapse is to build in the common functions: ¾ Log, route, modify headers, etc. ¾ Engage QoS: WSS, WSRM, WSA, etc. And use XML models: ¾ XPath, XSLT, etc. Configure the routing and transformation using a simple XML file
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 34 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Synapse Config Language
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 35 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Sequences A chain of actions to take on a given message ¾The actions may be conditional ¾Each sequence can have a name and be re-used
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 36 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc. Example
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 37 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Endpoints A simple local representation of a remote endpoint
Allows characteristics such as policy, RM, Security to be configured
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 38 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Useful Mediators
send header ¾ Set a header in the ¾ Send on message drop filter ¾ Ditch the message ¾ Do this if the XPath or Regex matches log class ¾ log message ¾ Call a user mediator makefault validate ¾ Send a fault on or back ¾ XSD validation transform switch ¾ Conditional processing ¾ XSLT
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 39 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Synapse Extensions Packaged as a JAR Uses dynamic discovery to register new XML elements into the configuration model e.g. ¾
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 40 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
User Mediators Simple Java class that implements the Mediator interface: boolean mediate(MessageContext mc);
true= continue processing false= halt processing
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 41 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Programming Model (Continued) o.a.synapse.MessageContext A representation of a SOAP infoset ¾Routing model • get/setTo, From, ReplyTo, FaultTo, MessageId, etc. ¾get/setEnvelope() • AXIOM representation ¾isResponse(), isMTOM(), isRest() ¾get/setProperties()
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 42 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Asynchronous Internals We are just working on a non-blocking IO model for Synapse ¾If full WS-Addressing in place then already asynchronous • Updating Synapse to have same behaviour even the client or server block on HTTP ¾Requires a NIO transport for Axis2 • Since Axis2 does all the IO for Synapse ¾More important for an intermediary than an endpoint • Endpoints are usually doing something with the thread while the socket is open
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 43 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Async IO Diagram
Incoming req Synapse
Request Thread1 processing Outgoing req Socket open Socket open
Incoming resp
Response Thread2 processing Outgoing resp
This model means: 1. Synapse threads never blocked during normal processing 2. Number of sockets open >> number of threads Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 44 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc. Scalable Event Driven Architecture Simple model of stages and queues for handling load Matt Welsh’s PhD thesis
http://www.eecs.harvard.edu/~mdw/proj/seda/
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 45 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
NIO Model Is Effectively SEDA
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 46 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
“Registry” Support So far everything has been stored in a single XML file ¾Synapse.xml Hard to manage Also ¾Requirement to update the directives without restarting Synapse
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 47 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Registry Model A registry is just a remote (or local) source of XML files ¾No special APIs or models from the Synapse perspective A pluggable model for reading from a registry ¾Synapse ships with a URL based implementation
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 48 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc. Properties and Dynamic Properties Properties are just local configuration items Can be used to set up global configuration Dynamic properties are properties backed by a registry The values are cached and read from the registry ¾Allows sequences, endpoints and other config to be loaded dynamically
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 49 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Dynamic Property example XML file stored at http://mystore.wso2.com/endpoint.xml
synapse.xml
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 50 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
So What Do You Need? Anne Thomas Manes again: One or more service platforms (endpoints) A SOA management solution (mediation) A registry (metadata) An XML gateway if services will be exposed outside the firewall
Synapse can be both the XML Gateway and the SOA management solution
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 51 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Demo
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 52 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Web Publisher JMS Synapse Services ActiveMQ Tungsten
TCPMON
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 53 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc.
Status
Incubator in Apache since August 2005 ¾ All Apache Contributed code, core committer team M1 release – January 2006 ¾ Core function, HTTP Proxy support, XSLT, XPath M2 release – June 2006 ¾ Clean up of config language 0.90 release – soon! (we always say that) ¾ Proxy services ¾ Repackage as a MAR ¾ JavaScript/E4X support Looking to Graduate from incubation when Apache gives us the go-ahead
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 54 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc. Getting involved
HomeWiki / Home site http://wiki.apache.org/ws/Synapse http://incubator.apache.org/synapse/ SVN https://svn.apache.org/repos/asf/incubator/synapse/trunk/java Try it out ¾ http://incubator.apache.org/synapse/download/M2/download.cgi Submit bug reports ¾ http://issues.apache.org/jira/browse/SYNAPSE Join us [email protected] Submit use cases, bugs, ideas, or even code (but actually we’d prefer the former) Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 55 Colorado Software Summit: October 22 – 27, 2006 © Copyright 2006, WSO2 Inc. Questions
Paul Fremantle — Building an Enterprise Service Bus Using Web Services and Apache Synapse v2 Page 56