Two Phase Commit


Two Phase Commit in Distributed Transactions:

Unlike a transaction on a local database, a distributed transaction involves altering data on multiple databases. The database ensures the integrity of data in a distributed transaction using the two-phase commit mechanism. There are three phases in a two phase commit transaction and a commit point site involved. The job of the commit point site is to initiate a commit or roll back operation as instructed by the global coordinator.

  1. Prepare Phase: The initiating node, called the global coordinator, asks participating nodes other than the commit point site to promise to commit or roll back the transaction. If any node cannot prepare, the transaction is rolled back.
  2. Commit Phase: If all participants respond to the coordinator that they are prepared, then the coordinator asks the commit point site to commit. After it commits, the coordinator asks all other nodes to commit the transaction.
  3. Forget Phase: If all participants respond to the coordinator that they are prepared, then the coordinator asks the commit point site to commit. After it commits, the coordinator asks all other nodes to commit the transaction.

Spring Advantages with testing and Mocking

An application geared towards dependency injection is typically more testable because resources are easily replaced with test-oriented resources. Consider a service object that uses a data access object; in production, you’d inject a DAO that talked to a backend data store. But for each test you could create a DAO that returned specific, known data; this allows you to focus on the object being tested.

SOAP Vs. REST

  1. Soap has overhead such as body, envelope and payload. Rest just has the payload.
  2. Using Soap allows you to use web services standards around transaction management and security out of the box. For example, you can use username/password in the soap header. In Rest, we have to come up with the implementation of non-functional requirements such as transaction management, security.
  3. SOAP supports XML by default and REST comes with XML and JSON by default.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s