How to declare dependency on a custom service?
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
Issue
Following are the steps to produce the issue.
-
Implement a
custom servicethat is sendingSNMP traps. -
This defined service is deployed on one of the servers and used by
EARdeployed on same/other server. -
When the sever is shutting down (which has the EAR), the
SNMP serviceis undeployed before the rest of the applications and those applications will never be able to send a trap with shut-down. -
How to
define dependency in custom SNMP service, where if theEARdeploys, theSNMP servicewill be already started and ready to use and when theEARis un-deployed, theSNMP serviceshould be still available so that the application will be able to sendSNMP traps.
Resolution
Following are the steps to define the dependency in custom service.
-
Create a new
DeploymentUnitProcessor(DUP) registered at the correct deployment phase to add aMSC dependencypreventing the deployment from moving to the next phase in the chain until the service is installed. -
For example, in this link, the
EE subsystemregisteringDUPs, and this link describes how to add service names toNEXT_PHASE_DEPS -
It is required to register a new
DUPin an appropriate phase, and have to addMasterAgentService.createServiceName()to theNEXT_PHASE_DEPSlist for any deployments that need to wait for it. -
The appropriate phase depends on how much of the deployment is required to be initialised before it waits for the SNMP agent to start, and the list is in this link
Root Cause
Red Hat JBoss Enterprise Application Platformdoes not provide the feature of defining dependecies for custome services.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
