Use JOTM to add transaction support for servlets (4)

zhaozj2021-02-16  26

Release web application

Once you have installed JOTM and Tomcat, publish and call web applications are very simple. First, download the bank.tgz file and decompressed. Copy Bank.xml and Bank.war to $ Tomcat Install Directory $ / WebApps Directory, then start Tomcat:

> CD $ CATALINA_HOME / BIN

> ./catalina.shrun

Using catalina_base: / home / jmesnil / lib / tomcat

Using catalina_home: / home / jmesnil / lib / Tomcat

Using catalina_tmpdir: / home / jmesnil / lib / tomcat / temp

USING JAVA_HOME: / USR / local / Java

May 6, 2003

5:56:00 pm org.apache.commons.Modeler.Registry LoadRegistry

INFO: Loading Registry Information

May 6, 2003

5:56:00 pm org.apache.commons.Modeler.Registry GetRegistry

Info: CREANG New Registry Instance

May 6, 2003

5:56:00 pm org.apache.commons.Modeler.Registry Get Server

Info: CREANG MBEANSERVER

May 6, 2003

5:56:07 pm org.apache.coyote.http11.http11protocol init

Info: Initializing Coyote HTTP / 1.1 on Port 8080

Starting Service Tomcat-Standalone

Apache Tomcat /

4.1.24

-LE-JDK14

You can notice that JOTM does not start from the log, only when you first access DataSource, it will start, then you will get the following information:

May 6, 2003

5:56:20 Pm Org.ObjectWeb.Jotm.Jotm

INFO: JOTM Started with a local transaction factory trata is not bound.

May 6, 2003

5:56:20 Pm Org.ObjectWeb.Jotm.Jotm

Info: Carol Initialization

Open the browser to point to http: // localhost: 8080 / bank / to use web applications.

Use web applications

The homepage of this web application consists of two links:

1) Go to the cash extraction page, where you can simulate the extraction of cash from ATM;

2) To the management console page, where you can check or update information related to the Bank account you created by you.

Before the operation, 500 yuan in the ATM, John Doe's bank account has 100 yuan, and Jane Doe's bank account has 600 yuan.

If John Doe wants to support 400 yuan, the transaction will fail because there is not enough money on his bank account. The result is like this:

Client ID: John_Doe, Value: $ 400

Cash can not be delivered to you

Because: NOT ENOUGH MONEY IN YOUR ACCOUNT (ONLY $ 100).

If Jane Doe wants to support 550 yuan, the transaction will fail because there is not enough cash in the ATM machine. The result is like this: Client ID: Jane_doe, Value: $ 550

Cash can not be delivered to you

Because: Not Enough Cash Available from this ATM (ONLY

$ 500).

If John Doe wants to take 50 yuan, the transaction will be completed successfully. The results are as follows:

Client ID: John_doe, Value: $ 50

Please take your cash ($ 50)

Thank you!

to sum up

This simple example demonstrates servlets to achieve strongness and simplicity by using transactions.

what

Correct operation in the case. The combination of Tomcat and Jotm provides a lightweight approach to a lightweight approach to getting superiority.

In addition to the functions in the example, JOTM also provides more features. JOTM provides the following features to help you enhance your web application:

Complete Distributed Transaction Support: If your application is running (data, business, representation layer) running in different JVMs, you can use global transactions across multiple JVMs. The content of the transaction can be propagated via RMI / JRMP or RMI / IIOP.

Integration with JDBC: Use Xapool, an XA-compatible JDBC connection pool, interact with the database. Xapool is very similar to Jakarta's DBCP project, adding XA compatibility above, which is a must-have method for integrating JTA transactions with JDBC.

Integration with JMS: JOTM can be integrated with Jorm, JORM is an JMS service implementation developed by ObjectWeb organization, through integrated JMS messages supported by integration. You can update JMS messages and database updates to the same transaction.

Web Service Transactions: JOTM provides BTP (Business Transaction Protocol), JOTM-BTP, you can add transaction behavior for your Web Service.

Documents and examples of the above functions can be

Jotm

The release version is found on its website.

转载请注明原文地址:https://www.9cbs.com/read-27636.html

New Post(0)