[Clustering/JBoss] - How to auto-start my singleton service?
by karanmg
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
19Â years
[JBoss Seam] - Multi-role components
by awheeler
I have a backing bean which is used in both the session and conversation context as follows:
| @Name("searchCompany")
| @Scope(ScopeType.SESSION)
| @Roles( {@Role(name="findCompany",scope=ScopeType.CONVERSATION)} )
|
In order for the outjected datamodel list to pick up the correct value on the page I have to use the page scope for the datamodel:
| @DataModel(value="companyList",scope=ScopeType.PAGE)
| public List<Company> getResultList() {
| return super.getResultList();
| }
|
If I do not limit the scope to page then if a I use the bean in a convesation and a previously instantiated session bean exists then the page (in a conversation) uses the session datamodel before a search has occured. Clicking on the list results in an error as the list was not generated by the conversation bean.
So it appears that I've solved my problem, but I can no longer use expressions such as the following in a dataTable:
| <s:link view="/secure/crm/editCompany.seam" action="#{editCompany.setInstance(company)}">
| #{company.companyName}
| </s:link>
|
I guess this is because the datamodel doesn't have "sufficient" scope at the time of the action, or perhaps seam doesn't look in the page scope when doing action events.
This problem is different from datamodelselection, which works for page scoped datamodel that postback to the same bean as the datamodel.
Is this just a fact of life with seam, or is there a better way ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4032264#4032264
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4032264
19Â years