I am currently in the process of migrating a suite of enterprise applications from JBoss AS 4.2.2 to WildFly 9.0.2.
With assistance from ctomc, I recently addressed an issue with a small EAR application [called DataSourceManager] that dynamically configures data sources via JMX operations on deployment/startup with an MBean causing deadlocks in the deployment process. The issue and the application/deployment are described in further detail here: WildFly 9.0.2 MBean Start Method Timeout/Deadlock
The solution to the issue was to execute the JMX operations for data source configuration on a separate thread from the deployment thread. While this does address the deadlock issue, there is now an issue with MBeans in other applications in the suite attempting to access data sources, which are configured by the DataSourceManager application deployment process, during startup before the DataSourceManager has finished the data source configuration process.
There are two things I am looking to do, neither of which I am exactly sure how to do.
1. Ensure that the DataSourceManager EAR is always deployed first before other applications in the suite. The rest of the applications in the suite essentially relies on the DataSourceManager being deployed prior to them being deployed. In JBoss AS 4.2.2, the way that this appears to have been accomplished was by adding an "EnhancedSuffixes" attribute to the ear-deployer.xml configuration file like this:
<server> <mbean code="org.jboss.deployment.EARDeployer" name="jboss.j2ee:service=EARDeployer"> ... <attribute name="EnhancedSuffixes">646:DataSourceManager.ear,647:app2.ear,648:app3.ear,649:app4.ear,650:.ear</attribute> </mbean> </server>
I am not sure if there is a way to define a global deployment order like this in WildFly 9.0.2.
2. For applications that access data sources configured by DataSourceManager in MBeans during deployment/startup, ensure that the data sources needed by the application are configured. There are two ways I can think of doing this. One would be creating another MBean in the DataSourceManager application/EAR that is deployed after the main DataSourceManagerMBean that performs the configuration whose responsibility is to check that all data sources have been configured. This would maybe be done by checking if the JMX resource for the data source is registered with the MBeanServer used to configure it [although, based on what was said in the linked discussion, I am not sure if this would cause deadlock issues since it involves a JMX operation] or attempting to lookup the data sources and create connections, waiting/retrying for a finite period of time before throwing an exception. The other would be for each application/MBean to declare dependencies on the data sources it needs, which I am not sure how to do. While applications/MBeans did not do this previously because it was not necessary, I believe in JBoss AS 4.2.2, this could be configured in a jboss-service.xml descriptor like this:
<server> <mbean code="AppMBean" name="appdomain:service=AppMBean"> ... <depends>jboss.jca:service=DataSourceBinding,data-source=AppDS</depends> </mbean> </server>
I do not believe that this can be done in WildFly 9.0.2.
Any information or ideas about this would be very much appreciated.