Академический Документы
Профессиональный Документы
Культура Документы
MEP
Message exchange pattern (MEP) is a template that establishes a pattern for the exchange of messages between SOAP nodes. Generalized to Web services, a message exchange pattern is a template that establishes a pattern for the exchange of messages between two communicating parties. MEP definitions will therefore be used by several technologies in the Web services architecture:
communication protocols such as SOAP description languages such as WSDL
The request-response MEP establishes a simple exchange in which a message is first transmitted from a source (service requestor) to a destination (service provider). Upon receiving the message, the destination (service provider) then responds with a message back to the source (service requestor).
In the Service compositions section, we provided an example where the TLS Accounts Payable Service, upon receiving an invoice submission from a vendor, enlists the TLS Vendor Profile Service to validate the invoice header information.
Complex MEPs
Primitive MEPs can be assembled in various configurations to create different types of messaging models, sometimes called complex MEPs. A classic example is the publish publish-and andsubscribe model
WSDL 2.0
In-out pattern Out-in pattern In-only pattern Out-only pattern Robust in-only pattern Robust out-only pattern In-optional-out pattern Out-optional-in pattern
Summary
An MEP is a generic interaction pattern that defines the message exchange between two services. MEPs can be composed to support the creation of larger, more complex patterns. The WSDL and SOAP specifications support specific variations of common MEPs.
2. SERVICE ACTIVITY
Service activity
In service-oriented solutions, each task can involve any number of services.
The interaction of a group of services working together to complete a task can be referred to as a service activity
Complex activities
Complex activities, on the other hand, can involve many services (and MEPs) that collaborate to complete multiple processing steps over a long period of time
1. The initial sender, RailCo's Invoice Submission Service, transmits the invoice message 2. The message is first received by a passive intermediary, which routes the message according to conditions. The message ata TLS's Accounts Payable Service. 3. environmental The Accounts Payable Service acts as a subsequently controller andarrives initiates service composition to begin processing the message contents. It begins by interacting with the Vendor Profile Service to validate header data and attaches the invoice document the and vendor 4. The invoice Accounts Payable Service then extracts taxes, shipping to fees, the account. invoice total. It passes these values to the Ledger Service, which updates various ledger accounts, including the General Ledger 5. Finally the activity ends, as the Accounts Payable Service completes its processing cycle by sending a response message back to RailCo
Summary
An activity is a generic concept used to represent a task or a unit of work performed by a set of services. The scope of primitive activities can be limited to the completion of simple MEPs. Complex activities are common within SOAs and exist as part of any non-trivial service-oriented application
3. COORDINATION
COORDINATION
Every activity introduces a level of context into an application runtime environment. Something that is happening or executing has meaning during its lifetime, and the description of its meaning (and other characteristics that relate to its existence) can be classified as context information. The more complex an activity, the more context information it tends to bring with it. The complexity of an activity can relate to a number of factors, including:
the amount of services that participate in the activity the duration of the activity the frequency with which the nature of the activity changes whether or not multiple instances of the activity can concurrently exist
Coordination framework
provide a means for context information in complex activities to be managed, preserved and/or updated, and distributed to activity participants.
Example
bob
Prepare Water
This service controls a composition of three other services that each play a specific part in the management of context data.
Registration service
Allows participating services to use context information received from the activation service to register for a supported context protocol.
Coordination service.
The controller service of this composition
Coordinator service
Coordination type
Each coordinator is based on a coordination type, which specifies the nature and underlying logic of an activity for which context information is being managed. The WS-Coordination framework is extensible and can be utilized by different coordination types.
WS-AtomicTransaction WS-BusinessActivity
Coordination protocol
The actual process that a coordinator uses to communicate with an application is defined by the coordination protocol chosen by the application. The coordination protocol defines a series of messages between the coordinator and each application that is participating in the coordination. In a single coordination, each participating Web service application can request to use a different protocol when communicating with the coordinator
Coordination Context
A context created by the activation service is referred to as a coordination context The coordination context contains all of the coordination-related information for a coordinated process and is defined in a SOAP message by the CoordinationContext element in the SOAP message header. can contain the following information:
Expiration value Identifier (unique) that represents the activity Coordination type Defines the type of coordination process that the coordination context has been defined for. Registration service Address of the service from which another Web service can request entry into the coordinated process. Other coordinationcoordination-specific information The Coordination-Context element is extensible and can be used to carry other application-specific information relating to the coordinated process.
Coordination Participants
service that wants to take part in an activity managed by WS-Coordination must request the coordination context from the activation service. It then can use this context information to register for one or more coordination protocols. A service that has received a context and has completed registration is considered a participant in the coordinated activity.
This invitation consists of the context information Upon a the application successful service originally registration, a received from the service is officially Any Web service activation service. a participant. The in possession of registration this context service information Via a passesmay the service The coordination issue a the CreateCoordinationCo location of the service composition is registration ntext request coordinator instantiated an request to the the message, it when asks service, with application serviceto registration activation service which all the contacts activation service. This generate a set of new participants are service allowsdata. the service context Once required to to enlist in a passed back with the interact. coordination ReturnContext based on a message, the specific protocol. application service now can invite other services to participate in the coordination.
As shown in Figure coordination is applied to the following steps: 3. The Accounts Payable Service uses the Vendor Profile Service to validate the In the previous case study example, the individual invoice header data. If the data is valid, we the established invoice document is attached to the process steps that comprised a complex activity. Once the processing vendor account. of this activity enters the TLS environment, TLS employs a context management to coordinate the flow ofand the shipping messagefees through 4. The Accounts system Payable Service extracts taxes fromits the internal services. invoice document. These values, along with the invoice total, are submitted to the Ledger Service. The Ledger Service is responsible for updating the General Ledger and numerous sub-ledgers, such as the Accounts Payable Ledger.
Transaction
Termine generico che si riferisce ad ogni attivit che crea, aggiorna o cancella i dati in un database Quando un set ordinato di operazioni modulato come una transazione allora tutto linsieme visto come one logic operation
Gli effetti della transazione si vedono quando questa unica operazione logica si conclusa con successo Se loperazione fallisce allora non successo niente
ACID
In generale le propriet delle transazioni sono conosciute come propriet ACID, ossia che assicurano Atomicit, Consistenza, Isolamento e Persistenza (Durabilit).
Ad esempio un sistema di gestione di basi di dati, conduce le transazioni in modo da garantire la consistenza dei data records anche quando vengono eseguite pi operazioni in concorrenza su di essi.
Consistent
richiede che al termine della transazione tutti i dati manipolati siano coerenti con la semantica della transazione stabilita da una logica di business.
Isolated
richiede che lesecuzione di una transazione sia completamente indipendente dalla contemporanea esecuzione di altre transazioni. In un ambiente distribuito lisolamento nasconde anche gli stati intermedi di una transazioni rendendoli inaccessibili dallesterno.
Durable
richiede che leffetto di una transazione che abbia eseguito il commit correttamente non venga pi perso.
Distributed Transaction
Move money transaction
Per applicazioni distribuite si ha la necessit di mettere insieme transazioni costituite esse stesse da transazioni
Deposit Transaction
Withdraw Transaction
DB1
DB2
Concurrency control
Consistency and isolation
Business Transaction
Con il termine Business Transaction si indica un cambiamento consistente nello stato di un processo condotto tra diverse organizzazioni Lautomazione di processi di business complessi non pu essere realizzata adeguatamente con gli attuali sistemi di scambi di messaggi
BT Framework
Apposito framework che assicuri che le transazioni che costituiscono il processo siano condotte secondo specifiche regole:
strumenti per definire la logica di business formato e sequenza di messaggi necessari per conseguire il risultato voluto
La sincronizzazione delle attivit che vengono svolte allinterno dei singoli partecipanti al processo deve essere gestita tenendo conto della natura dello scenario dove avviene la comunicazione (ad esempio il Web);
Le BT a lungo termine (o semplicemente BT) possono essere viste come un insieme di BT, legate da una logica di business.
Le singole transazioni possono avere esiti diversi, nel qual caso il risultato finale della BT dipende dalla particolare logica o da una decisione esplicita del cliente che ha iniziato la transazione.
Quando si eseguono short duration transactions e si deve preservare in the strict sense the ACID properties
ATOMIC TRANSACTIONS
ATOMIC TRANSACTION
Atomic transactions implement the familiar commit and rollback features to enable crossservice transaction support ( traditional twophase transaction protocol )
Originally, these steps were simply performed in sequence as a continuation of the overall process. Now we have a requirement that dictates that should the resulting soap mixture be unacceptable, the bucket needs to be reset to its original state (empty). This requirement emulates an atomic transaction, where at the completion of Step 5, the process is either rolled back to the beginning of Step 4, or the quality of water is accepted (committed) so that it can be applied to washing the car.
Two-Phase Commit
Main protocol used for completing transactions while maintaining the ACID properties of data AtomicTransaction specifies two versions of the two-phase commit protocol, known as volatile and durable.
The volatile two-phase commit protocol is used for coordinating volatile resources, such as an in-memory cache, The durable two-phase commit protocol is used for coordinating durable resources, such as a database, from which recovery is possible.
One participant (generally the application that created the transaction) registers for the completion protocol, so that it can tell the coordinator either to try to commit the transaction or force a rollback. A status is returned to indicate the final transaction outcome.
CompletionWithAck
Same as Completion, but the coordinator must remember the outcome until receipt of an acknowledgment notification.
2PC
A participant that wants the coordinator to notify it just before the 2PC protocol begins registers for this. A typical example is an application that caches data and needs a notification to write outstanding updates to a database. This is executed prior to the 2PC
OutcomeNotification:
A transaction participant that wants to be notified of the commit-abort decision registers for this. Applications use outcome notifications to release resources or perform other actions after commit or abort of a transaction.
Vote phase
Each participant's vote consists of either a "commit" or "abort" request In base al risultato ottenuto comunicano al coordinatore la loro capacit di eseguire correttamente il commit o meno
Commit Phase
Now reviews all votes and decides whether to commit or rollback the transaction. The conditions of a commit decision are simple:
if all votes are received and if all participants voted to commit, the coordinator declares the transaction successful, and the changes are committed. However, if any one vote requests an abort, or if any of the participants fail to respond, then the transaction is aborted, and all changes are rolled back
For the MyOrderService application to successfully place an order, it needs to verify both that the inventory for the product is available and that the shipment can be arranged. This means that if either MyShippingService or MyInventoryService should fail, the entire transaction cannot succeed.
example
1. After receiving a customer order, MyOrderService sends a CreateCoordinationContext message to MyCoordinator to request a new coordination context for the transaction. 2. MyCoordinator returns a CreateCoordinationContextResponse message containing the coordination context. 3. MyOrderService sends a Register request to the registration service, requesting to use the two-phase commit protocol. 4. The registration service returns a RegisterResponse message.
5. MyOrderService sends an inventory request message to MyInventoryService to check the inventory and mark the requested number of units for shipment. In the header of this message is a CoordinationContext header element with the context identifier and the address of the registration service. 6. MyInventoryService sends a Register message to the registration service to enter into the existing coordination context, also using the two-phase commit protocol. 7. The registration service returns a RegisterResponse message. 8. MyInventoryService sends a shipping request message to MyShippingService to schedule and confirm delivery. In the header of this message is a CoordinationContext header element with the context identifier and the address of the registration service.
9. MyShippingService sends a Register message to the registration service to enter into the existing coordination context, requesting to use the completion with acknowledgment protocol. 10. The registration service returns a RegisterResponse message. 11. With all of the services enrolled in the transaction, the coordinator sends a Prepare message to MyOrderService and MyInventoryService to begin the two-phase commit process. Since MyShippingService isn't using two-phase commit, it doesn't receive the Prepare message
12. After recording the transaction in a recoverable way, MyOrderService and MyInventoryService return a Prepared message to the coordinator. 13. After receiving the Prepared message, the coordinator sends a Commit message to all three services. 14. After successfully committing the changes, MyOrderService and MyInventoryService return a Committed message to the coordinator, and MyShippingService returns a Notified message.
Key Points
WS-AtomicTransaction is a coordination type that supplies five coordination protocols that can be used to achieve twophase commit transactions across multiple service participants. The atomic transaction coordinator makes the ultimate decision to commit or rollback a transaction. This decision is based on votes collected from participants.
Final Considerations
1. Il punto fondamentale di questo protocollo quindi il blocco delle risorse finch non si sicuri che tutto sia stato eseguito correttamente. Questa pratica non adatta in ambiente Web.
1. In primo luogo il Web caratterizzato da comunicazioni asincrone e non affidabili ; questo ostacola limplementazione di un protocollo 2PC in quanto il coordinatore non pu essere certo del tempo impiegato da un partecipante a rispondere ai suoi messaggi di prepare e di commit e rischia di attendere indefinitamente. Anche luso di timeout per ovviare a questo problema non offre una valida soluzione perch timeout troppo corti possono causare labort di un numero eccessivo di transazioni che invece sarebbero andate a buon fine, mentre timeout troppo lunghi possono tenere molte risorse bloccate inutilmente per tempi inaccettabili.
2.
Final Considerations
2. Secondariamente bisogna considerare che unorganizzazione che partecipi ad una transazione difficilmente sarebbe disposta a bloccare le proprie risorse per lungo tempo.
1. principalmente per questi motivi che si ormai diffusa lidea di rilassare i vincoli imposti dalle propriet ACID quando si ha a che fare con BT a lungo termine che spaziano tra i domini di pi organizzazioni diverse. Data la loro natura, le BT a breve termine possono essere implementate secondo i classici protocolli 2PC. Tipicamente infatti le operazioni di una BT a breve termine sono completamente automatizzate (e quindi eseguite in tempi brevissimi) e non escono dai confini di unorganizzazione.
2.
BT a lungo termine
Viene considerata come un insieme di transazioni a breve termine. Il coordinatore fa in modo che ognuna di queste venga eseguita indipendentemente dalle altre e raccoglie i vari esiti che gli giungeranno in diversi istanti di tempo. Generalmente alcuni saranno dei commit e altri degli abort. A seconda di quali transazioni sono andate a buon fine e quali no, verr presa una decisione (da una specifica applicazione di business o direttamente dal cliente) sullesito globale della BT.
COMPENSATION PROCESS
State example
Active State Completed state
For example, a participant can indicate that it has completed the processing it was required to perform as part of the activity by issuing a completed notification. This moves the participant from an active state to a completed state. The coordinator may respond with a close message to let the participant know that the business activity is being successfully completed.
Compensation state
Participants can enter a compensation state during which they attempt to perform some measure of exception handling. This generally invokes a separate compensation process that could involve a series of additional processing steps.
State example
Cancelled state
Alternatively to compensation state; this typically results in the termination of any further processing outside of the cancellation notifications that need to be distributed
Exit state
What also distinguishes business activities from atomic transactions is the fact that participating services are not required to remain participants for the duration of the activity. Because there is no tight control over the changes performed by services, they may leave the business activity after their individual contributions have been performed. When doing so, participants enter an exit state by issuing an exit notification message to the business activity coordinator.
Key Points
Business activities manage complex, long-running activities that can vary in scope and in the amount of participating services. WS-BusinessActivity builds on the WS-Coordination context management framework by providing two protocols for which activity participants can register. Participants and the business activity coordinator progress through a series of states during the lifespan of a business activity. State transition is accomplished through the exchange of notification messages.
ORCHESTRATION
With orchestration, different processes can be connected without having to redevelop the solutions that originally automated the processes individually. Orchestration bridges this gap by introducing new workflow logic. Further, the use of orchestration can significantly reduce the complexity of solution environments. Workflow logic is abstracted and more easily maintained than when embedded within individual solution components.
Orchestration Control
Language specification
A primary industry specification that standardizes orchestration is the Web Services Business Process Execution Language (WS-BPEL). WS-BPEL is the most recent name given to this specification, which also is known as BPEL4WS and just BPEL.
Some activities
Sequence
aligns groups of related activities into a list that determines a sequential execution order.
Flows
also contain groups of related activities, but they introduce different execution requirements.
Links
are used to establish formal dependencies between activities that are part of flows. Before an activity fully can complete, it must ensure that any requirements established in outgoing links first are met.
Key Points
An orchestration expresses a body of business process logic that is typically owned by a single organization. An orchestration establishes a business protocol that formally defines a business process definition. The workflow logic within an orchestration is broken down into a series of basic and structured activities that can be organized into sequences and flows. Orchestration has been called the "heart of SOA," as it establishes a means of centralizing and controlling a great deal of inter and intra-application logic through a standardized service model.
Choreography
A choreography is essentially a collaboration process designed to allow organizations to interact in an environment that is not owned by any one partner. The Web Services Choreography Description Language (WS-CDL) is one of several specifications that attempts to organize information exchange between multiple organizations (or even multiple applications within organizations), with an emphasis on public collaboration
Choreography elements
Roles
This establishes what the service does
Relationship
Each potential exchange between two roles
Channels
defining the characteristics of the message exchange between two specific roles
The choreography acts as a community interchange pattern used for collaborative purposes by services from different provider entities
A choreography, on the other hand, is not necessarily owned by a single entity.
An orchestration is based on a model where the composition logic is executed and controlled in a centralized manner. A choreography typically assumes that there is no single owner of collaboration logic.
Collaboration
web service
Process flow
web service
Orchestration-Centric Approach
receive 'OpenAccountRequest' invoke CollectAccountInfo invoke ValidateAccountInfo assign AccountInfoInvalid = ValidateAccountInfoResponse while AccountInfoInvalid = true invoke RepairAccountInfo pick onRepairAccountInfoCB invoke ValidateAccountInfo assign AccountInfoInvalid = ValidateAccountInfoResponse otherwise // timeout assume AccountInfo can't be repaired invoke DeclineAccountApplication terminate end pick end while invoke OpenAccount invoke SendConfirmation
Choreography-Centric Approach
CollectAccountInformation and ValidateAccountInformation ValidateAccountInformation and RepairAccountInformation. ValidateAccountInformation and OpenAccount. OpenAccount and SendConfirmation. RepairAccountInformation and DeclineAccountApplication
One key difference is that the orchestration approach assumes a single, central point of control over the entire scope of the process execution, while the choreography approach assumes that execution control is shared, potentially across multiple business process engines or various other technologies.
KEY POINTS
A choreography is a complex activity comprised of a service composition and a series of MEPs. Choreographies consist of multiple participants that can assume different roles and that have different relationships. Choreographies are reusable, composable, and can be modularized.
Request-Response MEP
committed
Ciascuna TR appena partita entra in uno stato in cui esegue la sua local computation
aborted
forgotten
SubTR1
Coordinator
SubTR2 Quando il coordinatore parte registra le sottotransazioni Se si ha lunanimit di commit allora il coordinatore annuncia una commit decisione altrimenti un abort decision ( rollback)
register
register
vote
vote
decision
decision
Ogni partecipante pu aggiornare il suo stato dopo ciascun passo della transazione I risultati di un task sono visibili prima della fine della transazione I vincoli di atomicit ed Isolamento sono relaxed
Loperazione di compensazione in caso di fallimento fa perdere semanticamente gli effetti dellesecuzione parziale della transazione Ciascuna operazione pu avere una differente logica di compensazione Ciascun provider pu avere una differente opinione riguardo lesatto significato di compensare una operazione
Disdetta reservation con pagamento penale o no
Museum Server
Airline Server WS
(4) prepare (5) (3)prepare prepared (6)prepared
WS
(2)prepare
COORD.
(7) message
COORD.
1. Ws Travel tenta di iniziare una transazione usando Completion Protocol 2. Il coordinatore inizia ad eseguire il protocollo di coordinamento per gli altri due partecipanti inviando un messaggio di PREPARE del 2PC protocol 3. I servizi coinvolti si dichiarano pronti ad eccezione del museo che risponde con un messaggio ed abbandona la transazione
Airline Server
WS
(9) vote (12) voted (8) vote
WS
(10) voted
COORD.
COORD.
(11) voted
A inizia la Business Activity e passa il contesto a B e C che si registrano con B finisce il suo lavoro mentre C incontra quando riceve il fault message R ha un gierrore ricevuto il messaggio completed RSe per il BusinessAgreement Protocol da B manda a B un messaggiio compensate altrimenti cancelled Infine R manda un forget message to C