lightweight restful integration with mule€¦ · why do developers choose mule? no prescribed...

67
the open source choice for SOA infrastructure Lightweight RESTful Integration with Mule Dan Diephouse

Upload: others

Post on 24-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

the open source choice for SOA infrastructure

Lightweight RESTful Integration with

MuleDan Diephouse

Page 2: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

All contents Copyright ! 2008, MuleSource Inc. 2

SOA defined

Page 3: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

All contents Copyright ! 2008, MuleSource Inc. 3

SOA is dead?

Page 4: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Website

Service

Application

Library

All contents Copyright ! 2008, MuleSource Inc. 4

Page 5: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Crap to deal with when building services

Versioning

Coupling

Interoperability

Scalability

Infrastructure

All contents Copyright ! 2008, MuleSource Inc. 5

Page 6: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

REST: Loosely coupled

All contents Copyright ! 2008, MuleSource Inc. 6

Page 7: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

REST: Interoperability

All contents Copyright ! 2008, MuleSource Inc. 7

Page 8: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

REST: Scalability

All contents Copyright ! 2008, MuleSource Inc. 8

Page 9: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

!"#$%!&'()#*+,-./+*#0,+#/"")12

All contents Copyright ! 2008, MuleSource Inc. 9

Page 10: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

The magical mystery bus!

All contents Copyright ! 2008, MuleSource Inc. 10

Page 11: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

ESB

Routing

Transform-ations

Messaging

Queueing

Security

Transactions

All contents Copyright ! 2008, MuleSource Inc. 11

Page 12: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Why do developers choose Mule?

No prescribed message format3 XML, CSV, Binary, Streams, Record, Java Objects3 Mix and match

Zero code intrusion3 Mule does not impose an API on service objects3 Objects are fully portable

Existing objects can be managed3 POJOs, IoC Objects, EJB Session Beans, Remote Objects3 REST & Web Services

Easy to test3 Mule can be run easily from a JUnit test case3 Framework provides a Test compatibility kit3 Scales down as well as up

Page 13: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Mule Manufacturing Co.

All contents Copyright ! 2008, MuleSource Inc. 13

Page 14: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Service

Mule Services

All contents Copyright ! 2008, MuleSource Inc. 14

ComponentInbound

Endpoints

Outbound Routers

Page 15: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Core Concepts: Connectors

HTTP

JMS

FTP

TCP

UDP

LDAP

BPM

CXF

File

POP

SMTP

Multicast

VM

XMPP

WSDL

STDIO

All contents Copyright ! 2008, MuleSource Inc. 15

Page 16: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Core Concepts: Endpoints

Used to connect components and external systems together

Endpoints use a URI for Addressing

Can have transformer, transaction, filter, security and meta-information associated

Two types of URI

3 scheme://[username][:password]@[host][:port]

?[params]! smtp://ross:pass@localhost:25

3 scheme://[address]?[params]! jms://my.queue?persistent=true

Page 17: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Core Concepts: Routers

Control how events are sent and receivedCan model all routing patterns defined in the EIP BookInbound Routers3 Idempotency3 Selective Consumers3 Re-sequencing3 Message aggregation

Outbound Routers3 Message splitting / Chunking3 Content-based Routing3 Broadcasting3 Rules-based routing3 Load Balancing

Page 18: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Core Concepts: Transformers

Transformers3 Converts data from one format to another3 Can be chained together to form transformation pipelines

<jms:object-to-jms name="XmlToJms"/>

<custom-transformer name="CobolXmlToBusXml"

class="com.myco.trans.CobolXmlToBusXml"/>

<endpoint address="jms://trades"

transformers="CobolXmlToBusXml, XmlToJms"/>

Page 19: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Simple example

!"#$%&'#()*+#,-.#/0#$%&'#"-1

!&)/23)41

!&)/23)45#)462&)7(*44$#"",-87769::;2'*;82"79<=>?>-(((((((((((

"@)'8$2)23",-7$3#-(:1

!:&)/23)41

!237/23)41

!6*""578$23A85$237#$1

!237/23)45#)462&)7(*44$#"",-%+9::2$4#$B3#3#-:1

!:6*""578$23A85$237#$1

!:237/23)41

!:"#$%&'#1

All contents Copyright ! 2008, MuleSource Inc. 19

Page 20: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Simple example

!"#$%&'#()*+#,-.#/0#$%&'#"-1

!&)/23)41

!&)/23)45#)462&)7(*44$#"",!"#$%%&'()'*+)+),-----------

"@)'8$2)23",-7$3#-(

7$*)"C2$+#$5$#C",!D"%E2F$4#$G2H2!:1

!:&)/23)41

!'2+62)#)7(';*"",!.I@F$4#$0#$%&'#!%1

!:"#$%&'#1

All contents Copyright ! 2008, MuleSource Inc. 20

Page 21: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

BUILDING SERVICES

All contents Copyright ! 2008, MuleSource Inc. 21

Page 22: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Jersey

Annotations to expose your classes as a RESTful service

Implements the JAX-RS (JSR311) specification

Mule connector makes it possible to embed JAX-RS services in

Mule

All contents Copyright ! 2008, MuleSource Inc. 22

Page 23: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

JG*78K-:8#;;2.2$;4-L

63/;&' ';*"" M#;;2N2$;4O#"23$'# P

JQRE

JG$243'#I&+#K-7#S7:6;*&)-L

63/;&' 07$&)A("*@M#;;2N2$;4KL(P

$#73$) -M#;;2(N2$;4-T

U

U

All contents Copyright ! 2008, MuleSource Inc. 23

Page 24: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

JGF0E

JG$243'#"K-*66;&'*7&2):S+;-L(((

JD2)"3+#"K-*66;&'*7&2):S+;-L

63/;&' O#"62)"#(6;*'#F$4#$KF$4#$(2$4#$L(P

&)7 )3+/#$(,(A#7V#S7F$4#$V3+/#$KLT

.

WOX(;2'*7&2)(,(3$&X)C2YA#7Z/"2;37#G*78KL

Y$#"2;%#K-:2$4#$":- [()3+/#$LT

$#73$) O#"62)"#Y!"#$%#&'()!$%*)+,

Y#)7&7@K2$4#$L

Y/3&;4KLT

U

All contents Copyright ! 2008, MuleSource Inc. 24

Page 25: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

JQRE

JG$243'#"K-*66;&'*7&2):S+;-L

JG*78K-:P&4U-L

63/;&' F$4#$(A#7F$4#$KJG*78G*$*+K-&4-L(&)7 &4L(P

$#73$) 2$4#$"YA#7K&4LT

U

All contents Copyright ! 2008, MuleSource Inc. 25

Page 26: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Simple Service Configuration

!"#$%&'#()*+#,!2$4#$O#"23$'#-1

!&)/23)41

!&)/23)45#)462&)7(

*44$#"",-H#$"#@987769::;2'*;82"79<=>?\:2$4#$"-:1

!:&)/23)41

!'2+62)#)7(

';*"",-2$AY+3;#Y#S*+6;#"Y+CAYF$4#$O#"23$'#-:1

!:"#$%&'#1

All contents Copyright ! 2008, MuleSource Inc. 26

Page 27: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Why Jersey?

Very easy to build RESTful services inside Mule

Built in serialization support for

3 XML via JAXB

3 JSON

3 Images

3 Easily write your own serializers

All contents Copyright ! 2008, MuleSource Inc. 27

Page 28: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

INTEGRATING REST INTO YOUR MESSAGING LAYER

All contents Copyright ! 2008, MuleSource Inc. 28

Page 29: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Process flow

All contents Copyright ! 2008, MuleSource Inc. 29

Order

Resource

POST

Order

HTTP

responseInternal order

processing queue

Page 30: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

!"#$%&'#1

.

!]55 X"(78&"(*()#.(2$4#$^(XC("2_(&)&7&*7#(78#(/*'`#)4(

6$2'#""&)A(551

!C&;7#$&)A5$237#$1

!237/23)45#)462&)7(*44$#"",-./0112")!#334"&#"-15

!*)45C&;7#$1

!$#"7;#793$&57#+6;*7#5C&;7#$(

%#$/",-6478-92$%%#"+:-1)"&#"3-15

!#S6$#""&2)5C&;7#$(

#%*;3*72$,-;#$&#"-9#<2"#33*)+:-;%%2=3%$%>3:?@A-915

!:*)45C&;7#$1

!:C&;7#$&)A5$237#$1

!:"#$%&'#1

All contents Copyright ! 2008, MuleSource Inc. 30

Page 31: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Another example: URI template routing

!"#$%&'#()*+#,-.#/0#$%&'#"-1

!&)/23)41

!&)/23)45#)462&)7(*44$#"",-87769::;2'*;82"79<=>?>-(((((((((((

"@)'8$2)23",-7$3#-(:1

!:&)/23)41

!237/23)41

!C&;7#$&)A5$237#$1

!237/23)45#)462&)7(*44$#"",-%+9::2$4#$B3#3#-:1

!$#"7;#793$&57#+6;*7#5C&;7#$(6*77#$),-:2$4#$":P2$4#$X4U-:1

!:C&;7#$&)A5$237#$1

!C&;7#$&)A5$237#$1

!237/23)45#)462&)7(*44$#"",-%+9::3"#$B3#3#-:1

!$#"7;#793$&57#+6;*7#5C&;7#$(6*77#$),-:3"#$"-(:1

!:C&;7#$&)A5$237#$1

!:237/23)41

!:"#$%&'#1

All contents Copyright ! 2008, MuleSource Inc. 31

Page 32: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Modify messages while filtering!

!$#"7;#793$&57#+6;*7#5C&;7#$(

6*77#$),-:2$4#$X4:P"#758#*4#$Y2$4#$X4U-(:1

!$#"7;#793$&57#+6;*7#5C&;7#$(

6*77#$),-:2$4#$X4:P"#756*@;2*4Y2$4#$X4U-(:1

All contents Copyright ! 2008, MuleSource Inc. 32

Page 33: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Order Processing

All contents Copyright ! 2008, MuleSource Inc. 33

Order processing

queue

Warehouse availability

check

Log business events

Page 34: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Order Processing

!"#$%&'#()*+#,-)"&#"6")!#33*+B-5

!&)/23)41

!&)/23)45#)462&)7(*44$#"",-./0112")!#334"&#"-93C+!;")+)>3:-%">#-5

!#S6$#""&2)57$*)"C2$+#$1

!$#73$)5*$A3+#)7(#%*;3*72$,-;#$&#"-9#<2"#33*)+:-D#"3#C="#32)+3#-915

!:#S6$#""&2)57$*)"C2$+#$1

!#S6$#""&2)57$*)"C2$+#$1

!$#73$)5*$A3+#)7(#%*;3*72$,-B")).C-9#<2"#33*)+:-2$C()$&=#+%*%C-915

!:#S6$#""&2)57$*)"C2$+#$1

!:&)/23)45#)462&)71

!:&)/23)41(

/&+01&+2(3-.-/%&+01&+2(3

!:"#$%&'#1

All contents Copyright ! 2008, MuleSource Inc. 34

Page 35: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Order Processing

!"#$%&'#()*+#,-)"&#"6")!#33*+B-5

!&)/23)43./%&)/23)41

!237/23)41

!'8*&)&)A5$237#$1

!237/23)45#)462&)7(*44$#"",-./011E$"#;)>3#7#".*!#-15

!]55 G2"7(78&"(72(78#(Z72+G3/ #%#)7(;2A(551

!237/23)45#)462&)7

*44$#"",-;%%2011()!$(;)3%0F@@?1$%)/2>G-9===95

!:'8*&)&)A5$237#$1

!:237/23)41

!:"#$%&'#1

All contents Copyright ! 2008, MuleSource Inc. 35

Page 36: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Warehousing

!"#$%&'#()*+#,-E$"#;)>3#7#".*!#-5

!&)/23)41

!&)/23)45#)462&)7(*44$#"",-./011E$"#;)>3#7#".*!#-15

!&)/23)45#)462&)7(

*44$#"",-D#"3#C0;%%2011()!$(;)3%0F@@?1E$"#;)>3#-9

3C+!;")+)>3:!"#$%&11

!:&)/23)41

!'2+62)#)71

!"&)A;#72)52/H#'7(';*"",&'H$"#;)>3#7#".*!#-15

!:'2+62)#)71

!:"#$%&'#1

All contents Copyright ! 2008, MuleSource Inc. 36

Page 37: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Its just Java

63/;&' ';*"" N*$#823"#0#$%&'# P

63/;&' %2&4 $#a3#"7G*$7"KF$4#$(2$4#$L(P

.

U

U

All contents Copyright ! 2008, MuleSource Inc. 37

Page 38: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

ATOMPUB

All contents Copyright ! 2008, MuleSource Inc. 38

Page 39: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Consider using Atom Publishing Protocol

Atom: a format for syndication

3 4+*/,.5+*#6).*7*#"'#,+)07+8#.9'",:07."9;#3 a.k.a. feeds

3 Feeds are composed of entries

User Extensible

More generic than just blog stuff

Page 40: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Atom Publishing Protocol

RESTful protocol for building services

Create, edit, delete entries in a collection

Extensible Protocol

3 Paging extensions

3 GData

3 Opensearch

Properly uses HTTP so can be scalable, reliable and secure

Service

Workspaces

CollectionsEntries

< Entry Resource

Media Entries

< Media Link Entry< Media Resource

Page 41: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Why you should use APP for your app

Provides ubiquitous elements which have meaning across all

contexts

You can leverage existing solutions for security

3 HTTP Auth, WSSE, Google Login, XML Sig & Enc

Eliminates the need for you to write a lot of server/client code

3 ETags, URLs, etc are all handled for you

Integrates seamlessly with non-XML data

There are many APP implementations and they are known to

work well together

Page 42: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Eventing

Publish and consume entries which map to events

Application level events

3 Exceptions/fault monitoring

Business level events

3 A expense over $1000 was registered

Use query parameters to narrow down the criteria

Works with any client which understands Atom

Powerful combination with opensearch

Page 43: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Process

Order is placedIs order > $10,000

Log to business event

Atom store

All contents Copyright ! 2008, MuleSource Inc. 43

Page 44: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Abdera Concepts

Atom

Service

Workspace

Collection

Abdera

Provider

WorkspaceManager

CollectionAdapter

All contents Copyright ! 2008, MuleSource Inc. 44

Page 45: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

CollectionAdapters

Write your own

Built in CollectionAdapters

3 JCR

3 JDBC

3 Filesystem

All contents Copyright ! 2008, MuleSource Inc. 45

Page 46: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

!+3;#9"#$%&'# )*+#,-'3"72+#$0#$%&'#-1

!+3;#9&)/23)41

!+3;#9&)/23)45#)462&)7(*44$#"",-87769::;2'*;82"79b>>c-(

"@)'8$2)23",-7$3#-:1

!:+3;#9&)/23)41

!*/4#$*9'2+62)#)7 6$2%&4#$5$#C,!*/4#$*G$2%&4#$-:1

!:+3;#9"#$%&'#1

All contents Copyright ! 2008, MuleSource Inc. 46

Page 47: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

!*96$2%&4#$(&4,!*/4#$*G$2%&4#$-1

!*9.2$`"6*'#(7&7;#,!4")20-5&'6789:),1

!$#C(/#*),!H'$Z4*67#$!%1

!:*9.2$`"6*'#1

!:*96$2%&4#$1

All contents Copyright ! 2008, MuleSource Inc. 47

Page 48: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

JCR Store

!/#*)(&4,-D!"I&$2%#"-9

';*"",&'$G&#"$=2")%)!)(=3#".#"=$&$2%#"3=D!"=J!"K)((#!%*)+I&$2%#"-9

*+*%L/#%;)&:-*+*%*$(*M#-5

!6$26#$7@()*+#,-$>%;)"-9.$(>#:-N>(#-15

!6$26#$7@()*+#,-%*%(#-9.$(>#:-O.#+%9P>#>#-15

!6$26#$7@()*+#,-!)((#!%*)+Q)&#6$%;-9.$(>#:-#+%"*#3-15

!6$26#$7@()*+#,-"#2)3*%)"C-9"#R:-D!"S#2)3*%)"C-15

!6$26#$7@()*+#,-!"#&#+%*$(3-5

!/#*)(';*"",-D$.$<=D!"=7*/2(#K"#&#+%*$(3-5

!'2)"7$3'72$5*$A1!%*;3#13"#$)*+#!:%*;3#1!:'2)"7$3'72$5*$A1

!'2)"7$3'72$5*$A1!%*;3#16*"".2$4!:%*;3#1!:'2)"7$3'72$5*$A1

!:/#*)1

!:6$26#$7@1

!6$26#$7@()*+#,-;"#R-9.$(>#:-#.#+%3-15

!:/#*)1

All contents Copyright ! 2008, MuleSource Inc. 48

Page 49: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Creating Atom Entries

!]55 G2"7(78&"(72(78#(Z72+G3/ #%#)7(;2A(551

!237/23)45#)462&)7(*44$#"",-;%%2011()!$(;)3%0F@@?1$%)/2>G-5

!#S6$#""&2)5C&;7#$(#%*;3*72$,-B")).C-9

#<2"#33*)+:-2$C()$&=2"*!# 59A@@@@-15

!+#""*A#56$26#$7&#"57$*)"C2$+#$(1

!*445+#""*A#56$26#$7@(`#@,-K)+%#+%L8C2#-9

.$(>#:-$22(*!$%*)+1$%)/T</(U%C2#:#+%"C-15

!:+#""*A#56$26#$7&#"57$*)"C2$+#$1

!*/4#$*9#)7$@50'927;&'#)'-.3

!:237/23)45#)462&)71

All contents Copyright ! 2008, MuleSource Inc. 49

Page 50: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Transformers

63/;&' ';*"" R)7$@E$*)"C2$+#$ #S7#)4"

Z/"7$*'7E$*)"C2$+#$ P

JF%#$$&4#

6$27#'7#4 F/H#'7(42E$*)"C2$+K

F/H#'7("$'_(07$&)A(#)'24&)AL(

78$2." E$*)"C2$+#$RS'#67&2) P

.

U

U

All contents Copyright ! 2008, MuleSource Inc. 50

Page 51: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Transformers

F$4#$(2$4#$ ,(KF$4#$L("$'T

R)7$@(#)7$@ ,(C*'72$@Y)#.R)7$@KLT

#)7$@Y"#7E&7;#K-F$4#$(C2$(- [(2$4#$YA#7G$&'#KL([(

-(C$2+(- [(2$4#$YA#7D3"72+#$KLLT

#)7$@Y"#7X4KC*'72$@Y)#.W3&4W$&KLLT

#)7$@Y"#7D2)7#)7K-Z)(2$4#$(.*"(6;*'#4(C2$(- [(

2$4#$YA#7G$&'#KL([(-(C$2+(- [(

2$4#$YA#7D3"72+#$KLLT

#)7$@Y"#7W64*7#4K)#. d*7#KLLT

#)7$@Y*44Z3782$K-I3;#(ICA(D2+6*)@-LT

$#73$) #)7$@T

All contents Copyright ! 2008, MuleSource Inc. 51

Page 52: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

XML version

!*/4#$*9#)7$@5/3&;4#$57$*)"C2$+#$1

!*/4#$*9#)7$@56$26#$7@()*+#,-$>%;)"-9

#.$(>$%)":-3%"*+B-9#<2"#33*)+:-S)339N$3)+-15

!*/4#$*9#)7$@56$26#$7@()*+#,-!)+%#+%-9

#.$(>$%)":-2$C()$&-9#<2"#33*)+:--15

!*/4#$*9#)7$@56$26#$7@()*+#,-%*%(#-9

#.$(>$%)":-;#$&#"-9#<2"#33*)+:-%*%(#-15

!*/4#$*9#)7$@56$26#$7@()*+#,->2&$%#&-9

#.$(>$%)":-R>+!%*)+-9#<2"#33*)+:-+)E-15

!*/4#$*9#)7$@56$26#$7@()*+#,-*&-999

#.$(>$%)":-B")).C-9

#<2"#33*)+:-V>"+0>>*&0V9T9

D$.$=>%*(=WWXY="$+&)/WWXY',=%)7%"*+B',-15

!:*/4#$*9#)7$@5/3&;4#$57$*)"C2$+#$1

All contents Copyright ! 2008, MuleSource Inc. 52

Page 53: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

POLLING VS. MESSAGING

All contents Copyright ! 2008, MuleSource Inc. 53

Page 54: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

ETag Header

Resources may return an ETag header when it is accessed

On subsequent retrieval of the resource, Client sends this ETag

header back

If the resource has not changed (i.e. the ETag is the same), an

empty response with a 304 code is returned

Reduces bandwidth/latency

Page 55: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

ServerClient

Client Server

ETag Example

MEEG:\Y\(c>>(Fe(

<90)$-.

RE*A9(-=#?<5f\>5=gb<C//'-

D2)7#)75h#)A789(\>f>(

D2)7#)75E@6#9(7#S7:87+;

.

MEEG:\Y\(=>f(V27(I24&C&#4

<90)$-.

RE*A9(-=#?<5f\>5=gb<C//'-(

D2)7#)75=)2>0?$-@.

QRE(:C##4Y*72+

M2"79(...Y*'+#Y'2+

.

QRE(:C##4Y*72+

XC5V2)#5I*7'89(

-=#?<5f\>5=gb<C//'-

M2"79(...Y*'+#Y'2+

.

Page 56: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Client Server

LastModified Example

MEEG:\Y\(c>>(Fe(

<90)$-.

h*"75I24&C&#49(0*7_(cb(F'7(

\bbf(\b9f=9=\(QIE

D2)7#)75h#)A789(\>f>(

D2)7#)75E@6#9(7#S7:87+;

.

MEEG:\Y\(=>f(V27(I24&C&#4

<90)$-.

h*"75I24&C&#49(0*7_(cb(F'7(

\bbf(\b9f=9=\(QIE

D2)7#)75h#)A789(>

QRE(:C##4Y*72+

M2"79(...Y*'+#Y'2+

.

QRE(:C##4Y*72+

XC5I24&C&#450&)'#9(

0*7_(cb(F'7(\bbf(

\b9f=9=\(QIE

M2"79(...Y*'+#Y'2+

.

Page 57: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Process

Poll warehouse for part updates

Have the parts arrived?

Update status

All contents Copyright ! 2008, MuleSource Inc. 57

Page 58: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Wiring with XML

!8776962;;&)A5'2))#'72$(

)*+#,-6)((*+BZ%%2K)++#!%)"-9

62;;&)Ai$#a3#)'@,-[@@@@-9

!;#!\O%$B:-%">#-15

!"#$%&'#()*+#,-#.#+%K)+3>/#"-5

!&)/23)41

!&)/23)45#)462&)7(

*44$#"",-;%%2011()!$(;)3%0F@@?1E$"#;)>3#-9

!)++#!%)"L"#R:-6)((*+BZ%%2K)++#!%)"-15

!:&)/23)41

!:"#$%&'#1

All contents Copyright ! 2008, MuleSource Inc. 58

Page 59: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Is polling the answer?

Example from OSCON:

6=9#>()?#@A*7B#@CCDB#friendfeed crawled flickr 2.9 million times to

get the latest photos of 45,754 users, of which 6,721 of that

45,754 potentially (E)"08+8#0#EF"7"2;

Page 60: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Frequent updates are common

Flickr

Blogs

Twitter

Business events

Presence on IM

Stock data

Page 61: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Is messaging the answer?

Messaging is asynchronous

4"+*9G7#E(7#(98(+#)"08#"9#7F+#*+,-+,#098#7F+#/).+97

Page 62: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

!"#$%&'"()*+",&-".&Flickr/Friendfeed

Page 63: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Lookup service

http://example.com/_2008/09/03/users?{userid}

Returns coordinate in sparse array

Page 64: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Leaves us with

Periodic poll (every minute or so) with a 1KB response (1440

times/day)

6700 GETs for new pictures

A GET for every time a user signs up

Page 65: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

In contrast to

6700 XMPP messages per day

6700 GETs for new pictures

Maintenance of new infrastructure

Page 66: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Conclusions

Services are hard!

In the long run, REST helps you

Getting away from the edges, Mule can help

Abdera, Jersey and Restlet are cool

Mule has a bunch of other tools to help you too

All contents Copyright ! 2008, MuleSource Inc. 66

Page 67: Lightweight RESTful Integration with Mule€¦ · Why do developers choose Mule? No prescribed message format 3 XML, CSV, Binary, Streams, Record, Java Objects 3 Mix and match Zero

Questions?

http://mulesource.com

http://mule.mulesource.org/display/MULE/MULE+RESTpack

My Blog: http://netzooid.com/blog

Twitter: dandiep

[email protected]

All contents Copyright ! 2008, MuleSource Inc. 67