Posted by: jbossejb3 | July 7, 2008

Generating Cluster Wide Unique UUID

In the import part add:
import org.jboss.ejb.plugins.keygenerator.uuid.UUIDKeyGeneratorFactory;

Get the factory from JNDI:
... = (UUIDKeyGeneratorFactory) ctx.lookup("UUIDKeyGeneratorFactory");
Generate the UUID:
uuidGen.getKeyGenerator().generateKey().toString()

Posted by: jbossejb3 | June 26, 2008

Terracotta – JBoss AS – EJB3

I am going to use terracotta just to speed up the system.
I still need JBoss AS and its EJB 3 implementation.
Terracotta alone is too flexible which is not appropriate for agile development which heavily depends on forced blueprint like EJB to ensure design quality.

Posted by: jbossejb3 | June 25, 2008

Terracotta. What?

While I am enjoying clustering solution using JBoss, I heard about terracotta. An interesting word, so I opened the website.

Somebody said terracotta hundreds time faster than JBoss clustering, and more transparent solution to clustering that the software components you build don’t have to be EJBs. Well, I don’t know yet.

I am very enthusiastic about learning terracotta tonight, but wait.. A friend needs me to compile and integrate our old java source code tonight :-(

Posted by: jbossejb3 | June 25, 2008

jboss-web.xml for session replication

<?xml version=”1.0″ encoding=”UTF-8″?>

<!DOCTYPE jboss-web PUBLIC
“-//JBoss//DTD Web Application 5.0//EN”
“http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd”>

<jboss-web>
<replication-config>
<replication-trigger>SET_AND_NON_PRIMITIVE_GET</replication-trigger>
<replication-granularity>SESSION</replication-granularity>
<replication-field-batch-mode>true</replication-field-batch-mode>
</replication-config>
</jboss-web>

Posted by: jbossejb3 | June 25, 2008

Installing Web Load Balancing to JBoss 5

After setting up JBoss clusters as explained in Setting up JBoss 5 AS cluster nodes, we can setup the web load balancing.

Install Apache 2. You can get it from http://httpd.apache.org.

Install mod_jk to the apache. You can get it from http://www.apache.org/dist/jakarta/tomcat-connectors/jk/binaries/

Let us say that you have added node1 in mod_jk installation. To the first node of your JBoss 5 cluster edit the file deployers/jbossweb.deployer/server.xml add attribute jvmRoute=”node1″ to the element <Engine>, so the element will look like this: <Engine name=”jboss.web” defaultHost=”localhost” jvmRoute=”node1″>.

Edit deployers/jbossweb.deployer/META-INF/war-deployers-beans.xml, to the bean WebAppClusteringDefaultsDeployer add property: <property name=”useJK”>true</property>

Do the same to other nodes.

Edit your web applications web.xml. Add <distributable/>

Edit your web applications jboss-web.xml

Posted by: jbossejb3 | June 25, 2008

Installing mod_jk

Get the mod_jk binary. You can get it from http://www.apache.org/dist/jakarta/tomcat-connectors/jk/binaries/.

Copy mod_jk.so to modules directory of your apache web server.

Put mod-jk.conf template in directory conf/extra of apache. Edit the file, replace MyApps with your application url string components.

Edit conf/httpd.conf, add one line: Include conf/extra/mod-jk.conf

Put uriworkermap.properties in directory conf/extra.

Put workers.properties in directory conf/extra. The template assuming that you have two nodes; node1 and node2 residing in host 172.16.1.37 and 172.16.1.195

Posted by: jbossejb3 | June 25, 2008

workers.properties

# Define list of workers that will be used
# for mapping requests
worker.list=loadbalancer,status
# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=172.16.1.37
worker.node1.type=ajp13
worker.node1.lbfactor=1
worker.node1.cachesize=10

# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=8009
worker.node2.host=172.16.1.195
worker.node2.type=ajp13
worker.node2.lbfactor=1
worker.node2.cachesize=10

# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
#worker.loadbalancer.balance_workers=node1
worker.loadbalancer.sticky_session=0

#worker.list=loadbalancer
# Status worker for managing load balancer
worker.status.type=status

Posted by: jbossejb3 | June 25, 2008

uriworkermap.properties

# Simple worker configuration file
# Mount the Servlet context to the ajp13 worker
/jmx-console=loadbalancer
/jmx-console/*=loadbalancer
/web-console=loadbalancer
/web-console/*=loadbalancer

Posted by: jbossejb3 | June 25, 2008

mod-jk.conf

# Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module modules/mod_jk.so

# Where to find workers.properties
JkWorkersFile conf/extra/workers.properties

# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat “[%a %b %d %H:%M:%S %Y]“

# JkOptions indicates to send SSK KEY SIZE
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

# JkRequestLogFormat
JkRequestLogFormat “%w %V %T”

# Mount your applications
JkMount /MyApps/* loadbalancer

# You can use external file for mount points.
# It will be checked for updates each 60 seconds.
# The format of the file is: /url=worker
# /examples/*=loadbalancer
JkMountFile conf/extra/uriworkermap.properties

# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
JkShmFile logs/jk.shm

# Add jkstatus for managing runtime data
<Location /jkstatus/>
JkMount status
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>

Posted by: jbossejb3 | June 25, 2008

Setting up JBoss 5 AS cluster nodes

Edit deploy/messaging/messaging-service.xml set the value of ServerPeerID with a unique integer to identify the node. If you have two nodes, you can set the value to 0 for the first node and 1 for the second node.

All nodes will share a database for management. Remove the file deploy/messaging/hsqldb-persistence-service.xml. Copy the template file thirdparty/jboss/messaging/resources/mysql-persistence-service.xml to the directory deploy/messaging. Edit the file change all DefaultDS to the mysql data source you have created as explained in JTA Data Source: MySQL Database.

Older Posts »

Categories