-
1. Re: Change schedule-provider configuration at runtime
camunda Dec 16, 2009 10:13 AM (in response to camunda)I am still searching for an easy and elegant solution, but it seems to be pretty hard. The way I found now is to go via the deployment, check for ESB deploymentmetadata and then use reflection a lot to query private fields until I "arrive" at the Trigger of the Scheudler. It is pretty hacky, but at least it works ;-)
Here is the code:
MBeanServer mbeanServer = MBeanServerLocator.locate(); MainDeployerMBean mainDeployer = (MainDeployerMBean) MBeanProxyExt.create(MainDeployerMBean.class, MainDeployerMBean.OBJECT_NAME, mbeanServer); Collection deployed = mainDeployer.listDeployed(); for (Object o : deployed) { if (o instanceof DeploymentInfo) { DeploymentInfo di = (DeploymentInfo) o; if (di.context.containsKey(JBoss4ESBDeploymentMetaData.class)) { JBoss4ESBDeploymentMetaData metaData = (JBoss4ESBDeploymentMetaData) di.context.get(JBoss4ESBDeploymentMetaData.class); if (metaData.getDeployment().getController() instanceof ManagedLifecycleController) { Field instancesField = ManagedLifecycleController.class.getDeclaredField("instances"); instancesField.setAccessible(true); ManagedLifecycle[] instances = (ManagedLifecycle[]) instancesField.get(metaData.getDeployment().getController()); instancesField.setAccessible(false); for (ManagedLifecycle instance : instances) { if (instance instanceof ScheduleListener) { // TODO check if we have the right scheduler depending on the service name (see sysout below) ScheduleListener sl = (ScheduleListener)instance; Field jobField = AbstractScheduledManagedLifecycle.class.getDeclaredField("job"); jobField.setAccessible(true); SchedulerJob job = (SchedulerJob) jobField.get(sl); jobField.setAccessible(false); Field triggerField = SchedulerJob.class.getDeclaredField("trigger"); triggerField.setAccessible(true); SimpleTrigger trigger = (SimpleTrigger) triggerField.get(job); triggerField.setAccessible(false); trigger.setRepeatInterval(100); System.out.println("#### CHANGED SCHEDULER : Service '" + sl.getConfig().getAttribute("service-name") + "' with trigger " + trigger); } } } } } }
Any comments? Anybody a better idea?
And on the other hand I think it is a trigger for the development of the ESB to allow easier configuration or at least access of it during runtime. Or is it intended, that this is not possible?
Cheers
Bernd
-
2. Re: Change schedule-provider configuration at runtime
tfennelly Dec 17, 2009 5:24 AM (in response to camunda)Hi Bernd.
As you have discovered, this is not really possible with the current codebase, without a hack. I think providing a clean API for this would probably require introduction of new APIs etc at the service/action level. I don't think there are any plans to do anything like this, but I'm not sure.
-
3. Re: Change schedule-provider configuration at runtime
ryanhos Dec 17, 2009 12:53 PM (in response to camunda)Bernd,
We've taken to re-writing the jboss-esb.xml on the fly and letting the deployer pick it up. We needed dynamic reconfiguration of FTP gateways to support user-defined subscriptions. Of course, this requires that you have deployment scanning on in production, which may not fit in with your current practices. It works so far. See the classes in jbossesb-config-model-1.1.0.jar, especially if you're already cursed to use xmlbeans. If not, you can try converting the jboss-esb.xsd to pojos. I tried it a few versions back and the schema had some mistakes related to an incomplete refactoring which prevented easy pojo generation, but I was eventually able to modify it enough to get Jibx's xsd-to-java tool to digest it fully. I haven't revisited it in quite a while (since 4.4) so perhaps things have changed.
-
4. Re: Change schedule-provider configuration at runtime
camunda Dec 18, 2009 4:32 AM (in response to ryanhos)Thanks for the answers! Yeah, it seems we have to go down the same path and reading and changing the jboss-esb.xml during runtime. Current plan is, to write an EJB3 for it. But will at least get tricky in a cluster ;-)
And at least I know I didn't completly miss the easy solution :-)