Advertise with us

Our eBooks

JBoss AS Service Dependency: an use case

JBoss AS has plenty of services available ready for use. However sometimes you might have the need to start a certain service after that your deployments units are available. Let's see how we can choose to deploy a service after your applications.



A typical use case would be that the EJB Timer service, which is configured in the server deploy directory with the ejb3-timer-service.xml.
A tutorial about the EJB3 Timer service is available here

Supposing you want your Timer service to be started after that your applications (a Web application and an EJB application) are deployed as shown here:

jboss as service mbean depends

All you have to do is adding a <depends> attribute to the EJB3TimerService MBean. Open the ejb3-timer-service.xml. This file already contains some dependancies on other services, we will add here our deployment dependency:

    <mbean code="org.jboss.ejb3.timerservice.quartz.jmx.EJB3TimerService" name="jboss.ejb:service=EJB3TimerService">
        <depends optional-attribute-name="DataSource">jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
    <!-- WEB dependency -->
    <!-- EJB dependency -->
        <attribute name="Properties">
                 <!-- commented for brevity -->
As you can see, adding a dependency for a Web application is quite easy, you have just to add the WebContext name of the application. Dependency of an EJB application is also easy, you have just to state some additional information like the EJB Class name and the Service type (EJB3) as it falls in the generic jboss.j2ee tree. 
© 2021 All Rights Reserved.

Please publish modules in offcanvas position.