I am using JDK 5, JBoss 4.0.5GA and Windows. I'm fairly familiar with
clustering, but barely with MBeans and sar archives.
I have gone through several posts, documentation and the wiki, and finally
managed to make a MBean service. I deployed the sar to farm/ it gets copied to
all nodes. When I go to the web-console, I can see that the service has been
successfully deployed on both the nodes. The jboss-service.xml of the sar
contains:
| <mbean code="com.tcore.jboss.service.SingletonServiceExample"
| name="tcore.services:service=SingletonServiceExample">
|
<depends>jboss.ha:service=HASingletonDeployer,type=Barrier</depends>
| <attribute name="Message">Message in the XML</attribute>
| </mbean>
|
Shouldn't the service automatically start on whichever node is the master?
I can manually invoke the start() operation which prints a diagnostic message
to let me know that the service has started. But how do I make it work so that
whichever node becomes master the service starts and when it loses master
status, the service stops?
Following is the service code:
| package com.tcore.jboss.service;
|
| public interface SingletonServiceExampleMBean
| {
| public String getMessage();
| public void setMessage(String message);
|
| public void printMessage();
| public boolean isTheMasterNode();
|
| public void startSingleton() throws Exception;
| public void stopSingleton();
| }
|
| package com.tcore.jboss.service;
|
| public class SingletonServiceExample implements SingletonServiceExampleMBean
| {
|
| private String message;
| private boolean theMasterNode = false;
|
| public void startSingleton() throws Exception
| {
| theMasterNode = true;
| message = "I have been started! " + theMasterNode;
| System.out.println("Starting with message: " + message);
| }
|
| public void stopSingleton()
| {
| theMasterNode = false;
| message = "I have been stopped!" + theMasterNode;
| System.out.println("Stopping with message: " + message);
| }
|
| public String getMessage()
| { return message; }
|
| public void setMessage(String message)
| { this.message = message; }
|
| public void printMessage()
| { System.out.println(message); }
|
| public boolean isTheMasterNode()
| { return theMasterNode; }
|
| }
|
Thanks!
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4032270#4032270
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4032270
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user