google Analytics

Monday, September 20, 2010

Jboss Cluster Configuration

Jboss Cluster Configuration


Starting with a newly unzipped copy of JBoss, navigate into the server
directory and copy the
 all directory twice: once to a directory called
node1 and once to a directory called node2. The contents of your server
directory should now look like that

Issue the following command

run -c node1 -g  cluster1 -u -b localhost -Djboss.messaging.ServerPeerID=1 -Djboss.service.binding.set=ports-01
run  -c node2 -g cluster2 -u -b localhost -Djboss.messaging.ServerPeerID=1 -Djboss.service.binding.set=ports-02


Creating a clustered EJB

The remote interface for a clustered SLSB
import javax.ejb.Remote;
public interface TestRemote {
  public void sayHello(String msg);

The bean code for a clustered SLSB
import javax.ejb.Stateless;
import org.jboss.ejb3.annotation.Clustered;
public class TestBean implements Counter {
  public void sayHello(String msg) {
@org.jboss.ejb3.annotation.Clustered annotation defined.
This annotation tells the server that this bean is clustered and should be load balanced.

Calling the clustered EJB
The client code that calls the clustered SFSB

import javax.naming.Context;
import javax.naming.InitialContext;
public class Client {
  public static void main(String[] args) throws Exception {
    InitialContext ctx = new InitialContext();
    TestRemote s = (TestRemote) ctx.lookup("TestBean/remote");
    for (int i = 0; i < 100; i++) {

includes the client/jbossallclient.jar in your classpath
The file

jboss clustering example/clustering with JBOSS 5.0/ejb
jboss clustering step by step
jboss clustering step by step
@clustered annotation
EJB Clustering Example


No comments:

Post a Comment