0
Taking Mule 3 for a Ride!
                Ross Mason!
What is Mule?!




All contents Copyright © 2009, MuleSoft Inc.                    2
Not a donkey!




All contents Copyright © 2009, MuleSoft Inc.   3
Not a llama!




All contents Copyright © 2009, MuleSoft Inc.   4
Not a camel!




All contents Copyright © 2009, MuleSoft Inc.   5
BaaS: Beer As A Service!

All contents Copyright © 2009, MuleSoft Inc.            6
BaaS!




All contents Copyright © 2009, MuleSoft Inc.   7
BaaS!




All contents Copyright © 2009, MuleSoft Inc.   8
BaaS!




All contents Copyright © 2009, MuleSoft Inc.   9
Mule Platform!




Connectivity!

                    Messaging!           Cloud Connect
                                 ...
AJAX – Hook the ESB to the Browser!




                     !   Real time events to the Browser!
                     !  ...
AJAX – Hook the ESB to the Browser!

      Mule Config (Server)!
 <ajax:connector name="ajax" serverUrl="http://localhost:8...
Cloud Connect!




                      !   Integrate with stuff on the net!
                              –  Grab data f...
Cloud Connect!




All contents Copyright © 2009, MuleSoft Inc.   14
Cloud Connect !



                                               Inject an Amazon S3
                                    ...
Mule Flow!




                     !   Fluid DSL for creating message flows!
                     !   Fixes the ʻSʼ in SOA...
<flow>!




Inbound!
                         Transformer!            Filters!   Routers!   Anything…!
Endpoint!




  All ...
<flow> intro!




<flow name=“BeerAsAService">
  <inbound-endpoint address="http://localhost:9090/brew"
                   ...
<choice>!




<flow name=“BeerAsAService">
  <inbound-endpoint address="http://localhost:9090/brew"
                     e...
<async>!




<flow name="BeerAsync">
    <inbound-endpoint address="http://localhost:9090/async"
                       ex...
<all>!




<flow name=“NotifyStaffDrinkers">
  <inbound-endpoint address="http://localhost:9090/all"
exchange-pattern="req...
Composable, reusable!




<flow name="CustomMP">
    <inbound-endpoint
        address="http://localhost:9090/custom-mp"
 ...
<service> still supported! 

                           But, compare to Mule 2.x...
                                      ...
Loanbroker: Service vs Flow!


      <!--
      The loan broker is used to receive loan requests
      -->
      <service ...
Mule Patterns!




                     !   Bigger Building Blocks!
                             –  A level above EIP!
   ...
Patterns – Simple Service!


 Use Case: Using Mule as a deployment platform for business
 services.!




                 ...
Pattern - Web-Service Proxy!


   Use Case: !
   •     Exposes an external web-service internally, while optionally perfor...
Pattern - Web-Service Proxy in Mule 2!


<spring:bean name="WSProxyService"
   class="org.mule.transport.soap.WSProxyServi...
Pattern - Web-Service Proxy!




All contents Copyright © 2009, MuleSoft Inc.   29
Pattern - Web-Service Proxy!




<mulexml:xslt-transformer
     name="v1-to-v2"
     xsl-file="v1-to-v2.xsl"/>
<mulexml:xs...
Pattern - Bridge!


 Use Case: Transactional synchronous bridge, for example: JMS bridging (topic to queue)!




<bridge
 ...
REST!




                        !   Uses Jersey!
                                –  JAX-RS reference implementation!
   ...
REST: Why Jersey in Mule?!




!   Wrap in a transaction, send off to JMS!
!   Implement custom routing rules based on URL...
Service Class!


@Path("/")
public class BeerOnDemand
{
    @POST
    @Consumes({ "application/json" })
    @Produces({ "a...
Jersey Resources!




<flow name="BeerAsARestService">
    <inbound-endpoint address="http://localhost:9090/jersey"/>
    ...
Easy REST client with JSON!




<flow name="OrderPlacer">
      …
    <json:object-to-json />
    <response>
        <json...
On the wire!



Object!                                            JSON!


public class Order {
      private String      ...
Web Services!




                     !   Web Services are a PITA!
                             –  Mule 3 makes them easi...
Hosting web services!




<flow name="BeerAsAWebService">
    <inbound-endpoint address="http://localhost:9090/ws"/>
    <...
Web Services: Improved XML configuration!




    <simple-
    service>!        •  POJO based web service!


              ...
Web Services: Improved XML configuration!




                 •  POJO based client using
<simple-client>!
                ...
Flexible, Scriptable!




<flow name="BeerAsAWebService">
  <inbound-endpoint address="http://localhost:9090/ws-async"/>
 ...
How does this all work?!

MESSAGE PROCESSORS!


All contents Copyright © 2009, MuleSoft Inc.   43
Message Processors and Flows!




                                           Filter!      Component!




      Transformer...
Custom MPs!




<flow name=“BeerAsAService">
    <inbound-endpoint address="http://localhost:9090/brew"/>
    <custom-proc...
For example….!




public class BrewerMessageProcessor
    implements MessageProcessor
{
    public MuleEvent process(Mule...
For example….!



public class BrewerMessageProcessor
    extends AbstractInteceptingMessageProcessor
{
    public MuleEve...
Moving in when the time is right!

HOT DEPLOYMENT!


All contents Copyright © 2009, MuleSoft Inc.   48
!   Pragmatic!
!   #NoOSGi!
!   Not another app server!




All contents Copyright © 2009, MuleSoft Inc.   49
Applications are zips!




!   Apps are zips or exploded directories!
!   By convention: most parts are optional!




All ...
Deployment Descriptor!




!   domain!
!   config.resources!
!   redeployment.enabled!
!   encoding!
!   config.builder!



...
Maven Plugin!




<project>
...
    <packaging>mule</packaging>
...
</project>




All contents Copyright © 2009, MuleSoft...
Questions?


                                     web: http://mulesoft.org

                                      twitter:...
Upcoming SlideShare
Loading in...5
×

Take Mule 3 For A Ride

12,021

Published on

Walks through some of the new features of Mule 3 including cloud connect, Flow, AJAX and JavaScript support, REST and Web Services and the new deployment model

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
12,021
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
510
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide
  • I hear mules are much more reliable than camels
  • Error handling
  • Transcript of "Take Mule 3 For A Ride"

    1. 1. Taking Mule 3 for a Ride! Ross Mason!
    2. 2. What is Mule?! All contents Copyright © 2009, MuleSoft Inc. 2
    3. 3. Not a donkey! All contents Copyright © 2009, MuleSoft Inc. 3
    4. 4. Not a llama! All contents Copyright © 2009, MuleSoft Inc. 4
    5. 5. Not a camel! All contents Copyright © 2009, MuleSoft Inc. 5
    6. 6. BaaS: Beer As A Service! All contents Copyright © 2009, MuleSoft Inc. 6
    7. 7. BaaS! All contents Copyright © 2009, MuleSoft Inc. 7
    8. 8. BaaS! All contents Copyright © 2009, MuleSoft Inc. 8
    9. 9. BaaS! All contents Copyright © 2009, MuleSoft Inc. 9
    10. 10. Mule Platform! Connectivity! Messaging! Cloud Connect ! Database! FTP/File! Applications ! Data Feeds ! Container! Services! Bindings: REST, WS! Flow! Transform! Patterns ! JSON/XML ! AJAX / JS! Core ! Platform! Security ! Error Handling! Routing! SEDA Engine! Deployment ! Scheduling! All contents Copyright © 2009, MuleSoft Inc. 10
    11. 11. AJAX – Hook the ESB to the Browser! !   Real time events to the Browser! !   Trigger ESB events from the Browser! AJAX / JS! !   Simple Set up, no need for App Server! !   JSON Support! –  Object Binding! –  Transformers! –  Query Language! !   JavaScript client for Mule ESB! All contents Copyright © 2009, MuleSoft Inc. 11
    12. 12. AJAX – Hook the ESB to the Browser! Mule Config (Server)! <ajax:connector name="ajax" serverUrl="http://localhost:8081/foo”/> <flow name=”AjaxService"> <vm:inbound-endpoint path="in"/> <component class="org.foo.MyComponent"/> <ajax:outbound-endpoint channel="/test"/> </flow>! Mule JS Client (Browser)! All contents Copyright © 2009, MuleSoft Inc. 12
    13. 13. Cloud Connect! !   Integrate with stuff on the net! –  Grab data from SaaS platforms! Cloud Connect ! –  Utilise infrastructure Services! –  Connect to Social Media platforms! !   Uses IBeans (open source project)! –  Provide a strongly typed interface to a service! !   Support for REST and Web Services! !   Data bindings using XML and JSON! All contents Copyright © 2009, MuleSoft Inc. 13
    14. 14. Cloud Connect! All contents Copyright © 2009, MuleSoft Inc. 14
    15. 15. Cloud Connect ! Inject an Amazon S3 Integration Bean! Pass in your S3 ! credentials! Create a new bucket store on S3! All contents Copyright © 2009, MuleSoft Inc. 15
    16. 16. Mule Flow! !   Fluid DSL for creating message flows! !   Fixes the ʻSʼ in SOA! Flow! –  Easier to think about what rather than how! !   Mix and match routing, transforms, components! !   Much less configuration than Mule 2! All contents Copyright © 2009, MuleSoft Inc. 16
    17. 17. <flow>! Inbound! Transformer! Filters! Routers! Anything…! Endpoint! All contents Copyright © 2009, MuleSoft Inc. 17
    18. 18. <flow> intro! <flow name=“BeerAsAService"> <inbound-endpoint address="http://localhost:9090/brew" exchange-pattern="request-response"/> <append-string-transformer message="Ordering, "/> <append-string-transformer message="Brewing me some beer, "/> <append-string-transformer message="Shipping"/> </flow> Result: Ordering, Brewing me some beer, Shipping All contents Copyright © 2009, MuleSoft Inc. 18
    19. 19. <choice>! <flow name=“BeerAsAService"> <inbound-endpoint address="http://localhost:9090/brew" exchange-pattern="request-response"/> <choice> <when expression="#[groovy:payload == 'IPA']"> <append-string-transformer message="Using recipe with extra hops, "/> </when> <otherwise> <append-string-transformer message="Using normal recipe, "/> </otherwise> </choice> … </flow> All contents Copyright © 2009, MuleSoft Inc. 19
    20. 20. <async>! <flow name="BeerAsync"> <inbound-endpoint address="http://localhost:9090/async" exchange-pattern="request-response"/> <append-string-transformer message="Ordering, "/> <append-string-transformer message="Brewing me some beer, "/> <async> <expression-transformer> <return-argument expression="'Drinking me some beer'" evaluator=”string"/> </expression-transformer> <stdio:outbound-endpoint system="OUT" /> </async> <append-string-transformer message="Shipping"/> </flow> All contents Copyright © 2009, MuleSoft Inc. 20
    21. 21. <all>! <flow name=“NotifyStaffDrinkers"> <inbound-endpoint address="http://localhost:9090/all" exchange-pattern="request-response"/> <append-string-transformer message="Ordering, "/> <append-string-transformer message="Brewing me some beer, "/> <all> <outbound-endpoint address="vm://staffDrinker1"/> <outbound-endpoint address="vm://staffDrinker2"/> </all> <append-string-transformer message="Shipping"/> </flow> All contents Copyright © 2009, MuleSoft Inc. 21
    22. 22. Composable, reusable! <flow name="CustomMP"> <inbound-endpoint address="http://localhost:9090/custom-mp" exchange-pattern="request-response"/> <append-string-transformer message="Ordering, "/> <flow-ref name="Brewing"/> <append-string-transformer message="Shipping"/> </flow> <flow name="Brewing"> <!-- Do brewing --> <append-string-transformer message="Brewing me some beer, "/> </flow> All contents Copyright © 2009, MuleSoft Inc. 22
    23. 23. <service> still supported! 
 But, compare to Mule 2.x... ! All contents Copyright © 2009, MuleSoft Inc. 23
    24. 24. Loanbroker: Service vs Flow! <!-- The loan broker is used to receive loan requests --> <service name="TheLoanBroker"> <inbound> <inbound-endpoint ref="CustomerRequests"/> </inbound> <component class="org.mule.example.loanbroker.esn.SynchronousLoanBroker"> <binding interface="org.mule.example.loanbroker.credit.CreditAgencyService"> <outbound-endpoint ref="CreditAgency"/> </binding> </component> <outbound> <pass-through-router> <outbound-endpoint ref="LenderService"/> </pass-through-router> </outbound> <async-reply timeout="1000000"> <inbound-endpoint ref="LoanBrokerQuotes"/> <custom-async-reply-router class="org.mule.example.loanbroker.routers.BankQuotesResponseAggregator"/> </async-reply> <flow name="loan-broker"> </service> <inbound-endpoint ref="CustomerRequests" exchange-pattern="request-response" /> <component class="org.mule.example.loanbroker.esn.SynchronousLoanBroker"> <!-- <binding interface="org.mule.example.loanbroker.credit.CreditAgencyService"> The credit agency service will get the credit profile for a customer <outbound-endpoint ref="CreditAgency" exchange-pattern="request-response" /> --> </binding> <service name="TheCreditAgencyService"> </component> <inbound> <component class="org.mule.example.loanbroker.lender.DefaultLender" /> <inbound-endpoint ref="CreditAgencyIn"/> <expression-filter expression="payload.lenders.endpoint!=null" evaluator="groovy" /> </inbound> <request-reply timeout="10000"> <component class="org.mule.example.loanbroker.credit.DefaultCreditAgency"/> <recipient-list evaluator="groovy" expression="payload.lenders.endpoint"/> </service> <inbound-endpoint ref="LoanBrokerQuotes"> <custom-aggregator class="org.mule.example.loanbroker.routers.BankQuotesResponseAggregator" /> <!-- </inbound-endpoint> The Lender service is used to determine which banks to contact for a quote </request-reply> --> </flow>! <service name="TheLenderService"> <inbound> <inbound-endpoint ref="LenderService"/> </inbound> <component class="org.mule.example.loanbroker.lender.DefaultLender"/> <outbound> <pass-through-router> <outbound-endpoint ref="BankGateway" transformer-refs="SetLendersAsRecipients"/> </pass-through-router> </outbound> </service> <service name="TheBankGateway"> <inbound> <inbound-endpoint ref="BankGateway"/> <forwarding-router/> </inbound> <outbound> <static-recipient-list-router> <reply-to address="LoanBrokerQuotes"/> <message-property-filter pattern="recipients!=null"/> </static-recipient-list-router> <logging-catch-all-strategy/> </outbound> </service>! All contents Copyright © 2009, MuleSoft Inc. 24
    25. 25. Mule Patterns! !   Bigger Building Blocks! –  A level above EIP! Patterns ! !   Reduces the amount of Config! !   Built in the Core of Mule! –  Users can add their own! –  Can be abstract! !   Good for working with external Teams! All contents Copyright © 2009, MuleSoft Inc. 25
    26. 26. Patterns – Simple Service! Use Case: Using Mule as a deployment platform for business services.! Configured with JAX-RS annotations! Create a JAX-RS service, also supports JAX-WS! All contents Copyright © 2009, MuleSoft Inc. 26
    27. 27. Pattern - Web-Service Proxy! Use Case: ! •  Exposes an external web-service internally, while optionally performing transformations on the SOAP envelope.! •  Supports WSDL proxying (with rewriting of the port address component) and overriding (with usage of a provided WSDL).! <ws:proxy name="beer-ws-proxy“ inboundAddress="http://localhost/beer-ws" outboundAddress="http://nogne-o.com/beer-ws" wsdlFile="localWsdl.wsdl" /> All contents Copyright © 2009, MuleSoft Inc. 27
    28. 28. Pattern - Web-Service Proxy in Mule 2! <spring:bean name="WSProxyService" class="org.mule.transport.soap.WSProxyService"> <spring:property name="wsdlFile" value="localWsdl.wsdl"/> </spring:bean> <service name="httpWebServiceProxy"> <inbound> <inbound-endpoint address="http://localhost:8080/my/service" synchronous="true"/> </inbound> <component> <spring-object bean="WSProxyService" /> </component> <outbound> <pass-through-router> <outbound-endpoint address=http://acme.come/remote/web/service synchronous="true"/> </pass-through-router> </outbound> </service> All contents Copyright © 2009, MuleSoft Inc. 28
    29. 29. Pattern - Web-Service Proxy! All contents Copyright © 2009, MuleSoft Inc. 29
    30. 30. Pattern - Web-Service Proxy! <mulexml:xslt-transformer name="v1-to-v2" xsl-file="v1-to-v2.xsl"/> <mulexml:xslt-transformer name="v2-to-v1" xsl-file="v2-to-v1.xsl"/> <ws:proxy name="beer-ws-proxy“ inboundAddress="http://localhost/beer-ws" outboundAddress="http://nogne-o.com/beer-ws" transformer-refs="v2-to-v1" responseTransformer-refs="v1-to-v2” wsdlFile=”beer.wsdl" /> All contents Copyright © 2009, MuleSoft Inc. 30
    31. 31. Pattern - Bridge! Use Case: Transactional synchronous bridge, for example: JMS bridging (topic to queue)! <bridge name="transacted-bridge" transacted="true" inboundAddress=”wmq://test.In" outboundAddress="jms://test.Out" /> All contents Copyright © 2009, MuleSoft Inc. 31
    32. 32. REST! !   Uses Jersey! –  JAX-RS reference implementation! REST, WS! !   Build correct RESTful services! !   Lightweight, easy to use! All contents Copyright © 2009, MuleSoft Inc. 32
    33. 33. REST: Why Jersey in Mule?! !   Wrap in a transaction, send off to JMS! !   Implement custom routing rules based on URLs! !   Mule security! !   Easily transform old versions! All contents Copyright © 2009, MuleSoft Inc. 33
    34. 34. Service Class! @Path("/") public class BeerOnDemand { @POST @Consumes({ "application/json" }) @Produces({ "application/json" }) public OrderStatus order(Order order) { // return a status return …; } @GET @Produces({ "application/json" }) public String brew() { return "Brewing!"; } } All contents Copyright © 2009, MuleSoft Inc. 34
    35. 35. Jersey Resources! <flow name="BeerAsARestService"> <inbound-endpoint address="http://localhost:9090/jersey"/> <jersey:resources> <component class="com.mulesoft.beer.BeerOnDemand"/> <component class="com.mulesoft.beer.CustomerPortal"/> </jersey:resources> </flow> All contents Copyright © 2009, MuleSoft Inc. 35
    36. 36. Easy REST client with JSON! <flow name="OrderPlacer"> … <json:object-to-json /> <response> <json:json-to-object returnClass="com.mulesoft.beer.Order" /> </response> <outbound-endpoint address="http://localhost:9090/rest-beer"/> </flow> All contents Copyright © 2009, MuleSoft Inc. 36
    37. 37. On the wire! Object! JSON! public class Order { private String { customer; “customer” : “Dan” private intcases; “cases” : 300 } } All contents Copyright © 2009, MuleSoft Inc. 37
    38. 38. Web Services! !   Web Services are a PITA! –  Mule 3 makes them easier! REST, WS! !   Host and Consume Web services! !   Decoupled Transport from Protocol! –  Receive / Send over JMS, email, etc! !   JAX-WS or Simple! !   Easy to Proxy and modify! All contents Copyright © 2009, MuleSoft Inc. 38
    39. 39. Hosting web services! <flow name="BeerAsAWebService"> <inbound-endpoint address="http://localhost:9090/ws"/> <cxf:jaxws-service serviceClass="com.mulesoft.beer.BeerOnDemand"/> <component class="com.mulesoft.beer.BeerOnDemand"/> </flow> All contents Copyright © 2009, MuleSoft Inc. 39
    40. 40. Web Services: Improved XML configuration! <simple- service>! •  POJO based web service! •  JAX-WS & JAXB web <jaxws-service>! service! •  Configures XML proxy! <proxy-service>! •  payload = envelope/body!
    41. 41. Web Services: Improved XML configuration! •  POJO based client using <simple-client>! service interface! <jaxws-client>! •  JAX-WS Generated client! •  Configures XML proxy client! <proxy-client>! •  payload = envelope/body!
    42. 42. Flexible, Scriptable! <flow name="BeerAsAWebService"> <inbound-endpoint address="http://localhost:9090/ws-async"/> <cxf:jaxws-service serviceClass="com.mulesoft.beer.BeerOnDemand"/> <expression-transformer> <return-argument expression="'Processing ' + payload[0] + ' orders'" evaluator="groovy"/> </expression-transformer> </flow> All contents Copyright © 2009, MuleSoft Inc. 42
    43. 43. How does this all work?! MESSAGE PROCESSORS! All contents Copyright © 2009, MuleSoft Inc. 43
    44. 44. Message Processors and Flows! Filter! Component! Transformer! Router! Endpoint! Message Flow! Processor! All contents Copyright © 2009, MuleSoft Inc. 44
    45. 45. Custom MPs! <flow name=“BeerAsAService"> <inbound-endpoint address="http://localhost:9090/brew"/> <custom-processor class="com.mulesoft.beer.BrewerMessageProcessor"/> </flow> All contents Copyright © 2009, MuleSoft Inc. 45
    46. 46. For example….! public class BrewerMessageProcessor implements MessageProcessor { public MuleEvent process(MuleEvent event) throws MuleException { event.getMessage().setPayload( "Yup, fermentin' me some beer."); return event; } } All contents Copyright © 2009, MuleSoft Inc. 46
    47. 47. For example….! public class BrewerMessageProcessor extends AbstractInteceptingMessageProcessor { public MuleEvent process(MuleEvent event) throws MuleException { event.getMessage().setPayload( "Yup, fermentin' me some beer."); MuleEvent response = processNext(event); event.getMessage().setPayload( “300 cases brewed."); return respones; } } All contents Copyright © 2009, MuleSoft Inc. 47
    48. 48. Moving in when the time is right! HOT DEPLOYMENT! All contents Copyright © 2009, MuleSoft Inc. 48
    49. 49. !   Pragmatic! !   #NoOSGi! !   Not another app server! All contents Copyright © 2009, MuleSoft Inc. 49
    50. 50. Applications are zips! !   Apps are zips or exploded directories! !   By convention: most parts are optional! All contents Copyright © 2009, MuleSoft Inc. 50
    51. 51. Deployment Descriptor! !   domain! !   config.resources! !   redeployment.enabled! !   encoding! !   config.builder! All contents Copyright © 2009, MuleSoft Inc. 51
    52. 52. Maven Plugin! <project> ... <packaging>mule</packaging> ... </project> All contents Copyright © 2009, MuleSoft Inc. 52
    53. 53. Questions?
 web: http://mulesoft.org
 twitter: @rossjmason
 email: ross@mulesoft.com ! All contents Copyright © 2009, MuleSoft Inc. 53
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×