JBoss:Developer's Guide
上QQ阅读APP看书,第一时间看更新

Clustered high available money TransferWebApp

In this section, Doctor JBoss and his assistant have the critical mission to build a proof of concept showing a clustered money transfer web application. The client will rely on this application to improve their money transfer portal.
The customer wants to see failover processes and confirm the transaction data is not lost when a node goes down.
A clustered application is a distributed application running on one or many server instances with the specificity that user data is also replicated on one or more nodes.
Web applications deployed on the JBoss Application Server must explicitly activate the clustering by adding the <distributable> tag in their web.xml descriptor.
This tag activates clustering on the the JBoss Application Server when the following subsystems are available:

  • Infinispan: This subsystem provides the replicated cache to store objects: httpsessions and ejbs
  • JGroups: This provides communication mechanisms used by nodes to discover each other and make exchanges
  • Modcluster: The subsystem provides capabilities to communicate with the Apache HTTP server when Apache acts as a load balancer

Since user sessions are replicated on various nodes, while hitting the application URL for node1 or node2, the user should see exactly the same content, including dynamic data stored in the session:

Session replication

If one node goes down, replication is not possible with the failing node; only users connected on the active node will be able to perform their transactions. At the same time, users previously connected on the failing node will face an error unless they have switched to a working node:

Session replication: a node goes down

To automatically switch clients to working nodes in case of a failure node, load balancers can be used; their main purpose is to listen for incoming client requests and redirect them to one active node. Load balancers also serve as a single entry point, hiding the multiple backend URLs to the final users.

If a user was previously connected to the failing node just before the break, by refreshing its browser or sending a new request, it should be switched by the load balancer to an active node where it resumes its session:

Load balancer in clustered application