New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for dynamic spring batch job invoication based on message header #968
Conversation
Can you run checkstyle and fix those issues mvn compile -Psourcecheck in the directory with the component. Also the header name should use naming: CamelComponentNameHeaderName, eg CamelSpringBatchXXXXX |
@@ -83,7 +85,7 @@ protected void doStart() throws Exception { | |||
if (jobLauncher == null) { | |||
jobLauncher = resolveJobLauncher(); | |||
} | |||
if (job == null && jobName != null) { | |||
if (job == null && jobName != null && jobName.compareTo("dynamic")!=0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"dynamic".equals(jobName)? But, what is wrong on setting initial jobName in URI path? AFAIK this concept is not used anywhare in Camel, so please remove the check for "dynamic".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi as jobName is the path and can't be made null beacause it's mandatory, "dynamic" keyword is used to omit the lookup of the Job and allow dynamic lookup based on message. Due to camel URI schema it's IMPOSSIBLe as you said in the ticket to make it null, so I need a keyword to know when it should be ignored. please check the ticket and your answer.
Can't you just use a dummy job name, and if there is a header that header take precedence. Or is there some pre-validation in the producer that a job with that name must exists? |
} | ||
} | ||
|
||
if (job2run == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is rednudant, this.job
is never null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it's not redundant. if the jobName is dynamic, then the job will be set to null by the Endpoint.
Hi, I was not aware of -Psourcecheck flag, I've added a new commit with the changes to correct the style warnings, sorry for the inconvenience.
where jobName is mockJob so I can't add this feature without breaking the backwards compatibility.. as jobName is the UriPath and it's mandatory, I can't just remove it, so I use "dynamic" As a dummy job from("direct:dynamic").to("spring-batch:dynamic"). |
@@ -25,6 +25,7 @@ | |||
public class SpringBatchComponent extends UriEndpointComponent { | |||
|
|||
private static final String DEFAULT_JOB_LAUNCHER_REF_NAME = "jobLauncher"; | |||
public static final String DYNAMIC_JOBNAME = "DYNAMIC_JOBNAME_HEADER"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static final String JOB_NAME = "CamelSpringBoot.jobName";
can we chat aboit this? skype? id: jlpedrosa |
Is it clear now why the dynamic is mandatory? There are no style check warnings, existing tests and new ones are passing. Rgds JL |
You intention for using "dynamic" in URI path is clear form beginning, but as I said, it is not good to create such a convention. What if somebody wants to name the job "dynamic" (or already named) and actually don't select the job by the new header? |
That point you said of someone using the job name "dynamic" is the only We could do something more elaborated like: Due to the sytax uri constrains the path must be set, even if (like in this So options)
I think 1) is the way forward.
|
Does a use case, that no job is known from beginning, really exist? I don't think so. If yes, then recipientList or toD are still in the game. |
Hi Tomas I understand you think drop the patch is best and use tod. In my opinion: In my use case I don't know any job during the route creation, as I'm And I doubt anyone would try to create a job with name "dynamic" or As I said in the Jira ticket, toD would work for me, but as Claus pointed Regards
|
I am not for rejecting the patch at all, I just don't like using a constant path to achieve a no-job endpoint during startup. |
Tomas, I agree with you, having a magic keyword, it's not a perfect solution, but So options)
maybe the answer is mixed? 2) for 2.18 and 1) for 2.17? Tomas, Claus is your call. On Fri, Apr 29, 2016 at 10:28 AM, Tomas Rohovsky notifications@github.com
|
} | ||
|
||
@Test | ||
public void dynamicJobWorksIfHeaderWithInvalidJobName() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this test be named dynamicJobFailsIfHeaderWithInvalidJobName
with the word Fails
replacing the word Works
?
We can add a query option |
Ok, that´s ok, I’ll implement it on monday, is it enough?
|
Yeah sounds good. Maybe open a new PR with the jobFromHeader so its easier to review |
@jlpedrosa are you able to work on a new PR? |
Hi Claus Yes, I'll get it done next week, is it ok?
|
Yes thats fine |
…Name in the headers, Test passed, code rules passed.
Contiunued in as a sugestion of @davsclaus |
Entesb 9237 2.23.x
Pull request for issue: https://issues.apache.org/jira/browse/CAMEL-9733