A business might require two or more distributed databases
to be maintained in step. WebSphere® MQ
offers a solution involving multiple units of work acting asynchronously.
The top half of
Figure 1 shows
a two-phase commit structure, while the WebSphere MQ solution is shown in the lower
half, as follows:
- The first application writes to a database, places a message on
a queue, and issues a syncpoint to commit the changes to the two resources.
The message contains data which is to be used to update a second database
on a separate system. Because the queue is a remote queue, the message
gets no further than the transmission queue within this unit of work.
When the unit of work is committed, the message becomes available
for retrieval by the sending MCA.
- In the second unit of work, the sending MCA gets the message from
the transmission queue and sends it to the receiving MCA on the system
with the second database, and the receiving MCA places the message
on the destination queue. This is performed reliably because of the
assured delivery property of WebSphere MQ.
When this unit of work is committed, the message becomes available
for retrieval by the second application.
- In the third unit of work, the second application gets the message
from the destination queue and updates the database using the data
contained in the message.
Figure 1. Data integrity
It is the transactional integrity of units of work 1 and 3, and
the once and once only, assured delivery property of WebSphere MQ used in unit of work 2, which
ensures the integrity of the complete business transaction.
If the business transaction is a more complex one, many units of
work may be involved.