首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

Clustering in JBoss AS7/EAP 六

2013-11-23 
Clustering in JBoss AS7/EAP 6The example stateful session bean is a CDI component associated to the

Clustering in JBoss AS7/EAP 6

The example stateful session bean is a CDI component associated to the HTTP session. The bean has a counter which is increased every time it is read by the getter-method getCounterValue(). With the counter you can track how often the bean was invoked during the session.

Enable HTTP Session replication

Replication of the HTTP session ensure that the sessions of the clients will be available on all cluster nodes. That means a session object is replicated to other cluster-nodes. This is internally done by storing the session objects into an Infinispan cache-container. So, if one node dies the HTTP session of the client can be continued on another node. For this, an external mechanism is required to handle failover and load balancing transparent to the client side, the browser. mod_cluster can do that out-of-the-box and we cover this in a second.

Configuring the JBoss AS to replicate the HTTP session is done by adding the <distributable/> element to the web.xml:

We need to download the EAP 6 version, because we ran into several known bugs related to the clustering capabilities of the current community release 7.1.1.Final. These bugs are already fixed in the development branch. So you could also try the latest nightly build or download the JBoss 7.1.2.Final tag from github and run the build.sh script.

After you downloaded the JBoss AS, extract the ZIP archive in two different directories, for example jb1 and jb2. For our cluster environment, we run the JBoss instances in standalone mode. This mode is similar to the previous versions of the JBoss AS. Now we can deploy our example-application. So, copy the Web-archive to both jb1/standalone/deployments/ and jb2/standalone/deployments/ directories.

Before we start the two JBoss AS instances let us have a look at the start commands:

Now feel free to play with the cluster you just built. Access our example-application through http://127.0.0.1/cluster.
Clustering in JBoss AS7/EAP 六

You see which node is processing the requests – kill that node (ctrl-c in the console window of that node) wait a second and hit the refresh button of your browser, the request should now be processed by the other node and much more interesting you neither get a new session nor a new stateful session bean. It just looks like nothing happened except that the request is handled by another cluster-node. Feel free to play around a little bit with your cluster.

Summary and Prospects

In this post we used the EAP 6 version, which is completely stable and fully usable in relation to the clustering capability. With the current community release 7.1.1.Final we ran into several known bugs. All these bugs have been fixed in the 7.1.2.Final tag. But for production environments we recommend the supported and quality-assured EAP version.

As we have shown it is really easy to configure a simple Java EE application to run in a clustered environment. In this post we did not cover message-driven-beans or the second-level cache for JPA entities, but we plan to do this in later posts.

The next post covers the management of a clustered environment with the new domain mode of the JBoss AS 7.

Feel free to contact us for any questions or feedback.

immanuel.sims (at) akquinet.de
heinz.wilming (at) akquinet.de

热点排行