Project: springxd
Issue XD-705: A batch job can be launched by sending a message on a channel
*Description* When a job is ‘created’ in SpringXD, a ‘control-channel’ for that job is also created. The listener for that channel will receive a message, be able to take the ‘jobParameters’ and other launch information from the message, and be able to launch/run the job. NOTE: I can see a few other stories that should probably be made to break this up after writing it. I put estimate of 10 for now, but we should break this up. Here are some suggestions 1. create ‘data only’ JobParametersBean equivalent with primitive types 2. create jobLauncher source 3. create jobParameterTransformer processor 4. Refactoring of ChannelRegistry’s aliasHing to use a callback strategy. *Implementation Suggestions* job create --name helloWorldJob --definition "myjob --somePropertyToOverride=someValue * This would not execute the batch job immediately, but instead register the job definition and deploys a “jobLauncher�? and the job definition to an XD-Container. * The XD-Container that receives the deploy request message will create a module application context, will also create a channel with the Channel registry named after the job, e.g. :myJob. This should be a pub/sub channel from the point of view of the middleware. From the point of view of the spring integration channel, it should ideally be of the executor channel. There is a limitation in the current implementation of ChannelRegistry now as ‘createInbound’ only creates direct channels. The boolean ‘aliasHint’ should probably be extended to some type of callback that creates a channel. The aliasHint was added to address the case of LocalChannelRegistry creating or looking up a queue backed channel or a direct channel. There will be a consumer on the SI channel in the module application context that will be responsible for getting the job launch information and launching the job. The launching of the job may need to be explicitly done in a separate thread if direct channels are created by the ChannelRegistry. The contents of the message should be something similar to the current “JobParametersBean�?, it needs to be easily serializable with simple types via JSON over the wire. The current impl of “JobParametersBean�? has ObjectMapper, so that may require a bit of reworking. The handler of the message will use the jobLauncher to launch the job, using the information in the JobParametersBean. * The ‘myjob’ can then be launched by sending a message, perhaps this is handled by having a jobLauncher source jobLauncher [--jobParameters ] [--dateFormat ] [--numberFormat ] [--makeUnique ] > :myJob e.g. with no-args jobLauncher > :myJob *How to verify it works* With the test HelloSpringXDTasklet, we should be able to create the job job create --name helloSpringXD --definition "myjob" This will not launch the job (as mentioned in the ‘implementation’ section. It would then be launched by jobLauncher > :myJob where jobLauncher is a new source. Ideally would like to be able to test a data driven triggering. This would require a new file source that doesn’t use the file-to-string-transformer, but lets a File object be the payload. file | jobParameterTransformer > :myJob
Story points: 16