0
Building Asynchronous
Services with SCA

Mike Edwards
Raymond Feng
Luciano Resende
Agenda
>   Service Component Architecture
>   Why Asynchronous Services?
>   Facilities for Async Services
>   SCA support...
What SCA is
  >   executable model for assembling services
       ●   composites provide language to compose and
         ...
SCA Overview
Service Interface                                                                           Reference Interfa...
Why SCA makes life simpler
  >   One way to look at SCA is that it takes details of
       ●   access methods and endpoint...
Why SCA makes life simpler
  >   SCA gives developers
      single programming model for using services
      for all aspe...
Service Component Architecture (SCA):
Simplified Programming Model for SOA
 >   model for:
 >   building service component...
Agenda
>   Service Component Architecture
>   Why Asynchronous Services?
>   Facilities for Async Services
>   SCA support...
Asynchronous interactions
  >   Typical in business processes
  >   …not everything happens immediately
  >   …a single re...
Synchronous Processing
                            Price of IBM stock?



           IBM = $121.50


                     ...
Asynchronous Processing
                     Order Books X, Y, Z



           Acknowledge, OrderID = 3824




           ...
Why Asynchronous Services?
>   Business processes involve long running
    multi-step sequences
>   Clients & Services can...
Agenda

>   Service Component Architecture
>   Why Asynchronous Services?
>   Facilities for Async Services
>   SCA suppor...
Synchronous Services
>   plenty of support for synchronous
    programming
>   call-and-return typical for most
    progra...
Asynchronous Services
>   Facilities less common
     ●   JavaTM concurrency classes
     ●   JAX-WS asynchronous client
 ...
JAX-WS Async Client API
    SearchResponse search(SearchRequest sRequest );




    Future<?> searchAsync(SearchRequest oR...
JMS/Messaging
>   Supports async clients and async services



          Client                                           ...
BPEL and Async Processing
>   BPEL designed to handle:
     ●   long running processes
     ●   with asynchrony
     ●   m...
Agenda

>   Service Component Architecture
>   Why Asynchronous Services?
>   Facilities for Async Services
>   SCA suppor...
SCA Service Interaction

                                                          AccountData
   TripCataclog            ...
SCA Callbacks
>   SCA supports Async services using Callbacks
     ●   service has regular forward call interface
     ●  ...
Sync and Async Interfaces
public interface SyncSearchService {
    public SearchResponse search( SearchRequest sRequest );...
Callback Interfaces
>   Callback interface
     ●   may have multiple operations/methods
     ●   operations may be called...
Bidirectional Service Interaction
•   The reference creates a callback endpoint to
    receive callbacks
•   The service e...
Agenda

>   Service Component Architecture
>   Why Asynchronous Services?
>   Facilities for Async Services
>   SCA suppor...
Bidirectional Interface
•   Forward Interface
        @Remotable
        @Callback(SearchCallback.class)
        public in...
Trip Async Search
                                                 AccountData
                           Callback        ...
Flight Service implementation
import org.osoa.sca.annotations.*;
public class FlightImpl implements Search, Book {

    @C...
Catalog client application
 import org.osoa.sca.annotations.*;
 public class TravelCatalogImpl implements TravelCatalogSea...
Composite
<component name="TravelCatalogComponent">
        <implementation.java class="scatours.travelcatalog.TravelCatal...
"under the hood"
>   How do the callbacks work in practice?
     ●   implemented using suitable
         communication met...
Agenda

>   Service Component Architecture
>   Why Asynchronous Services?
>   Facilities for Async Services
>   SCA suppor...
Asynchrony & Events
>   Another way to handle asynchrony is to
    use events
>   components communicate by producing
    ...
Events or Callbacks
>   Both allow asynchrony
>   Calls target single specific service
>   Callbacks ensure responses go b...
Agenda

>   Service Component Architecture
>   Why Asynchronous Services?
>   Facilities for Async Services
>   SCA suppor...
SCA Tours
  Online Travel Sample Scenario



http://svn.apache.org/repos/asf/tuscany/sandbox/travelsample




            ...
SCA Tours – Asynchronous Search
Services
                                                 fullapp-packagedtrip (8085)


  ...
Agenda

>   Service Component Architecture
>   Why Asynchronous Services?
>   Facilities for Async Services
>   SCA suppor...
Summary
>   Asynchronous services are a fact of life
>   SCA makes providing async services and
    their clients simpler ...
Useful links
>   Articles about SCA:
       http://www.infoq.com/articles/setting-out-for-sca
       http://www.osoa.org/d...
Mike Edwards
mike_edwards@uk.ibm.com
Raymond Feng
rfeng@us.ibm.com
Luciano Resende
luciano_resende@us.ibm.com
Upcoming SlideShare
Loading in...5
×

Building Asynchronous Services With Sca

2,434

Published on

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

No Downloads
Views
Total Views
2,434
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
52
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Transcript of "Building Asynchronous Services With Sca"

  1. 1. Building Asynchronous Services with SCA Mike Edwards Raymond Feng Luciano Resende
  2. 2. Agenda > Service Component Architecture > Why Asynchronous Services? > Facilities for Async Services > SCA support for service interactions > Example Async Service & Client > Events and Async Services compared > Demo Scenario > Summary
  3. 3. What SCA is > executable model for assembling services ● composites provide language to compose and configure service components ● handles service dependencies > Simplified component programming model for implementing services ● BPEL processes, JavaTM POJOs, EJBs, COBOL, PHP scripts, C++ apps, JavaScript & AJAX, XSLT… > Late binding of policy and communication methods, with distributed deployment model
  4. 4. SCA Overview Service Interface Reference Interface - Java Property - Java - WSDL - WSDL Composite A property setting Component Component Service A B Reference promote wire promote Service Binding Implementation Reference Binding Web Service Java Web Service JMS BPEL JMS SLSB PHP SLSB Rest SCA composite Rest JSONRPC spring JSONRPC JCA EJB module JCA … … …
  5. 5. Why SCA makes life simpler > One way to look at SCA is that it takes details of ● access methods and endpoints ● implementations and configuration ● policy such as encryption, authentication > …and moves them into middleware layer > Application developers write business logic: code that actually builds value ● details of using services handled by SCA ● late binding: as details change, applications (and developers who wrote them) aren’t affected ● "no plumbing in the code"
  6. 6. Why SCA makes life simpler > SCA gives developers single programming model for using services for all aspects of service lifecycle: – Construction – Assembly – Deployment > As your SOA gets more complex, developers have to learn more and more interfaces ● In JavaTM alone: EJBs, RMI, JCA, JAX-WS, JMS...
  7. 7. Service Component Architecture (SCA): Simplified Programming Model for SOA > model for: > building service components > assembling components into applications > deploying to (distributed) runtime environments - Service components built from new or existing code using SOA principles - vendor-neutral – supported across the industry - language-neutral – components written using any language - technology-neutral – use any communication protocols and infrastructure to link components
  8. 8. Agenda > Service Component Architecture > Why Asynchronous Services? > Facilities for Async Services > SCA support for service interactions > Example Async Service & Client > Events and Async Services compared > Demo Scenario > Summary
  9. 9. Asynchronous interactions > Typical in business processes > …not everything happens immediately > …a single request can result in a sequence of responses over time > …a client probably does not want to wait while all steps are completed
  10. 10. Synchronous Processing Price of IBM stock? IBM = $121.50 Price of AT&T stock? AT&T = $38.72 Client Provider
  11. 11. Asynchronous Processing Order Books X, Y, Z Acknowledge, OrderID = 3824 OrderID = 3824 Expect dispatch = 12/06/2008 Client Provider OrderID = 3824 Books X,Y dispatched 10/06/2008 Package ID = 478842110 OrderID = 3824 Books Z dispatched 13/06/2008 Package ID = 479567736
  12. 12. Why Asynchronous Services? > Business processes involve long running multi-step sequences > Clients & Services cannot afford to wait on long request/response operations ● impact on processing resources, memory, communication resources
  13. 13. Agenda > Service Component Architecture > Why Asynchronous Services? > Facilities for Async Services > SCA support for service interactions > Example Async Service & Client > Events and Async Services compared > Demo Scenario > Summary
  14. 14. Synchronous Services > plenty of support for synchronous programming > call-and-return typical for most programming languages SearchResponse search(SearchRequest searchRequest); > most service frameworks support this - for clients & service providers
  15. 15. Asynchronous Services > Facilities less common ● JavaTM concurrency classes ● JAX-WS asynchronous client ● JMS messaging ● BPEL
  16. 16. JAX-WS Async Client API SearchResponse search(SearchRequest sRequest ); Future<?> searchAsync(SearchRequest oRequest, AsyncHandler<SearchResponse> responseHandler ); + class SearchResponseHandler implements AsyncHandler<SearchResponse> { public void handleResponse( Response<SearchResponse> theResponse ) { SearchResponse orderResponse = theResponse.get(); } }
  17. 17. JMS/Messaging > Supports async clients and async services Client Service a.send( message1 ) message1 = x.receive( ) . . . . . . message2 = b.receive( ) y.send( message2 ) + messageListener onMessage listener interface
  18. 18. BPEL and Async Processing > BPEL designed to handle: ● long running processes ● with asynchrony ● multiple partner relationships
  19. 19. Agenda > Service Component Architecture > Why Asynchronous Services? > Facilities for Async Services > SCA support for service interactions > Example Async Service & Client > Events and Async Services compared > Demo Scenario > Summary
  20. 20. SCA Service Interaction AccountData TripCataclog Flight Service Component Component Component Callback (optional) Reference Service Synchronous or Asynchronous interaction styles supported - depends on the interface definition
  21. 21. SCA Callbacks > SCA supports Async services using Callbacks ● service has regular forward call interface ● + callback interface on which service makes calls back to clients ● clients implement the callback interface ● SCA callbacks are part of the business ● Forward calls and callbacks can use different styles such as: ● Oneway + Req/Res ● Req/Res + Req/Res ● Req/Res + Oneway ● Oneway + Oneway
  22. 22. Sync and Async Interfaces public interface SyncSearchService { public SearchResponse search( SearchRequest sRequest ); } public interface AsyncSearchService { public void search( SearchRequest sRequest ); } public interface AsyncSearchCallback { public void searchResponse( SearchResponse sResponse ); }
  23. 23. Callback Interfaces > Callback interface ● may have multiple operations/methods ● operations may be called at any time after initial forward call to service ● number and sequence of callback operations for given forward call is variable (0, 1, many…)
  24. 24. Bidirectional Service Interaction • The reference creates a callback endpoint to receive callbacks • The service establishes a “callback” reference to the caller • The forward call can use different binding than the callback Callback endpoint for reference flightSearch Search Flight binding Callback binding
  25. 25. Agenda > Service Component Architecture > Why Asynchronous Services? > Facilities for Async Services > SCA support for service interactions > Example Async Service & Client > Events and Async Services compared > Demo Scenario > Summary
  26. 26. Bidirectional Interface • Forward Interface @Remotable @Callback(SearchCallback.class) public interface Search { TripItem[] searchSynch(TripLeg tripLeg); @OneWay void searchAsynch(TripLeg tripLeg); } • Callback Interface @Remotable public interface SearchCallback { void searchResults(TripItem[] items); }
  27. 27. Trip Async Search AccountData Callback Flight Service Component Component Trip Cataclog Component Callback AccountData Hotel Service Component Component Callback AccountData Car Service Component Callback Component AccountData Packages Service Component Component
  28. 28. Flight Service implementation import org.osoa.sca.annotations.*; public class FlightImpl implements Search, Book { @Callback protected SearchCallback searchCallback; ………. public void searchAsynch(TripLeg tripLeg) { ………. // return available flights searchCallback.searchResults(searchSynch(tripLeg)); } }
  29. 29. Catalog client application import org.osoa.sca.annotations.*; public class TravelCatalogImpl implements TravelCatalogSearch, SearchCallback{ @Reference protected Search flightSearch; …… public TripItem[] search(TripLeg tripLeg) { flightSearch.searchAsynch(tripLeg); …… } public void searchResults(TripItem[] items){ if (items != null) { for(int i = 0; i < items.length; i++ ){ searchResults.add(items[i]); } } …… } }
  30. 30. Composite <component name="TravelCatalogComponent"> <implementation.java class="scatours.travelcatalog.TravelCatalogImpl"/> <reference name="flightSearch"> <interface.java interface="scatours.common.Search" callbackInterface="scatours.common.SearchCallback"/> <binding.ws uri="http://localhost:8080/Flight/Search"/> <callback> <binding.ws uri="http://localhost:8080/Flight/SearchCallback"/> </callback> </reference> </component> <component name="FlightComponent"> forward interface <implementation.java class="scatours.flight.FlightImpl"/> <service name="Search"> <interface.java interface="scatours.common.Search" callbackInterface="scatours.common.SearchCallback"/> <binding.ws uri="http://localhost:8080/Flight/Search"/> <tuscany:binding.jsonrpc/> <callback> callback interface <binding.ws uri="http://localhost:8080/Flight/SearchCallback"/> </callback> </service> <service name="Book"/> </component> callback binding
  31. 31. "under the hood" > How do the callbacks work in practice? ● implemented using suitable communication methods, such as: ● JMS messaging ● Web services using WS-Addressing
  32. 32. Agenda > Service Component Architecture > Why Asynchronous Services? > Facilities for Async Services > SCA support for service interactions > Example Async Service & Client > Events and Async Services compared > Demo Scenario > Summary
  33. 33. Asynchrony & Events > Another way to handle asynchrony is to use events > components communicate by producing and consuming events ● these are one-way ● asychronous ● arbitrary sequences > eg JMS messages
  34. 34. Events or Callbacks > Both allow asynchrony > Calls target single specific service > Callbacks ensure responses go back to original requester > Event handling is more flexible ● pub/sub, broadcasting of events ● no guarantee that anyone listens
  35. 35. Agenda > Service Component Architecture > Why Asynchronous Services? > Facilities for Async Services > SCA support for service interactions > Example Async Service & Client > Events and Async Services compared > Demo Scenario > Summary
  36. 36. SCA Tours Online Travel Sample Scenario http://svn.apache.org/repos/asf/tuscany/sandbox/travelsample 36
  37. 37. SCA Tours – Asynchronous Search Services fullapp-packagedtrip (8085) Trip Partner Java fullapp-frontend (8084) TravelCatalog fullapp-bespoketrip (8086) binding.ws Hotel Partner Java Java Flight Partner Java Car Partner Java
  38. 38. Agenda > Service Component Architecture > Why Asynchronous Services? > Facilities for Async Services > SCA support for service interactions > Example Async Service & Client > Events and Async Services compared > Demo Scenario > Summary
  39. 39. Summary > Asynchronous services are a fact of life > SCA makes providing async services and their clients simpler and easier > SCA supports this on a range of communication methods
  40. 40. Useful links > Articles about SCA: http://www.infoq.com/articles/setting-out-for-sca http://www.osoa.org/display/Main/SCA+Resources > Apache Tuscany - Open Source implementation of SCA: http://tuscany.apache.org/ > SCA Specifications in OASIS: http://www.oasis-opencsa.org/
  41. 41. Mike Edwards mike_edwards@uk.ibm.com Raymond Feng rfeng@us.ibm.com Luciano Resende luciano_resende@us.ibm.com
  1. A particular slide catching your eye?

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

×