[wildfly-dev] Application shutdown code: recommended approach?

Thomas Segismont tsegismo at redhat.com
Thu May 23 10:27:39 EDT 2013


We have just one deployment, the RHQ EAR, which is deployed in "A Mixed 
Approach" manner, as described by Brian in this wiki page:
https://community.jboss.org/wiki/ExtendingAS7

I'm not expecting the server to determine a shutdown order, as it has no 
way to know which jobs our Quartz scheduler is currently running.

What I'm asking is an advice on how I can make one @Singleton bean 
automatically depend on all other beans in the deployment.

So far, the only solution I could imagine was a implementing a 
DeploymentUnitProcessor in a AS extension.

For the record, before we moved to AS7, our shutdown code was triggered 
by the notification of type STOP_NOTIFICATION_TYPE from the JBoss MBean 
server.

On startup:

ObjectName jbossServerName = new ObjectName("jboss.system:type=Server");
MBeanServer jbossServer = MBeanServerLocator.locateJBoss();
jbossServer.addNotificationListener(jbossServerName, new 
ShutdownListener(), null, null);

And in the ShutdownListener:

if 
(org.jboss.system.server.Server.STOP_NOTIFICATION_TYPE.equals(notification.getType()))
     // Do shutdown
}

Le 23/05/2013 15:09, Stuart Douglas a écrit :
> What are you actually asking for?
>
> I'm not really sure what your use case is, is there just one deployment?
> Can you be very specific as to what EJB's depend on other EJB's and why
> they have a dependency?
>
> Reading your email it sounds like you expect us to magically determine a
> shutdown order, which does not sound possible based on what you describe.
>
> Stuart
>
>
>
>
> Thomas Segismont wrote:
>> Hi,
>>
>> I recently created this BZ for EAP6.1:
>>
>> Bug 958217 - Unable to call Stateless bean methods from Singleton
>> PreDestroy callback
>> https://bugzilla.redhat.com/show_bug.cgi?id=958217
>>
>> I though I could call any EJB bean from a @Singleton @PreDestroy method
>> but, as Jaikiran pointed out, the @DependsOn annotation is needed to
>> prevent dependencies from being shutdown before this last call.
>>
>> While it is doable to manually list a few dependencies, it is obviously
>> not an option if your shutdown code virtually needs any of your EJB
>> beans to be available: in RHQ, we want to be able to shutdown a Quartz
>> scheduler gracefully, and the jobs running at shutdown might depend on
>> any EJB bean.
>>
>> I though of adding a DeploymentUnitProcessor which would automatically
>> make a "special" @Singleton bean (marked with an annotation) depend on
>> all over beans in the RHQ deployment.
>>
>> What do you think?
>>
>> Thanks and regards,
>> Thomas
>> _______________________________________________
>> wildfly-dev mailing list
>> wildfly-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/wildfly-dev
> _______________________________________________
> wildfly-dev mailing list
> wildfly-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/wildfly-dev
>



More information about the wildfly-dev mailing list