In my EAR application running on Jboss AS 5.01 I'm trying to define a quartz service that may only start when the web module in the ear has completely started.
At first I just tried to use the following in my quartz service:
But for some reason this just hangs the server during startup.
I then tried to use BarrierController as per the advice found here: http://www.jboss.org/file-access/default/members/jbossas/freezone/docs/Server_Configuration_Guide/4/html/Additional_Services-The_BarrierController_Service.html
My quartz service now looks as follows:
<server> <!-- In this example we have the BarrierController controlling a Barrier that is started when we receive the "jboss.tomcat.connectors.started" notification from the Tomcat mbean, and stopped when we receive the "org.jboss.system.server.stopped" notification from the server mbean. The dependent services need only define a dependency on the Barrier mbean! --> <mbean code="org.jboss.system.BarrierController" name="jboss:service=BarrierController"> <!-- Whether to have the Barrier initially started or not --> <attribute name="BarrierEnabledOnStartup">false</attribute> <!-- Whether to subscribe for notifications after startup --> <attribute name="DynamicSubscriptions">true</attribute> <!-- Dependent services will depend on this mbean --> <attribute name="BarrierObjectName">jboss:name=TomcatConnector,type=Barrier</attribute> <!-- The notification subscription handback that starts the barrier --> <attribute name="StartBarrierHandback">start</attribute> <!-- The notification subscription handback that stops the barrier --> <attribute name="StopBarrierHandback">stop</attribute> <!-- The notifications to subscribe for, along with their handbacks --> <attribute name="SubscriptionList"> <subscription-list> <mbean name="jboss.web:service=WebServer" handback="start"> <filter factory="NotificationFilterSupportFactory"> <enable type="jboss.tomcat.connectors.started"/> </filter> </mbean> <mbean name="jboss.system:type=Server" handback="stop"> <filter factory="NotificationFilterSupportFactory"> <enable type="org.jboss.system.server.stopped"/> </filter> </mbean> </subscription-list> </attribute> </mbean> <mbean code="org.quartz.ee.jmx.jboss.QuartzService" name="user:service=myQuartzService,name=myQuartzService"> <depends>jboss.jca:service=DataSourceBinding,name=MyPostgresDS</depends> <depends>jboss.jca:service=DataSourceBinding,name=MyPostgresDS_NOTX</depends> <!-- The BarrierObjectName configured in the BarrierController --> <depends>jboss:name=TomcatConnector,type=Barrier</depends> <!-- rest omitted for brevity --> </mbean> </server>
However, I now get the following error when starting up Jboss AS:
DEPLOYMENTS MISSING DEPENDENCIES: Deployment "user:name=myQuartzService,service=myQuartzService" is missing the following dependencies: Dependency "jboss:name=TomcatConnector,type=Barrier" (should be in state "Start", but is actually in state "Create") DEPLOYMENTS IN ERROR: Deployment "jboss:name=TomcatConnector,type=Barrier" is in error due to the following reason(s): Create 18:23:16,979 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8081 18:23:17,008 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8082 18:23:17,024 INFO [ServerImpl] JBoss (Microcontainer) [5.0.1.GA (build: SVNTag=JBoss_5_0_1_GA date=200902232048)] Started in 56s:550ms
I don't understand why this is happening. It seems like the quartz service finds that the barrier has not started yet and then it immediately throws the error since the barrier has not started. However, wasn't the entire idea that it should be waiting for the barrier to have started? That was basically the whole point of adding the barrier.
Does someone knows how to actually let it wait?