integration & dsl

37
Integration & DSL #TDC2011

Upload: alexandre-porcelli

Post on 15-May-2015

1.380 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Integration & DSL

Integration

&

DSL#TDC2011

Page 2: Integration & DSL

Alexandre Porcelli

Writer

Alexandre Porcelli

Organizer

Alexandre Porcelli

Commiter / Parser Developer

Alexandre Porcelli

Founder

Alexandre PorcelliAPI Designer / Developer

@porcelli

Page 3: Integration & DSL

integration

Page 4: Integration & DSL
Page 5: Integration & DSL
Page 6: Integration & DSL

THE reference

Page 7: Integration & DSL

cloud

Page 8: Integration & DSL

problems...

Page 9: Integration & DSL

silos

Page 10: Integration & DSL

3443

Page 11: Integration & DSL
Page 12: Integration & DSL

#facts

✓ #1 OPEN SOURCE ESB✓ OVER 1.5 MILLION DOWNLOADS✓ 2500+ PRODUCTION DEPLOYMENTS✓ PERFORMANCE: 10000 TPS✓ SCALABLE: 13000 DEPLOYED SERVERS✓ 100+ CONNECTORS APPS & PROTOCOLS✓ CLOUD CONNECTORS

Page 13: Integration & DSL

enterprise...

High-performance ESB

Access to source code

Community extensions

Management Console

High availability

Premium Connectors

Self-healing connections

Technical Support

Knowledge Base

Service packs / hot patches

QA

Enterprise documentation

Enterprise license

Mule ESBCommunity

Mule ESBEnterprise

Page 14: Integration & DSL

customers...

Page 15: Integration & DSL

mule studio!

Page 16: Integration & DSL

tech spec...

Page 17: Integration & DSL

cloud connectors...

Page 18: Integration & DSL

POJO!@Connector(namespacePrefix="my-push")public class MyPushCloudConnector { /** * Hostname of My Push Notification Gateway */ @Property private String host;

@Operation public void send(String deviceToken, @Parameter(optional=true)

String alert, @Parameter(optional=true) String sound, @Parameter(optional=true, defaultValue="-1") int badge, @Parameter(optional=true) Map<String,String> fields) {

... }}

Page 19: Integration & DSL
Page 20: Integration & DSL
Page 21: Integration & DSL

<flow name="Hello World"> <composite-source> <!-- Incoming HTTP requests --> <inbound-endpoint address="http://localhost:8888" transformer-refs="HttpRequestToNameString" exchange-pattern="request-response"> <not-filter> <wildcard-filter pattern="/favicon.ico"/> </not-filter> </inbound-endpoint>

<!-- Incoming Servlet requests --> <inbound-endpoint address="servlet://name" transformer-refs="HttpRequestToNameString" exchange-pattern="request-response"> <not-filter> <wildcard-filter pattern="/favicon.ico"/> </not-filter> </inbound-endpoint>

<!-- Incoming VM requests --> <vm:inbound-endpoint path="greeter" transformer-refs="StringToNameString" exchange-pattern="request-response"/> </composite-source>

<component class="org.mule.example.hello.Greeter"/>

<choice> <when expression="payload instanceof org.mule.example.hello.NameString" evaluator="groovy"> <vm:outbound-endpoint path="chitchatter" exchange-pattern="request-response"/> </when> <when expression="payload instanceof java.lang.Exception" evaluator="groovy"> <vm:outbound-endpoint path="userErrorHandler" exchange-pattern="request-response"/> </when> </choice>

<!-- Route unexpected errors to separate error handler --> <default-exception-strategy> <vm:outbound-endpoint path="systemErrorHandler" exchange-pattern="one-way"/> </default-exception-strategy> </flow>

Page 22: Integration & DSL

xml?

Page 23: Integration & DSL
Page 24: Integration & DSL

so what?

Page 25: Integration & DSL
Page 26: Integration & DSL

MuleContex context = Mule.newMuleContext();

Flow myFlow = new Flow();

myFlow.setName("MyFlow");

InboundEndpoint myIn = new GenericInboundEndpoint();myIn.setURL("file:///Users/porcelli/in");

OutboundEndpoint myOut = new GenericOutboundEndpoint();myIn.setURL("file:///Users/porcelli/out");

myFlow.setInbound(myIn);myFlow.addMessageProcessor(myOut);

context.addFlow(myFlow);

muleContext.start(); ok?

Page 27: Integration & DSL

NO!

Page 28: Integration & DSL

DSL!

Page 29: Integration & DSL

➡ Expressive & Natural➡ Easy to Use & Learn➡ Hard to Misuse➡ Extensible

goals...

Page 30: Integration & DSL

Mule.newMuleContext(new AbstractModule() { @Override public void configure() { flow("MyFlow") .from("file:///Users/porcelli/in") .send("file:///Users/porcelli/out"); } }).start();

Page 31: Integration & DSL

MuleContex context = Mule.newMuleContext();

Flow myFlow = new Flow();

myFlow.setName("MyFlow");

InboundEndpoint myIn = new GenericInboundEndpoint();myIn.setURL("file:///Users/porcelli/in");

OutboundEndpoint myOut = new GenericOutboundEndpoint();myIn.setURL("file:///Users/porcelli/out");

myFlow.setInbound(myIn);myFlow.addMessageProcessor(myOut);

context.addFlow(myFlow);

muleContext.start();

remember?

Page 32: Integration & DSL

feedback?

Page 33: Integration & DSL

cloud...

final TwitterConnector twitterConnector = new TwitterConnector();twitterConnector.setConsumerKey("key");twitterConnector.setConsumerSecret("secret");twitterConnector.setOathToken("token");

Mule.newMuleContext(new AbstractModule() { @Override public void configure() { flow("MyFlow") .from("file:///Users/porcelli/tweet") .transformTo(String.class) .process(twitterConnector.statusesUpdate(payload())); }}).start();

Page 34: Integration & DSL

demo

Page 35: Integration & DSL
Page 36: Integration & DSL

questions?