How to declare dependency on a custom service?

Solution Verified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x

Issue

Following are the steps to produce the issue.

  • Implement a custom service that is sending SNMP traps.

  • This defined service is deployed on one of the servers and used by EAR deployed on same/other server.

  • When the sever is shutting down (which has the EAR), the SNMP service is 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 the EAR deploys, the SNMP service will be already started and ready to use and when the EAR is un-deployed, the SNMP service should be still available so that the application will be able to send SNMP 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 a MSC dependency preventing the deployment from moving to the next phase in the chain until the service is installed.

  • For example, in this link, the EE subsystem registering DUPs, and this link describes how to add service names to NEXT_PHASE_DEPS

  • It is required to register a new DUP in an appropriate phase, and have to add MasterAgentService.createServiceName() to the NEXT_PHASE_DEPS list 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 Platform does 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.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.