can i call you back? building solutions with asynchronous services using sca

31
OpenCSA Member Section – Service Component Architecture 1 OpenCSA Member Section – Service Component Architecture 1 Can I Call You Back? Can I Call You Back? Building Solutions Building Solutions with Asynchronous Services with Asynchronous Services Using SCA Using SCA www.oasis-open.org Mike Edwards - IBM Hursley Lab, England S S implicity, implicity, C C onsumability, onsumability, A A gility gility

Upload: martha

Post on 14-Jan-2016

18 views

Category:

Documents


0 download

DESCRIPTION

www.oasis-open.org. Can I Call You Back? Building Solutions with Asynchronous Services Using SCA. Mike Edwards - IBM Hursley Lab, England. S implicity, C onsumability, A gility. Agenda. Why Asynchronous Services? Facilities for Async Services SCA support for service interactions - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 1OpenCSA Member Section – Service Component Architecture 1

Can I Call You Back? Can I Call You Back?

Building Solutions Building Solutions with Asynchronous Services with Asynchronous Services

Using SCAUsing SCA

www.oasis-open.org

Mike Edwards - IBMHursley Lab, England

SSimplicity, implicity, CConsumability, onsumability, AAgilitygility

Page 2: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 2OpenCSA Member Section – Service Component Architecture 2

Agenda

Why Asynchronous Services? Facilities for Async Services SCA support for service interactions Example Async Service & Client Events and Async Services compared

Page 3: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 3OpenCSA Member Section – Service Component Architecture 3

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

Page 4: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 4OpenCSA Member Section – Service Component Architecture 4

Synchronous Processing

Client Provider

Price of IBM stock?

IBM = $121.50

Price of AT&T stock?

AT&T = $38.72

Page 5: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 5OpenCSA Member Section – Service Component Architecture 5

Asynchronous Processing

Order Books X, Y, Z

Acknowledge, OrderID = 3824

OrderID = 3824 Expect dispatch = 12/06/2008

OrderID = 3824 Books X,Y dispatched 10/06/2008Package ID = 478842110

OrderID = 3824 Books Z dispatched 13/06/2008Package ID = 479567736

Client Provider

Page 6: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 6OpenCSA Member Section – Service Component Architecture 6

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

Page 7: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 7OpenCSA Member Section – Service Component Architecture 7

Agenda

Why Asynchronous Services? Facilities for Async Services SCA support for service interactions Example Async Service & Client Events and Async Services compared

Page 8: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 8OpenCSA Member Section – Service Component Architecture 8

Synchronous Services plenty of support for synchronous

programming call-and-return typical for most

programming languages

most service frameworks support this - for clients & service providers

OrderResponse placeOrder( OrderRequest oRequest );

Page 9: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 9OpenCSA Member Section – Service Component Architecture 9

Asynchronous Services Facilities less common

Java concurrency classes JAX-WS asynchronous client JMS messaging BPEL

Page 10: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 10OpenCSA Member Section – Service Component Architecture 10

JAX-WS Async Client APIOrderResponse placeOrder( OrderRequest oRequest );

Future<?> placeOrderAsync( OrderRequest oRequest, AsyncHandler<OrderResponse> responseHandler );

class OrderResponseHandler implements AsyncHandler<OrderResponse> {

public void handleResponse( Response<OrderResponse> theResponse ) { OrderResponse orderResponse = theResponse.get(); }}

+

Page 11: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 11OpenCSA Member Section – Service Component Architecture 11

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

.

.

.

.

.

.

Page 12: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 12OpenCSA Member Section – Service Component Architecture 12

BPEL and Async Processing

BPEL designed to handle: long running processes with asynchrony multiple partner relationships

Page 13: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 13OpenCSA Member Section – Service Component Architecture 13

Agenda

Why Asynchronous Services? Facilities for Async Services SCA support for service interactions Example Async Service & Client Events and Async Services compared

Page 14: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 14OpenCSA Member Section – Service Component Architecture 14

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

Page 15: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 15OpenCSA Member Section – Service Component Architecture 15

Warehouse Service

WarehouseComposite

WarehouseBroker

Component

WarehouseComponent

Order Processing

Service

OrderProcessingComponent

Shipping Reference

External Warehouse

Reference

PaymentsComponentPayment

Service

AccountsComposite

ExternalBanking

Reference

AccountsLedger

Component

SCA assembly

BPEL

Java EE

C++

SOAP/HTTP

JMS

RMI/IIOP

Mixed:- technologies- app locations

Multi-levelcomposition

Page 16: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 16OpenCSA Member Section – Service Component Architecture 16

SCA Service Interaction

ClientComponent

AccountData

Service

Component

ServiceComponent

Reference Service

Synchronous or Asynchronous interaction styles supported- depends on the interface definition

Page 17: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 17OpenCSA Member Section – Service Component Architecture 17

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

Page 18: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 18OpenCSA Member Section – Service Component Architecture 18

Sync and Async Interfaces

public interface SyncOrderService {

public OrderResponse placeOrder( OrderRequest oRequest );

}

public interface AsyncOrderService {

public void placeOrder( OrderRequest oRequest );

}

public interface AsyncOrderCallback {

public void placeOrderResponse( OrderResponse oResponse );

}

Page 19: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 19OpenCSA Member Section – Service Component Architecture 19

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…)

Page 20: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 20OpenCSA Member Section – Service Component Architecture 20

Agenda

Why Asynchronous Services? Facilities for Async Services SCA support for service interactions Example Async Service & Client Events and Async Services compared

Page 21: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 21OpenCSA Member Section – Service Component Architecture 21

The interfaces

public interface AsyncOrderCallback {

public void placeOrderResponse( OrderResponse oResponse );

}

public interface AsyncOrderService {

public void placeOrder( OrderRequest oRequest );

}

Forward service interface:

Callback interface:

Page 22: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 22OpenCSA Member Section – Service Component Architecture 22

Order Service implementationimport org.osoa.sca.annotations.*;public class OrderServiceImpl implements OrderService { // A field for the callback reference object

private OrderCallback callbackReference;

// The place order operation itselfpublic void placeOrder( OrderRequest oRequest ) {

// …do the work to process the order…// …which may take some time…// when ready to respond…OrderResponse theResponse = new OrderResponse();

callbackReference.placeOrderResponse( theResponse );}

// A setter method for the callback reference@Callbackpublic void setCallbackReference( OrderCallback theCallback ) {

callbackReference = theCallback;}

}

Page 23: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 23OpenCSA Member Section – Service Component Architecture 23

Order client applicationimport org.osoa.sca.annotations.*;public class OrderServiceClient implements OrderCallback { // A field to hold the reference to the order service

private OrderService orderService;

public void doSomeOrdering() {OrderRequest oRequest = new OrderRequest();//… fill in the details of the order …orderService.placeOrder( oRequest );// …the client code can continue to do processing

}

// callback method…public void placeOrderResponse( OrderResponse oResponse ) {

// …handle the response as needed}

// A setter method for the order service reference@Referencepublic void setOrderService( OrderService theService ) {

orderService = theService;}

}

Page 24: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 24OpenCSA Member Section – Service Component Architecture 24

Composite diagram

orderComposite

Component

OrderClient

Component

OrderService

reference service

wire

Page 25: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 25OpenCSA Member Section – Service Component Architecture 25

Composite<?xml version="1.0" encoding="UTF-8"?><composite name="orderComposite"

xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">

<!-- The OrderClient component --> <component name="OrderClient"> <implementation.java class="OrderServiceClient"/> <reference name="OrderService" target="OrderService/OrderService"> <binding.ws/> </reference> </component> <!-- The OrderService component --> <component name="OrderService"> <implementation.java class="OrderServiceImpl"/> <service name="OrderService">

<interface.java interface="OrderService" callbackinterface="OrderCallback"/> <binding.ws/> </service> </component>

</composite>

forward interface

callback interface

wire

Page 26: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 26OpenCSA Member Section – Service Component Architecture 26

"under the hood" How do the callbacks work in

practice? implemented using suitable

communication methods, such as:

JMS messaging Web services using WS-Addressing

Page 27: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 27OpenCSA Member Section – Service Component Architecture 27

Agenda

Why Asynchronous Services? Facilities for Async Services SCA support for service interactions Example Async Service & Client Events and Async Services compared

Page 28: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 28OpenCSA Member Section – Service Component Architecture 28

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

Page 29: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 29OpenCSA Member Section – Service Component Architecture 29

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

Page 30: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 30OpenCSA Member Section – Service Component Architecture 30

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

Page 31: Can I Call You Back?  Building Solutions  with Asynchronous Services Using SCA

OpenCSA Member Section – Service Component Architecture 31OpenCSA Member Section – Service Component Architecture 31

Useful links Articles about SCA: http://www.infoq.com/articles/setting-out-for-sca http://www.osoa.org/display/Main/SCA+Resources

Open Source implementation of SCA: http://cwiki.apache.org/TUSCANY/

SCA Specifications in OASIS: http://www.oasis-opencsa.org/

Email address: [email protected]