How to detect startup state of Jboss 7(.1.1)Markus Lutum Aug 27, 2012 5:05 AM
Hi.
We have migrated our app to Jboss7.1.1 now.
Its a single ear file which is deployed in the standalone environment.
Because of some historical old stuff we need to know when the ear is completely deployed.
Then we have to trigger some initialization internally to really start some old non ejb3 services.
I tried to use serverState attribute at jboss.as:management-root=server or
checking state of my ear at "jboss.msc:type=container,name=jboss-as"
But the states are UP or RUNNING also before I see the line:
[org.jboss.as] (MSC service thread 1-31) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in .....
So can someone tell we how to detect when my application is deployed?
THX!!!
Marus Lutum
1. Re: How to detect startup state of Jboss 7(.1.1)Nicklas Karlsson Aug 27, 2012 5:32 AM (in response to Markus Lutum)
Perhaps it's just the JBAS015874 text being late? Have you compared when the .isDeployed marker files appear in relation to the RUNNING state and the JBAS015874?
2. Re: How to detect startup state of Jboss 7(.1.1)Markus Lutum Aug 27, 2012 7:49 AM (in response to Nicklas Karlsson)
No... the line is always the last line. Then all my @Startup singletons are started so the ear is completely ready.
If I check the serverState from one of the singletons the state is already RUNNING while my services and singletons are still starting....
Same as on the ear itself.
I checked it via JConsole on:
"jboss.msc:type=container,name=jboss-as"
and called getServiceStatus
on
jboss.deployment.unit."MYEARNAME.ear"
This returns UP as one of the returning properties also while it is still deploying...
Any Idea? maybe different MBean? Or Rest based info call?
3. Re: How to detect startup state of Jboss 7(.1.1)Nicklas Karlsson Aug 27, 2012 8:07 AM (in response to Markus Lutum)
Are you using @DependsOn?
4. Re: How to detect startup state of Jboss 7(.1.1)Markus Lutum Aug 27, 2012 8:46 AM (in response to Nicklas Karlsson)
No... my singletons normally handle dependencies automatically via @EJB
Can I create a dependsOn on the "ear module" or something "late"?
Like :
@Singleton(name="ServerStateCheckerService")
@Startup
@DependsOn("WHAT SHOULD GO IN HERE")
public class ServerStateCheckerServiceImpl
...
Then I can use this late service to do my derived initialization stuff
5. Re: How to detect startup state of Jboss 7(.1.1)Nicklas Karlsson Aug 27, 2012 8:55 AM (in response to Markus Lutum)
(it's probably only applicable within a single deployment. and there might also be other, non-singleton-dependecies to consider)
Not sure how people generally handle this, perhaps have all components report to a single (singleton?) place and when the last @PostContruct-initiated report comes in, kick things off?
6. Re: How to detect startup state of Jboss 7(.1.1)Martin Both Jan 28, 2016 3:10 AM (in response to Markus Lutum)
I'm using JBoss EAP 7.0 and check the state of the server during start up with the two MBeans you mentioned every second.
MBean 1 has the ObjectName("jboss.msc:type=container,name=jboss-as")
and I call the method "getServiceStatus" every second.
MBean 1 is always there and the method returns always "UP". I don't see any other state!
MBean 2 has ObjectName("jboss.as:management-root=server")
and I get the attribute "serverState" every second.
MBean 2 is not always there and I have to catch InstanceNotFoundException around mBeanServer.getAttribute().
After about 1 or 2 seconds the MBean 2 is there and the "serverState" attribute has got the value "starting".
After deployment messages and the message "WFLYSRV0025: EAP 7.0.0.Beta1 (WildFly Core 2.0.3.Final-redhat-1) started in 5669ms - Started 403 of 633 services"
the value of the "serverState" attribute changes to "running".
So MBean 2 does the job for me on JBoss EAP 7.0.
Best regards
Martin Both