Thursday 18 October 2018

Transactions in SOA

Transactions
  • Services can be:
    • Non-Transactional Services
    • Transactional Service
  • Non-Transactional services are the services that does not modify data.
E.g. File Adapter, FTP Adapter
  • Transactional service can be defined as any service that performs DML operations, where each operation are subject to ACID(Atomicity, Consistency, Isolation, Durability) principles.
  • Transactional services are implemented as a java web services or adapter services which are invoked from SOA using BPEL or Mediator
  • Transactional boundaries depend on context, configurations and environment of the services that are implemented and invoked.
  • Transactional semantics differs for the services that are invoked synchronously compared with services invoked asynchronously.
Transaction Boundaries
  • Transaction boundaries depends on the type of interaction
    • Starts when a service is invoked(operation begins) and Ends when a service ends(operation completes)
    • Propagates across synchronous services which can:
Joining an existing transaction (By default it will Join in Global Tx)
End the existing transaction(Can be achieved by Dehydration)
Propagate the transaction to another synchronous services
    1. Terminate when invoking an asynchronous service, which:
      Ends or suspends the existing transaction
      Starts new independent transaction
Transactional Service Implementation
Services with transactional behavior can be implemented using
  • Web services(i.e. JWS, Spring Web services, ADF-BC) that execute SQL transactions
  • Database Adapter
  • Service Data Objects
BPEL Transaction
  • BPEL processes are:
    • Transient, when they don’t have any dehydration points i.e. execute start to end without dehydration
    • Durable, when one or more dehydration points occur during execution
  • BPEL Transactions are:
    • Begin at the start of the process. The first activity(Receive / Pick) marks the start of the bpel process.
    • Ends at the end of the transient(Synchronous) process, when it send the reply to its client, or when the dehydration point occurs in a durable(asynchronous) process.
    • If the a fault occurs before these end conditions, the transaction is rolled back to the start and unhandled faults are returned to caller.
BPEL Transactional Behavior
  • JTA (Java Transaction API) is used with the request and when:
    • If exists, the local transaction joins the global JTA transaction when transaction property is set.
    • If does not exist then new transaction is started
  • A transaction is completed when it encounters a break point activity(causing dehydration) or reaching end of flow.
BPEL Transaction and Delivery properties
Transaction boundaries between different BPEL services are controlled by 2 properties i.e. Delivery Property and Transaction property
Delivery property can have 3 values. Those are 1)- async.persit  2)- async.cache 3)- sync
Transaction property can have 2 values. 1)- Required 2)- Requires New
<component name=”TransactionBpel” version=”2.0″>
<implementation.bpel src=”BPELASynchCall.bpel”/>
<property name=”bpel.config.transaction” type=”xs:string” many=”false”>required</property>
<property name=”bpel.config.oneWayDeliveryPolicy” type=”xs:string” many=”false”>async.persist</property>
</component>
case1: If BPEL Process is Async or one-way process then, Delivery property is used
async.persit: Delivery messages are persisted in the database in table dlv_message. With this setting, reliability is obtained with some performance impact on the database.
When the client initiates a process instance, an invocation request is placed in an internal queue. Inside Oracle BPEL Server, a message-driven bean (MDB), WorkerBean, monitors the queue for invocation requests. When a message is dequeued, Oracle BPEL Server allocates a thread to process the message.
async.cache : Incoming delivery messages are kept only in the in-memory cache. If performance is preferred over reliability, this setting should be considered.
Message are not dehydrated into dlv_message table. Rest all is same as async.persist.
sync : Directs Oracle BPEL Server to bypass the scheduling of messages in the invoke queue, and invokes the BPEL instance synchronously. In some cases this setting can improve database performance.
case2: If BPEL Process is Sync process then, transaction boundary between client and bpel process is controlled by “Transaction” property
Required : This makes the BPEL process execute as part of the calling transaction. If no calling transaction exists, it will create a new one.
RequiresNew: This is the default value and makes the BPEL process execute as a separate transaction. Any existing transaction will be suspended.
Adapters
  • Transactional adapters that supports Two Phase commit:
    • DB Adapter
    • JMS Adapter
    • AQ Adapter
    • Oracle Apps Adapter
  • Non transactional adapters
    • File Adapter
    • FTP Adapter
Compensation Activity
  • Problem: Transactions do not work with asynchronous services.
    • ACID principles and XA transactions cannot be applied across asynchronous invocations
    • Transactions can be managed for synchronous services, provided all invocations are synchronous.
  • Solution: Compensation handling, which enables an asynchronous invocation to execute:
    • An operation that performs a transaction
    • An operation that perform reverse of previously completed transaction.

No comments:

Post a Comment

xslt padding with characters call template for left pad and right pad

  Could a call-template be written that took two parameters ?   a string, and a   number) return the string with empty spaces appended t...