You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "Mitko Kolev (JIRA)" <ji...@apache.org> on 2010/03/15 00:33:45 UTC
[jira] Created: (CAMEL-2549) Camel Exec component
Camel Exec component
--------------------
Key: CAMEL-2549
URL: https://issues.apache.org/activemq/browse/CAMEL-2549
Project: Apache Camel
Issue Type: New Feature
Affects Versions: 2.3.0
Environment: Tested on Windows XP and Linux
Reporter: Mitko Kolev
Fix For: 2.3.0
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Thomas Demande (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59049#action_59049 ]
Thomas Demande commented on CAMEL-2549:
---------------------------------------
Hi Mitko,
Thanks for your fast reply!
I took a look at what you said and it actually helped a lot:
About the needed reset, I was indeed 'reading' the stream twice, as I used {{trace="true"}} for my context...
Not using it does make the result appear in the log.
However, using stream caching does not help at all, so in a route using the wireTap pattern such as:
{code:xml}
<route streamCache="true">
<from uri="direct:testExec" />
<to uri="exec:dir"/>
<wireTap uri="seda:wireTap"/>
<to uri="seda:treatResult" />
</route>
{code}
the {{treatResult}} route would be unable to read the exec result without resetting it (with a bean?).
About the stdErr design, I think that the current SVN state makes using the exec component problematic in a "pure" Spring XML notation (without being 'forced' to use beans).
I think a basic usage of this component would be to launch the exec, then route the message using a CBR, based on the return code. Each route should then IMHO be able to get the exec result without being aware of the stream where it is located (err or out).
As you said, always restting streams in the converter would cause issues for streams that would throw an exception when calling reset(), but I really think that being able to use this component _transparently_ in the basic usage I described is a must have ;)
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59051#action_59051 ]
Mitko Kolev commented on CAMEL-2549:
------------------------------------
Hi everyone,
{quote}
Each route should then IMHO be able to get the exec result without being aware of the stream where it is located (err or out).
{quote}
If you have both {{stdout}} and {{stderr}} filled, it is hard to chose what would be a result, because this can be use-case specific. That's why I think it is important to have the body filled with the stdout (but not the stderr) by default. However it would make sense to write {{sdtderr}} in the out-body *only* when the {{stdout}} is {{null}}, for convenience. This must cover your case.
About the stream conversion, I think it would be better to reset the streams, only if they are of type {{ByteArrayInputStream}}, which is by default. This will be OK with the default implementation of {{ExecResult}}, and will not break other different input stream sources, however the component will behave differently on different input stream sources with not - resetable streams. I find the behavior acceptabe.
What do you think for both?
* Returning {{stderr}}, only when {{stdout}} is {{null}}
* Resetting the streams only if they are {{ByteArrayInputStream}}
BTW, i also tried different scenarios using a stream converter, and it did not do what i expected. I'll investigate the issue further.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Martin Krasser (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58606#action_58606 ]
Martin Krasser commented on CAMEL-2549:
---------------------------------------
Patch applied with thanks! Keep up the good work, Mitko! Would you mind to write some documentation in the Wiki, then I can close this issue.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Martin Krasser (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58270#action_58270 ]
Martin Krasser commented on CAMEL-2549:
---------------------------------------
>> In this (outCapable) case I write it additionally in the header to be consistent with the (in-only) case. There are 3 possible output values: exit value, stdout and stderr. In the in-only case both stdout and stderr, as well as the exit value are set as headers; the in-message is not touched. Now you know my concerns, what do you think would be most appropriate in this case?
Also in the in-only case, you should modify the message body.
>> In this case this would be similar to a call to System.setOut(new PrintStream(new FileOutputStream("file.output"). What will happens is that the standart output stream (stdout) will be empty, because nothing will be written to it. The output is printed namely in the new file stream. In this case one should define a custom executor and then read the file output manually.
Not quite. You mean stdout redirection but an executable might well write to stdout AND to one or more files. I rather thought about something like "exec:myprog?outfile=foo.txt". If an outfile is defined, use it to set the message body. Maybe it would make sense to introduce a special data structure to be set as message body that contains the data from 0..n output files, stdout and stderr data. A special type converter could then do conversions if needed. For example, if there's only data from stdout or from a single output file then a conversion to a String should be possible.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff, camel-exec-patch2.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Thomas Demande (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59036#action_59036 ]
Thomas Demande commented on CAMEL-2549:
---------------------------------------
I'm trying to use this component, and I'm currently seeing 2 problems:
- When invoking a program that fills {{stdErr}}, the content of that cannot be easily accessed without a deep inspection of the ExecResult.
I would have expected that the Converter would send the ExecResult {{stdErr()}} if it is not null.
- When *not* using the {{outFile}} parameter, the ExecResult {{stdOut}} (but also the {{stdErr}}) have to be reset, otherwise the Converter will return nothing as Body.
I'm using the latest revision of the component, and currently having such a route (in a Windows environment):
{code:xml}
(...)
<to uri="exec:dir"/>
<to uri="log:myLogger />
(...)
{code}
results in: {code}INFO: Exchange[BodyType:org.apache.camel.component.exec.ExecResult, Body:]{code} without the reset().
And, (worse), using the example
{code:xml}
(...)
<to uri="exec:java?args=-version"/>
<to uri="log:myLogger />
(...)
{code}
results in{code} INFO: Exchange[BodyType:org.apache.camel.component.exec.ExecResult, Body:org.apache.camel.component.exec.ExecResult@14382c6]{code}
as in this case it is in fact the {{stdErr}} that is filled.
Here's a diff excerpt (thrown exceptions should be also changed) that summarizes the solutions I quickly made to get it working like I thought it would be:
{code:java}
Index: components/camel-exec/src/main/java/org/apache/camel/component/exec/ExecResultConverter.java
===================================================================
@@ -105,10 +103,16 @@
if (execResult.getCommand().getOutFile() != null) {
return new FileInputStream(execResult.getCommand().getOutFile());
} else {
- if (execResult.getStdout() == null) {
- LOG.warn("Received null stdout of the ExecResult for conversion!");
- }
- return execResult.getStdout();
+ if(execResult.getStderr() != null){
+ execResult.getStderr().reset();
+ return execResult.getStderr();
+ } else {
+ if (execResult.getStdout() == null) {
+ LOG.warn("Received null stdout of the ExecResult for conversion!");
+ }
+ execResult.getStdout().reset();
+ return execResult.getStdout();
+ }
}
}
}
{code}
I may be wrong, but I think that such a behavior would be more usable.
Regards,
Thomas
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Martin Krasser (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58264#action_58264 ]
Martin Krasser commented on CAMEL-2549:
---------------------------------------
Mitko, thanks for your second patch and your good work. A few comments/questions after my initial review
* Why do your write the results from stdout to the message body AND header? Writing it to the body should be sufficient (preferrably as InputStream).
* What if the executable writes the results to a file. How should these be read then, in your opinion?
* What if the executable reads from stdin. How would one pass data in this case?
* In ExecParseUtils you do a lot of low-level command line tokenizing/parsing. Aren't there libraries available for that?
* Why do you define an ExecBinding interface + impl but do parts of reading/writing from/to an Exchange in ExecProducer directly? This should be the responsibility of the ExecBinding impl.
* A minor one: A timeout value should be typed as long instead of int (a hint in the javadocs that timeout is in milliseconds would be helpful too)
* I also agree with Claus' comments regarding # notation.
What do you think?
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff, camel-exec-patch2.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (CAMEL-2549) Camel Exec component
Posted by "Martin Krasser (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Krasser reassigned CAMEL-2549:
-------------------------------------
Assignee: Martin Krasser
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Martin Krasser (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58239#action_58239 ]
Martin Krasser commented on CAMEL-2549:
---------------------------------------
Thanks Mitko for your contribution. I'll take a look at it as soon as I can. Could you please write two or three sentences for us in JIRA about the purpose of the component?
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Martin Krasser (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58852#action_58852 ]
Martin Krasser commented on CAMEL-2549:
---------------------------------------
@Claus. I was about to review the patch and prepared a commit too but you've been faster :) What about the Wiki docs - do you want to add it or shall I?
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt
>
>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58279#action_58279 ]
Claus Ibsen commented on CAMEL-2549:
------------------------------------
I think the component should behave the same regardless what the MEP is set as InOnly or InOut etc. Eg data should be stored in headers / body the same way. Otherwise its too confusing.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff, camel-exec-patch2.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58242#action_58242 ]
Mitko Kolev commented on CAMEL-2549:
------------------------------------
Hi Martin,
thanks for the hint :)
with the component it possible to execute an OS command from a Camel route.
Here is a basic example to show what this component can be used for:
<camelContext ...>
<route>
...
<to uri="exec:java?args=-version&timeout=10000"/>
...
</route>
</camelContext>
The route will execute the "java -version" command in the working dir of the Camel application, and read stdout and stderr streams of the program. Additionally, if the process does not exit within 10000 milliseconds, the implementation will send a termination request. After the execution the stdout and stderr are stored in the message headers.
It is possible to set the working dir, timeout, and args as a list of white-space separated tokens. Quoting of the arguments with " is also supported.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59051#action_59051 ]
Mitko Kolev edited comment on CAMEL-2549 at 4/23/10 4:59 AM:
-------------------------------------------------------------
Hi everyone,
{quote}
Each route should then IMHO be able to get the exec result without being aware of the stream where it is located (err or out).
{quote}
If you have both {{stdout}} and {{stderr}} filled, it is hard to chose what would be a result, because this can be use-case specific. That's why I think it is important to have the body filled with the stdout (but not the stderr) by default. However it would make sense to write {{sdtderr}} in the out-body *only* when the {{stdout}} is {{null}}, for convenience. This must cover your case.
About the stream conversion, I think it would be better to reset the streams, only if they are of type {{ByteArrayInputStream}}, which is by default. This will be OK with the default implementation of the default {{ExecCommandExecutor}}, and will not break other different input stream sources, however the component will behave differently on different input stream sources with not - resetable streams. I find the behavior acceptabe.
What do you think for both?
* Returning {{stderr}}, only when {{stdout}} is {{null}}
* Resetting the streams only if they are {{ByteArrayInputStream}}
BTW, i also tried different scenarios using stream caching, and it did not do what i expected. I'll investigate the issue further.
was (Author: mkolev):
Hi everyone,
{quote}
Each route should then IMHO be able to get the exec result without being aware of the stream where it is located (err or out).
{quote}
If you have both {{stdout}} and {{stderr}} filled, it is hard to chose what would be a result, because this can be use-case specific. That's why I think it is important to have the body filled with the stdout (but not the stderr) by default. However it would make sense to write {{sdtderr}} in the out-body *only* when the {{stdout}} is {{null}}, for convenience. This must cover your case.
About the stream conversion, I think it would be better to reset the streams, only if they are of type {{ByteArrayInputStream}}, which is by default. This will be OK with the default implementation of {{ExecResult}}, and will not break other different input stream sources, however the component will behave differently on different input stream sources with not - resetable streams. I find the behavior acceptabe.
What do you think for both?
* Returning {{stderr}}, only when {{stdout}} is {{null}}
* Resetting the streams only if they are {{ByteArrayInputStream}}
BTW, i also tried different scenarios using a stream converter, and it did not do what i expected. I'll investigate the issue further.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mitko Kolev updated CAMEL-2549:
-------------------------------
Attachment: camel-exec-patch.diff
There is one TODO in the pom.xml that should be fixed.
The documentation will follow.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58269#action_58269 ]
Mitko Kolev commented on CAMEL-2549:
------------------------------------
Hi Martin and Claus,
thanks for the detailed review. I'll try to answer the questions:
>> 1) Why do your write the results from stdout to the message body AND header? Writing it to the body should be sufficient (preferrably as InputStream).
In this (outCapable) case I write it additionally in the header to be consistent with the (in-only) case. There are 3 possible output values: exit value, stdout and stderr. In the in-only case both stdout and stderr, as well as the exit value are set as headers; the in-message is not touched. Now you know my concerns, what do you think would be most appropriate in this case?
There is something else here: I initially assumed that it would be better to keep the component simple. Maybe it is better to introduce a new optional "encoding" parameter, so that the stdout and stderr have the right encoding (currently the default system codec is used).
>> What if the executable writes the results to a file. How should these be read then, in your opinion?
In this case this would be similar to a call to System.setOut(new PrintStream(new FileOutputStream("file.output"). What will happens is that the standart output stream (stdout) will be empty, because nothing will be written to it. The output is printed namely in the new file stream. In this case one should define a custom executor and then read the file output manually.
>> What if the executable reads from stdin. How would one pass data in this case?
The scenario is not supported by this initial implementation for simplicity. This can be be added further if needed.
>> In ExecParseUtils you do a lot of low-level command line tokenizing/parsing. Aren't there libraries available for that?
There is an Apache library for this - commons-exec. The funcitonality of the low level parser is actually a fix for an open critical bug, regarding quoting with \"\"quoted text\"\" (double - double quoted text) in commons exec http://issues.apache.org/jira/browse/EXEC-36, that is not plannedfor fixing. The bug occurs, when the arguments are given to a shell script (e.g. windows) in this case the semicolons or colons are treated as argument separators, and finally the batch script receives wrong args. I discovered this when i wrote my first test script, so i assume that more advanced uses of the component will also encounter the same hard-to-find problem.
I plan to contribute the functionality of the low level parser in Apache commons-exec. When this happens (or when they do a fix) the parser class can be dropped. You are completely right, Camel is not the best place for such a low level parser.
>> Why do you define an ExecBinding interface + impl but do parts of reading/writing from/to an Exchange in ExecProducer directly? This should be the responsibility of the ExecBinding impl.
You are right, this should be refactored
>> A minor one: A timeout value should be typed as long instead of int (a hint in the javadocs that timeout is in milliseconds would be helpful too)
Yes, this must be changed to long.
>> I also agree with Claus' comments regarding # notation.
Yes, I also agree. Should be changed.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff, camel-exec-patch2.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Thomas Demande (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59052#action_59052 ]
Thomas Demande commented on CAMEL-2549:
---------------------------------------
{quote}
Returning stderr, only when stdout is null
{quote}
Indeed, if both are filled, prefer the stdOut, as stdErr is available in the header.
{quote}
Resetting the streams only if they are ByteArrayInputStream
{quote}
(y)
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58545#action_58545 ]
Mitko Kolev commented on CAMEL-2549:
------------------------------------
Hi Claus,
I was actually planning to submit a patch tomorrow (must implement a few more tests).
The new stuff I implemented so far are:
* All refactorings pointed out in the feedback. Some details here - I implemented the in(out)-message body to be a {{ExecResult}} (with stdout, stderr, outFile, exit code etc.); stderr and the exit value are additionally written in the headers for convenience.
* Implementation of the functionality with the {{outFile}} - works basically as Martin suggested (body is {{ExecResult}}, and there is an {{ExecResult}} type converter)
* The in-message body, that the component receives, is converted to {{InputStream}} and sent as input to the stdin of the executable (was asked in the mailing lists)
Regards,
Mitko
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff, camel-exec-patch2.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mitko Kolev updated CAMEL-2549:
-------------------------------
Attachment: camel-exec-component-feedback.zip
Hi guys,
I am sending a new patch, where I implemented the stuff in my previous comment.
Regards,
Mitko
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mitko Kolev updated CAMEL-2549:
-------------------------------
Attachment: exec-wiki.txt
camel-exec-3.diff
Hello everyone,
I am attaching the wiki content, of the component documententation. I was not able to view the source of the Camel wiki pages as example, so thie wiki content has to be probably adapted to the Camel format (headers, logos etc).
I also found some issues in the code and fixed them:
* I removed the loggin of the stderr and stdout. It could cause inconvenience as the streams get read by the logging (must be reset in this case).
* The type of the command args is now List, when set from the headers. In this case the custom parser is not needed, so it is also not used.
* I addded the examples in the wiki docs as tests, that are @Ignored, so that the examples can be verified easily when needed
* I documented better some parts of the Java docs
* ExecResult is now value object
I tested the code with source checks and built it on Linux and Windows. If something else is needed, let me know.
Regards,
Mitko
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt
>
>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58851#action_58851 ]
Claus Ibsen commented on CAMEL-2549:
------------------------------------
Thanks for the 3rd patch. I have applied it to trunk: 934297.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt
>
>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Thomas Demande (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59140#action_59140 ]
Thomas Demande commented on CAMEL-2549:
---------------------------------------
Nice patch that covers what I needed, and works like a charm :)
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt, reset.output.in.converter.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58607#action_58607 ]
Mitko Kolev commented on CAMEL-2549:
------------------------------------
Hi Martin,
many thanks for the time you spent to review the code. I'll start with the docs as soon as I get an account for the Camel wiki. I'll fax the contributor agreement to ASF today.
Regards,
Mitko
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Martin Krasser (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58243#action_58243 ]
Martin Krasser commented on CAMEL-2549:
---------------------------------------
Cool! Very useful contribution. I'm very busy today but plan to take a closer look tomorrow. Thanks again!
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58531#action_58531 ]
Claus Ibsen commented on CAMEL-2549:
------------------------------------
How far are we from having a solution that we can put into Camel 2.3?
I am on the run for trimming the tickets so we can start narrow down and get a 2.3 release in the works. Would be cool to have 2.3 out in may 2010.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff, camel-exec-patch2.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mitko Kolev updated CAMEL-2549:
-------------------------------
Attachment: camel-exec-patch2.diff
Hi Martin,
here is something that could be relevant for you when you evaluate the code.
In the tests in patch "camel-exec-patch.diff" i assumed, that "java" is available on the system path. I realized yesterday, that it would make sense to assume, that the JAVA_HOME environment variable is set, because JAVA_HOME is used in the mvn scripts anyway.
Something else: in one of the tests i execute a test-script. Because JDK 1.5 does not have the canExecute() method, the test could, at least in theory, break the build if there are not enough priviledges to execute the test-script. Therefore I set @Ignore on this test.
I am sending a new patch that fixes those two issues.
Thanks again.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff, camel-exec-patch2.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58282#action_58282 ]
Mitko Kolev commented on CAMEL-2549:
------------------------------------
Hi again,
Many thanks for the extensive feedback!
I find Martin's suggestion for
{code}
exec:myprog?outfile=foo.txt
{code}
very useful, but i need some time to think it out and implement it. I'll write back when i am ready with it, and the other stuff from the feedback as well.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff, camel-exec-patch2.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (CAMEL-2549) Camel Exec component
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Claus Ibsen resolved CAMEL-2549.
--------------------------------
Resolution: Fixed
Thanks a lot Mitko for the really great documentation.
I have added it to wiki
https://cwiki.apache.org/confluence/display/CAMEL/Exec
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt
>
>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59113#action_59113 ]
Claus Ibsen commented on CAMEL-2549:
------------------------------------
Mitko thanks for the patch. I have applied it to trunk: 938323.
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt, reset.output.in.converter.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Claus Ibsen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=58260#action_58260 ]
Claus Ibsen commented on CAMEL-2549:
------------------------------------
Good work
In Camel 2.x you can use the # notation to lookup complex objects from endpoint uris. So no need to have xxxRef string parameters anymore.
So I recon all the custom code you have in ExecComponent can be handled out of the box, using the {{setProperties}} method.
You should still set the remaning as the executable. But the reference lookup and whatnot should all be handed out of the box.
And then you do not need any special xxRef options at all.
eg
{code}
?commandExecutorRef=myCmdExec
{code}
becomes
{code}
?commandExecutor=#myCmdExec
{code}
So the component code could probably be changed to something like this
{code}
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ ExecEndpoint endpoint = new ExecEndpoint(uri, this);
setProperties(endpoint, parameters);
endpoint.setExecutable(remaining);
+ return endpoint;
{code}
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-patch.diff, camel-exec-patch2.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mitko Kolev updated CAMEL-2549:
-------------------------------
Attachment: reset.output.in.converter.diff
Hello everyone,
i am sending a patch with the proposed improvements.
Regards,
Mitko
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt, reset.output.in.converter.diff
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CAMEL-2549) Camel Exec component
Posted by "Mitko Kolev (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/activemq/browse/CAMEL-2549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=59042#action_59042 ]
Mitko Kolev commented on CAMEL-2549:
------------------------------------
Hi Thomas,
Thanks for the feedback!
I will check your use case today.
Some initial comments:
* You can easily access the {{stderr}} from the message headers. If there is no {{stderr}}, the header value must be {{null}}.
* I assume you read the stream twice once in the log ( i suppose you do it once again after the log). If there is a second read it will generally need a reset. This is a common problem when you read from streams. Did you try using the Camel stream caching for that route, I think it is designed exactly for such cases.
{code}
I would have expected that the Converter would send the ExecResult stdErr() if it is not null.
{code}
This is rather a design issue, that can be easily implemented, as you just noticed. However, the solution you proposed will not work if the stream is not resetable (this could be the case if someone is using a custom executor).
I will think over your suggestion and write back here later today.
Regards,
Mitko
> Camel Exec component
> --------------------
>
> Key: CAMEL-2549
> URL: https://issues.apache.org/activemq/browse/CAMEL-2549
> Project: Apache Camel
> Issue Type: New Feature
> Affects Versions: 2.3.0
> Environment: Tested on Windows XP and Linux
> Reporter: Mitko Kolev
> Assignee: Martin Krasser
> Fix For: 2.3.0
>
> Attachments: camel-exec-3.diff, camel-exec-component-feedback.zip, camel-exec-patch.diff, camel-exec-patch2.diff, exec-wiki.txt
>
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.