Re: Workaround interceptFrom().transacted()

2013-10-01 Thread Claus Ibsen
Use advice-with if you wanna "mess around" with routes.


On Fri, Sep 27, 2013 at 5:05 PM, Charles Moulliard  wrote:
> Hi,
>
> Since Camel 2.12, the following syntax is not longer tolerated/accepted. Is
> there a workaround 
>
> public void testInvalidTransactedInterceptFrom() throws Exception {
> try {
> context.addRoutes(new RouteBuilder() {
> @Override
> public void configure() throws Exception {
>
> interceptFrom().transacted();
>
> from("direct:start")
> .split(body())
> .to("mock:split")
> .end();
> }
> });
> fail("Should fail");
> } catch (IllegalArgumentException e) {
> assertTrue(e.getMessage().startsWith("The output must be added
> as top-level on the route."));
> }
> }
>
> Regards,
>
> --
> Charles Moulliard
> Apache Committer / Architect @RedHat
> Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Workaround interceptFrom().transacted()

2013-10-01 Thread Charles Moulliard
AdviceWith can only be used for unit test.
The problem that the customer would like to solve is the following :
Customer has developed some classes that the project will use to develop
Camel routes. These classes are abstract RouteBuilder class where
strategies have been developed to handle functional, technical Exception
but also transaction behavior. Advantage is that the developer does not
need to add .transacted in their routes.


On Tue, Oct 1, 2013 at 9:18 AM, Claus Ibsen  wrote:

> Use advice-with if you wanna "mess around" with routes.
>
>
> On Fri, Sep 27, 2013 at 5:05 PM, Charles Moulliard 
> wrote:
> > Hi,
> >
> > Since Camel 2.12, the following syntax is not longer tolerated/accepted.
> Is
> > there a workaround 
> >
> > public void testInvalidTransactedInterceptFrom() throws Exception {
> > try {
> > context.addRoutes(new RouteBuilder() {
> > @Override
> > public void configure() throws Exception {
> >
> > interceptFrom().transacted();
> >
> > from("direct:start")
> > .split(body())
> > .to("mock:split")
> > .end();
> > }
> > });
> > fail("Should fail");
> > } catch (IllegalArgumentException e) {
> > assertTrue(e.getMessage().startsWith("The output must be
> added
> > as top-level on the route."));
> > }
> > }
> >
> > Regards,
> >
> > --
> > Charles Moulliard
> > Apache Committer / Architect @RedHat
> > Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com
>
>
>
> --
> Claus Ibsen
> -
> Red Hat, Inc.
> Email: cib...@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>



-- 
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog : http://cmoulliard.blogspot.com


Re: Camel route - how to move the file in the failed directory if there's an error

2013-10-01 Thread Claus Ibsen
camel-spring-batch would have to fail with an exception for the file
consumer to move the file to the failed directory.

Not sure how spring batch triggers this. I suggest to dive into the
source code / unit tests to take a look.

On Tue, Oct 1, 2013 at 12:31 AM, nguyen  wrote:
> Oups the route didn't show.. Inserted now the route definition.
>
>  xmlns="http://camel.apache.org/schema/spring";>
> 
> 
> Route to poll a directory for transaction alert file and 
> launch the job
> 
> 
> uri="file:{{batch.process.watch.directory}}?include={{transaction.file.name.pattern}}&delay={{transaction.file.poll.delay}}&doneFileName=${file:name}.sig&move={{batch.process.done.directory}}&moveFailed={{batch.process.failed.directory}}"
> />
> 
> ${headers.CamelFileNameOnly}
>
>
> 
> 
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Camel-route-how-to-move-the-file-in-the-failed-directory-if-there-s-an-error-tp5740611p5740613.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: CAMEL + CXF+ ACTIVE MQ

2013-10-01 Thread pannereselvam
Thanks Willem.




--
View this message in context: 
http://camel.465427.n5.nabble.com/CAMEL-CXF-ACTIVE-MQ-tp5740278p5740648.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Read a stream from telnet service

2013-10-01 Thread David Wicki
Thank you for your answer. I think I'm going to implement the logic 
myself and feed a JMS queue. From there on, I can use Camel...


 -David



On 09/30/2013 12:54 PM, Claus Ibsen wrote:

This is not currently possible out of the box in any of the camel-mina
or camel-netty components.

You can of course use Mina or Netty API and write the logic yourself.

There is some tickets in JIRA about having camel-mina supporting to
connect to a remote server and read input as a stream.



On Fri, Sep 27, 2013 at 10:28 AM, David Wicki  wrote:

Hi all!

I'm new to this mailing list - and new to camel;-)

What I'm trying to do is, connecting to a tcp port (which is a telnet
service) and continuously read the character stream that is sent through the
connection. The stream basically "never" ends. The stream of characters can
be divided into separate messages. The separator is a keyword. So, the
stream could look like:

...message 5message6message7






Re: Camel's use of jsch/java.io

2013-10-01 Thread Claus Ibsen
Hi

The code is in jsch? If so you should report this to the jsch team.

On Tue, Oct 1, 2013 at 6:46 AM, neil  wrote:
> Hi,
> I would like to report a potential bug in Camel's use of jsch/java.io, and
> find a potential workaround.
>
> Apologies in advance for abusing terms -- I am only a Camel user, I am not
> intimately familiar with its implementation.
>
> We have an indefinite polling route that does a directory listing on a
> third-party's sftp server, and subsequently downloads "new" files and does
> things with them.
>
> A couple times per year, this route halts apparent operation with no error
> logged, and no impact to other jvm activities.  The impact of this behavior
> is dire to us -- there is no error reported, yet Camel is not doing
> anything.
>
> Looking at a thread dump, the "sftp" camel thread is stuck in an apparent
> infinite loop in java.io.PipedInputStream.read().  Ignoring the deeply weird
> use of thread safety in this class for a moment, it appears that this can
> happen if Camel moves its processor instance of this sftp route to a
> different thread while it is processing.
>
> public synchronized int read() throws IOException {
> if (!connected) {
> throw new IOException("Pipe not connected");
> } else if (closedByReader) {
> throw new IOException("Pipe closed");
> } else if (writeSide != null && !writeSide.isAlive()
> && !closedByWriter && (in < 0)) {
> throw new IOException("Write end dead");
> }
>
> readSide = Thread.currentThread();
> int trials = 2;
> while (in < 0) {
> if (closedByWriter) {
> /* closed by writer, return EOF */
> return -1;
> }
> if ((writeSide != null) && (!writeSide.isAlive()) && (--trials < 0))
> {  // <- If writeSide is null, infinite loop?
> throw new IOException("Pipe broken");
> }
> /* might be a writer waiting */
> notifyAll();
> try {
> wait(100);  // <  MY THREAD SPENDS 100% TIME HERE
> } catch (InterruptedException ex) {
> throw new java.io.InterruptedIOException();
> }
> }
> int ret = buffer[out++] & 0xFF;
> if (out >= buffer.length) {
> out = 0;
> }
> if (in == out) {
> /* now empty */
> in = -1;
> }
> return ret;
> }
>
>
> Might that be the case?  If it is, what is the recommended way of tearing
> down a route and then rebuilding it?  Most of the "shutdown" docs are aimed
> at shutting down an entire container, which we most certainly do not want to
> do.
>
> And should camel do this by default on routes that use
> jsch/java.io.PipedInputStream as a transport implementation?  It seems like
> the resources required to spin up a new thread would be dwarfed by creating
> a new ssh connection.
>
> If that is not the case, is there any other known issue about polling sftp
> routes?  I've googled around and I have not found anything, yet we have seen
> this half a dozen times over the last few months.
>
> Any advice is appreciated!
>
> Thanks!
> -neil
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Camel-s-use-of-jsch-java-io-tp5740623.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: @XmlElement overriding @JsonProperty

2013-10-01 Thread Claus Ibsen
Hi

Did you look into this? Maybe there is a flag/option you can set in
jackson to have it favor @JsonProperty over JAXB. If so maybe there is
something we can add to camel-jackson, so you can turn this flag
on/off.

On Wed, Jul 17, 2013 at 11:57 PM, Craig Tataryn  wrote:
> I'm working on a little route for my blog feed, essentially I have a route
> that looks like this:
>
> from("rss:...")
> .marshal().rss()
> .split(xpath("//item"))
> .unmarshal(jaxb)
> //do stuff to my Article object
> .marshal().json(JsonLibrary.Jackson)
>
> My problem is, when I marshal my model object to json I don't want it to
> have the same names as the element names from the XML the object was
> created from.
>
> So for instance, the model object that is created by JAXB has properties
> such as:
>
> @XmlElement(name = "encoded",namespace = "
> http://purl.org/rss/1.0/modules/content/";)
> @JsonProperty("body")
> public void setBody(String body)...
>
> What appears to be happening is the json marshalling seems to be respecting
> the element name from the @XmlElement annotation instead of the name given
> in the @JsonProperty annotation.  In fact, it appears to ignore all @Json*
> annotations for any property that has an @XmlElement annotation associated
> with it.  So instead of "body": properties in my json I end up with
> "encoded": properties
>
> Has anyone else run into this?  It's pretty maddening :(
>
> Thanks,
>
> Craig
>
> --
> Craig Tataryn
> site: http://www.basementcoders.com/
> irc: ThaDon on freenode #basementcoders
> twitter: craiger



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


FTP siteCommand Option

2013-10-01 Thread anakin59490
Hi,

i want to upload file to a server but when i run the program, i got this
message :
"Writing file failed with: File operation failed: 501 File must be specified
by library/file.member.
 Cannot change directory to: /. Code: 501"
 
Because when i login to the server, i login to AS400  

I think i have find the solution by using QUOTE SITE NAMEFMT ftp subcommand
:
http://www-01.ibm.com/support/docview.wss?uid=nas8N1017416

But i don't know how to use it with camel 

I try : ftp://login@server//directory?password=password&siteCommand=QUOTE
SITE NAMEFMT 0

but i get : "Writing file failed with: Site command: QUOTE SITE NAMEFMT 0
returned false"


Is it the right syntax ?
Is siteCommand the right option to use ?


Thank you for your help 




--
View this message in context: 
http://camel.465427.n5.nabble.com/FTP-siteCommand-Option-tp5740653.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Bean component/Bean Binding: Body as InputStream parametr (specified as ${body} in route)

2013-10-01 Thread radek_kraus
Hello,
I am playing with "bean binding" on bean component. I know, that I can solve my 
requirements by another way. 
But anyway I think, that my "syntetic" example doesn't work how I expect (I 
tested it with Camel 2.11.2, 2.12.1).

I have a "streamBodyBindingBean" bean with this method:

public void bodyBinding(InputStream in) throws IOException {
  int byteCount = 0;
  int c;
  while((c = in.read()) != -1)
byteCount++;
  System.out.println("ByteCount: " + byteCount);
}

And this route:


  
  
  
  


Here is a way how I send exchange from test stuff:

ByteArrayInputStream in = new ByteArrayInputStream(
  "Small body, which I want to bind as InputStream".getBytes("UTF-8")
);
Exchange exchange = createExchangeWithBody(in);
exchange.getIn().setHeader("testHeader", "testHeader");
exchange.setPattern(ExchangePattern.InOnly);
template.send("direct://body-input-stream-binding-in", exchange);

In this case I got a sysout message: "ByteCount: 0".
When I used the commented variant in route, I got expected result: "ByteCount: 
47",  => is it an ${body} evaluation problem?

I think that the reason is MethodInfo class, line 526 (with strange comment for 
me):

// the parameter value was not already valid, but since the simple language 
have evaluated the expression
// which may change the parameterValue, so we have to check it again to see if 
its now valid
exp = exchange.getContext().getTypeConverter().convertTo(String.class, 
parameterValue);
// String values from the simple language is always valid
if (!valid) {
  ...
}

The line after "strange" comment caused that my "InputStream" is transformed 
into String (what can be a problem in case of "big" InputStream).
The question is, why this line isn't in "if(!valid)" block? I am unable to 
decide, if it is a problem, which should be reported to JIRA or 
I only don't understand how bean binding should work or if I have only 
"stupid/incorrect" example.

This i a reason, why I ask first here.

Thank you for any feedback.
Radek Kraus.


Re: Bean component/Bean Binding: Body as InputStream parametr (specified as ${body} in route)

2013-10-01 Thread Taariq Levack
Hi

Looks like you're trying to read the stream twice, try again after enabling
stream-caching[1]

[1] http://camel.apache.org/stream-caching.html

Taariq


On Tue, Oct 1, 2013 at 11:25 AM,  wrote:

> Hello,
> I am playing with "bean binding" on bean component. I know, that I can
> solve my requirements by another way.
> But anyway I think, that my "syntetic" example doesn't work how I expect
> (I tested it with Camel 2.11.2, 2.12.1).
>
> I have a "streamBodyBindingBean" bean with this method:
>
> public void bodyBinding(InputStream in) throws IOException {
>   int byteCount = 0;
>   int c;
>   while((c = in.read()) != -1)
> byteCount++;
>   System.out.println("ByteCount: " + byteCount);
> }
>
> And this route:
>
> 
>   
>   
>   
>   
> 
>
> Here is a way how I send exchange from test stuff:
>
> ByteArrayInputStream in = new ByteArrayInputStream(
>   "Small body, which I want to bind as InputStream".getBytes("UTF-8")
> );
> Exchange exchange = createExchangeWithBody(in);
> exchange.getIn().setHeader("testHeader", "testHeader");
> exchange.setPattern(ExchangePattern.InOnly);
> template.send("direct://body-input-stream-binding-in", exchange);
>
> In this case I got a sysout message: "ByteCount: 0".
> When I used the commented variant in route, I got expected result:
> "ByteCount: 47",  => is it an ${body} evaluation problem?
>
> I think that the reason is MethodInfo class, line 526 (with strange
> comment for me):
>
> // the parameter value was not already valid, but since the simple
> language have evaluated the expression
> // which may change the parameterValue, so we have to check it again to
> see if its now valid
> exp = exchange.getContext().getTypeConverter().convertTo(String.class,
> parameterValue);
> // String values from the simple language is always valid
> if (!valid) {
>   ...
> }
>
> The line after "strange" comment caused that my "InputStream" is
> transformed into String (what can be a problem in case of "big"
> InputStream).
> The question is, why this line isn't in "if(!valid)" block? I am unable to
> decide, if it is a problem, which should be reported to JIRA or
> I only don't understand how bean binding should work or if I have only
> "stupid/incorrect" example.
>
> This i a reason, why I ask first here.
>
> Thank you for any feedback.
> Radek Kraus.
>


Apache Camel - Multicast - Is there a 'null' or a similar endpoint ?

2013-10-01 Thread arunodhaya80
Please excuse stupidity as this is my first Camel application 

1. To respond to a web request, I am sourcing the content from two different
sources. 
2. I am, therefore, making a multicast request to two methods and
parallelizing it.
3. The response is an marshalled JSON object (using camel-jackson)

All works fine. 

public class RestToBeanRouter extends RouteBuilder{

@Override
public void configure() throws Exception {

from("cxfrs://bean://rsServer")
   
.multicast()
.parallelProcessing()
.aggregationStrategy(new CoreSearchResponseAggregator())
.beanRef("searchRestServiceImpl", "firstMethod")
.beanRef("searchRestServiceImpl", "secondMethod")
.end()
.marshal().json(JsonLibrary.Jackson)
.to("log://camelLogger?level=DEBUG");

}


**Question :** 

The Multicast routing expects a `to` in the DSL.  Currently, I am mapping
this to a `log` endpoint.  Is this fine? 

Since I am not using the `to` and the last exchange of the Aggregator
strategy is the one which is returned to the user, should my endpoint be
configured to something else - like a null or something? (Ah, the stupidity
kicks in)



--
View this message in context: 
http://camel.465427.n5.nabble.com/Apache-Camel-Multicast-Is-there-a-null-or-a-similar-endpoint-tp5740664.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Bean component/Bean Binding: Body as InputStream parametr (specified as ${body} in route)

2013-10-01 Thread radek_kraus
Thanks for answer..

But IMHO it isn't  "stream-caching" problem. I have stream-caching enabled by 
"camel-context" attribute:


In addition, when I change the route, where I used bean component twice:

  
  
  
  


I got this result:

2013-10-01 12:26:37.259 DEBUG {main} [SendProcessor]  
Endpoint[bean://isBodyBindingBean?method=bodyBinding%28%24%7Bbody%7D%29] 
Exchange[Message: [Body is instance of org.apache.camel.StreamCache]]
ByteCount: 0
2013-10-01 12:26:37.289 DEBUG {main} [SendProcessor]  
Endpoint[bean://isBodyBindingBean] Exchange[Message: [Body is instance of 
org.apache.camel.StreamCache]]
ByteCount: 47
2013-10-01 12:26:37.307 DEBUG {main} [SendProcessor]  
Endpoint[mock://body-input-stream-binding-out] Exchange[Message: [Body is 
instance of org.apache.camel.StreamCache]]

__
> Od: Taariq Levack 
> Komu: 
> Datum: 01.10.2013 11:43
> Předmět: Re: Bean component/Bean Binding: Body as InputStream parametr 
> (specified as ${body} in route)
>
>Hi
>
>Looks like you're trying to read the stream twice, try again after enabling
>stream-caching[1]
>
>[1] http://camel.apache.org/stream-caching.html
>
>Taariq
>
>
>On Tue, Oct 1, 2013 at 11:25 AM,  wrote:
>
>> Hello,
>> I am playing with "bean binding" on bean component. I know, that I can
>> solve my requirements by another way.
>> But anyway I think, that my "syntetic" example doesn't work how I expect
>> (I tested it with Camel 2.11.2, 2.12.1).
>>
>> I have a "streamBodyBindingBean" bean with this method:
>>
>> public void bodyBinding(InputStream in) throws IOException {
>>   int byteCount = 0;
>>   int c;
>>   while((c = in.read()) != -1)
>> byteCount++;
>>   System.out.println("ByteCount: " + byteCount);
>> }
>>
>> And this route:
>>
>> 
>>   
>>   
>>   
>>   
>> 
>>
>> Here is a way how I send exchange from test stuff:
>>
>> ByteArrayInputStream in = new ByteArrayInputStream(
>>   "Small body, which I want to bind as InputStream".getBytes("UTF-8")
>> );
>> Exchange exchange = createExchangeWithBody(in);
>> exchange.getIn().setHeader("testHeader", "testHeader");
>> exchange.setPattern(ExchangePattern.InOnly);
>> template.send("direct://body-input-stream-binding-in", exchange);
>>
>> In this case I got a sysout message: "ByteCount: 0".
>> When I used the commented variant in route, I got expected result:
>> "ByteCount: 47",  => is it an ${body} evaluation problem?
>>
>> I think that the reason is MethodInfo class, line 526 (with strange
>> comment for me):
>>
>> // the parameter value was not already valid, but since the simple
>> language have evaluated the expression
>> // which may change the parameterValue, so we have to check it again to
>> see if its now valid
>> exp = exchange.getContext().getTypeConverter().convertTo(String.class,
>> parameterValue);
>> // String values from the simple language is always valid
>> if (!valid) {
>>   ...
>> }
>>
>> The line after "strange" comment caused that my "InputStream" is
>> transformed into String (what can be a problem in case of "big"
>> InputStream).
>> The question is, why this line isn't in "if(!valid)" block? I am unable to
>> decide, if it is a problem, which should be reported to JIRA or
>> I only don't understand how bean binding should work or if I have only
>> "stupid/incorrect" example.
>>
>> This i a reason, why I ask first here.
>>
>> Thank you for any feedback.
>> Radek Kraus.
>>
>


Consumer template get stuck when calling receive() with SMPP uri and getting a negative response.

2013-10-01 Thread mamouros
I am using the consumer template to receive deliver_sm from an smsc.

exchange = consumer.receive("smpp://" + username + "@" + destination + ":" +
port + "?password=" + password , timeoutInMillis);

So far, so good but when it can't connect to the smsc (maybe because of
wrong username or password), the smsc returns:

p - 2.1.0.4 | Receive negative bind response
org.jsmpp.extra.NegativeResponseException: Negative response 000e found

and then tries to reconnect for ever:

2013-10-01 13:25:26,790 | INFO  | Thread-1642  | SmppConsumer   
 
| el.component.smpp.SmppConsumer$2  155 | 172 - org.apache.camel.camel-smpp
- 2.11.0 | Trying to reconnect to smpp://8000800120@213.249.19.247: -
attempt #85...

I don't want it to try to reconnect for ever and getting stuck there. I
would like to continue after it gets a negative bind response and move on so
it can call the route again.
How could I do this.

Tried with error handler in context:





and with try() catch() block surrounding the consumer.receive()

but nothing..





--
View this message in context: 
http://camel.465427.n5.nabble.com/Consumer-template-get-stuck-when-calling-receive-with-SMPP-uri-and-getting-a-negative-response-tp5740666.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: [ConsumerTemplate] CamelLocks deleted before file is completely processed

2013-10-01 Thread Aida
Hi,

I have been investigating about this issue, because using the same
ConsumerTemplate doesn´t seem to fix it.

Just in case it can help somebody, I have seen that the
MarkerFileExclusiveReadLockStrategy#deleteLockFiles method is called once
per endpoint. So if two endpoints differ only in the "fileName" parameter
(but both files are in the same dir) this method is called and the
.camelLocks are removed.

If somebody has this problem he or she could try using a GenericFileFilter
implementation to filter by fileName. I haven´t tried it because this
approach has problems consuming files in parallel as I will comment in [1]
in some minutes. But if there is no need of concurrency, give it a try.

BR.

[1]
http://camel.465427.n5.nabble.com/ConsumerTemplate-Concurrency-problems-in-Camel-2-11-2-attached-test-td5740295.html


Claus Ibsen-2 wrote
> Hi
> 
> Yes create the template once and reuse it. See this page it also
> applies to consumer template
> http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html
> 
> On Fri, Sep 20, 2013 at 1:55 PM, Aida <

> ai.desu@

> > wrote:
>> Hi,
>>
>> I'm using the consumer template for reading files, and I'm experiencing
>> something that makes me think that I'm not using it correctly. What
>> happens
>> to me is:
>>
>> 1. I have a dir with multiple files
>> 2. The consumer template reads one of those files, creating a camelLock
>> file
>> for the file that is going to be processed
>> 3. The consumer template reads another file (same route, different
>> thread)
>> and, since the camelLock of the previous file still exists, deletes it
>> and
>> creates the camelLock for the file that is going to be processed now (the
>> previous file haven´t ended its processing and haven´t been "finished"
>> using
>> the doneUnitOfWork)
>> 4. The same for each file that is read (the camelLocks are removed and a
>> WARNING appears in the log " Deleting orphaned lock file: .../..
>> .camelLock")
>>
>> I think that maybe this is because I'm creating a new consumerTemplate
>> each
>> time I have to read something (could it be?), because I have seen that it
>> has a ConsumerCache.
>>
>> The problem is that I use some "rules" to use it (one of them creating
>> the
>> CT each time), because of some problems I have had in the past:
>>
>> - Don´t use the disconnect option for FTPs (Nullpointer, at least in
>> Camel
>> 2.9.0 that leaves threads alive, Camel post in [1])
>> - Create a new Consumer template each time I read a file (same reasons as
>> previous sentence) and stop it after use
>> - I synchronize the method that consumes an endpoint because otherwise,
>> when
>> reading files in parallel instead of reading two files, the consumer
>> reads
>> one twice
>>
>>
>> In case it can helps, I put my code here:
>>
>> ConsumerTemplate cTemplate =
>> camelContext.createConsumerTemplate();
>> Exchange dataExchange = null;
>> if(timeoutInMilis == 0){
>> dataExchange = cTemplate.receiveNoWait(endpoint2Consume);
>> }
>> else{
>> dataExchange = cTemplate.receive(endpoint2Consume,
>> timeoutInMilis);
>> }
>> try {
>> cTemplate.stop();
>> } catch (Exception e) {
>> log ...
>> }
>>
>>
>> Thanks in advance
>>
>> Camel Version: 2.10.4
>> [1]
>> http://camel.465427.n5.nabble.com/FTP-ConsumerTemplate-Threads-remaining-alive-td5548338.html#a5723551
>>
>>
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/ConsumerTemplate-CamelLocks-deleted-before-file-is-completely-processed-tp5739870.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 
> -- 
> Claus Ibsen
> -
> Red Hat, Inc.
> Email: 

> cibsen@

> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen





--
View this message in context: 
http://camel.465427.n5.nabble.com/ConsumerTemplate-CamelLocks-deleted-before-file-is-completely-processed-tp5739870p5740681.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Apache Camel - war project How to process the Queue and set to another queue?

2013-10-01 Thread James Carman
Have you tried turning up logging to see what's going on?  Camel gets
very descriptive at DEBUG level

On Mon, Sep 30, 2013 at 11:17 AM, kosalads  wrote:
> Hi James,
>
>   So how do we handle the below scenario with Camel?
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Apache-Camel-war-project-How-to-process-the-Queue-and-set-to-another-queue-tp5740524p5740574.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Jetty consumer - how to send reply?

2013-10-01 Thread Dale King
On Oct 1, 2013, at 2:14 AM, Claus Ibsen  wrote:

> You can do
> 
> setBody(constant(new File("")))

That works if the file name is fixed at the time of route construction.

The method I showed using simple and the built in conversion from string to 
File will allow you to determine the file name dynamically when the route is 
running, which is what I needed in my case.



Re: [ConsumerTemplate] Concurrency problems in Camel 2.11.2 (attached test)

2013-10-01 Thread Aida
Hi,

About reading files concurrently with the consumerTemplate, if this can help
somebody in the future:

I have found out that without using an implementation of GenericFileFilter
in order to get the right file (but using the "fileName" endpoint parameter
instead) there are no problems reading concurrently (all files are read and
there are no mixtures of data).

So the problem seems to happen when the same endpoint is read concurrently.


I had this (see the link to the test of the previous message for more info):

GenericFileFilterByName filter = new
GenericFileFilterByName(fileNameEncoded);   
GenericFileEndpoint endpoint2Consume = (GenericFileEndpoint)
CamelContextHelper.getMandatoryEndpoint(camelContext, ENDPOINT_TO_CONSUME);
endpoint2Consume.setFilter(filter);

Exchange dataExchange = consumer.receive(endpoint2Consume, 
1);


And now if I just add the fileName option (and without using the filter), it
works as expected:

Exchange dataExchange = consumer.receive(ENDPOINT_TO_CONSUME +
"?fileName=" + fileName, 1);


Conclusion: apparently, if you want to read files with the consumerTemplate
in parallel you must use different endpoints for each file


BR,

   Aida



Aida wrote
> Hi,
> 
> I have upgraded to Camel 2.11.2 . I'm trying to use the consumerTemplate
> for read files in parallel but I have two kind of errors:
> 
> - Files that are not read (the receive method returns null when the file
> exists)
> - The content of the files is mixed (If I have the file "1.txt" with
> content "" and "2.txt" with content "" the consumerTemplate gives
> me the "2.txt" with content "1")
> 
> 
> I have written a test class that tests this (sometimes fails because of
> the first error and others because of the second).
> 
> I attach it in case it can be of any help. The test works if I use the
> consumerTemplate synchronizing the method that uses it, but it doesn´t
> when I remove it.
> 
> What the test does:
> 
>   - Write a specified number of files (by default 5) in the target dir. 
> All
> files are different with different content. The file "N.txt" has
> ".." as content
>   - Start a route that reads in parallel (using a bean that uses the
> consumerTemplate) all these files (one by one, in parallel)
>   - The test retrieves the read exchanges and makes assertions to check
> that all files have been read and that these files have the right content.
>   
> All what is needed is in the same class (to execute it the package
> declaration must be updated for the appropiate one).
> 
> 
> I supposed that in Camel 2.11.2, as the consumerTemplate is threadSafe I
> could do this (read different files in parallel). Maybe It's not possible
> ...
> 
> 
> Thanks in advance.
> 
>   Aida.
> 
> The test class is this: 
> ConsumerTemplateUsageTest.java
> 
>   




--
View this message in context: 
http://camel.465427.n5.nabble.com/ConsumerTemplate-Concurrency-problems-in-Camel-2-11-2-attached-test-tp5740295p5740698.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: SJMS component and IBM Websphere MQ quirks

2013-10-01 Thread nigel
Ah - no I didn't - that's much neater. Thanks



--
View this message in context: 
http://camel.465427.n5.nabble.com/SJMS-component-and-IBM-Websphere-MQ-quirks-tp5740588p5740699.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel's use of jsch/java.io

2013-10-01 Thread neil
The code that pointed out is in java.io.PipedInputStream.read().

I believe Camel's thread management is triggering an infinite loop in it,
although I am not certain.

Is there a graceful way to have a Camel polling route completely reset
itself periodically?  Or is bouncing the container a better option?

Thanks,
-neil



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-s-use-of-jsch-java-io-tp5740623p5740700.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: dynamicly change the url of the element after the camelcontext is started

2013-10-01 Thread salemi
Thank you Babak. Since we are using Camel 2.10 we are using the
BridgePropertyPlaceholderConfigurer as followed below:





How does BridgePropertyPlaceholderConfigurer with the PropertiesComponent?

Thanks,
Ali





-
Alireza Salemi
--
View this message in context: 
http://camel.465427.n5.nabble.com/dynamicly-change-the-url-of-the-from-element-after-the-camelcontext-is-started-tp5740599p5740702.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Creating routes dynamically like a for()

2013-10-01 Thread mamouros
I would like to create a route for every query my sql route returns.
>From this:

from("sql:" + fromUri + "?dataSource=dataSource")
.to("bean:SmsReceiver?method=creatingRoutes");

I want to make something hypothetically like this:

for( from("sql:" + fromUri + "?dataSource=dataSource") )  {

 .to("bean:SmsReceiver?method=creatingRoutes");

}

so if I have 3 entries in my table, I would create 3 routes.

How is that possible. Is there any EIP that does that?



--
View this message in context: 
http://camel.465427.n5.nabble.com/Creating-routes-dynamically-like-a-for-tp5740703.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Creating routes dynamically like a for()

2013-10-01 Thread Dale King
Not clear what you are trying to achieve exactly, but I think what you want is 
the splitter which in this case you would use to execute the route for each 
record. Something like the following will call the method for each record 
returned from the SQL.

from("sql:" + fromUri + "?dataSource=dataSource")
.split(body())
.to("bean:SmsReceiver?method=creatingRoutes");

On Oct 1, 2013, at 11:58 AM, mamouros  wrote:

> I would like to create a route for every query my sql route returns.
> From this:
> 
> from("sql:" + fromUri + "?dataSource=dataSource")
> .to("bean:SmsReceiver?method=creatingRoutes");
> 
> I want to make something hypothetically like this:
> 
> for( from("sql:" + fromUri + "?dataSource=dataSource") )  {
> 
> .to("bean:SmsReceiver?method=creatingRoutes");
> 
> }
> 
> so if I have 3 entries in my table, I would create 3 routes.
> 
> How is that possible. Is there any EIP that does that?
> 
> 
> 
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Creating-routes-dynamically-like-a-for-tp5740703.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



Re: dynamicly change the url of the element after the camelcontext is started

2013-10-01 Thread Babak Vahdat
You can reach/do the same there as well see the setter method:

BridgePropertyPlaceholderConfigurer#setResolver

Through which you can inject your own PropertiesResolver implementation. So
to recapitulate, just implement you own PropertiesResolver by extending
DefaultPropertiesResolver. Then implement resolveProperties as:

public class MyPropertiesResolver extends DefaultPropertiesResolver {

public Properties resolveProperties(CamelContext context, boolean
ignoreMissingLocation, String... uri) throws Exception {
Properties answer = super.resolveProperties(context,
ignoreMissingLocation, uri);

// now retrieve the remaining *dynamic* properties from the DB and
add them all to
// the answer

return answer;
}

}

And then inject this PropertiesResolver to
BridgePropertyPlaceholderConfigurer using the setter method above.

Babak


salemi wrote
> Thank you Babak. Since we are using Camel 2.10 we are using the
> BridgePropertyPlaceholderConfigurer as followed below:
> 
> 
>  class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer" >
> 
> 
> 
> 
> How does BridgePropertyPlaceholderConfigurer with the PropertiesComponent?
> 
> Thanks,
> Ali





--
View this message in context: 
http://camel.465427.n5.nabble.com/dynamicly-change-the-url-of-the-from-element-after-the-camelcontext-is-started-tp5740599p5740705.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Invoking remote RESTful services urgent !!

2013-10-01 Thread Tracy Snell
Here's code I use to expose a REST url externally to an internal REST service.

from(BASE_URI + "/doctor?bindingStyle=SimpleConsumer&resourceClasses=" 
+ DoctorLookupService.class.getName())
  .setHeader(Exchange.HTTP_URI,
 
simple("http://my.company.com/CT/GetContact.svc/npi/${header.npi}";))
.setHeader("Authorization", simple("Basic foobarred="))
.setHeader("CamelHttpPath", simple(""))
.to("http://igetoverridden.com?throwExceptionOnFailure=false";);

Just use the http(4) component and set the appropriate URL. In my case it's 
dynamic so I stuff it in the header and that overrides the one in the .to

On Sep 30, 2013, at 1:49 PM, vjboston  wrote:

> 
> Can somebody share a sample code for invoking an remote restful service.
> I tried it with following code 



SFTP component help: Reading only modified content of a file in regular invervals

2013-10-01 Thread gudiseashok


Hi Is there anyway to read only modified content from a file?

I have a job scheduler which calls a remote directory which always have same
set of files (a.log,a1.log,a2.log,a3.log)
and It will replicated the same folder in local with those files, So If am
reading same folder after 30 minutes, I wonder to check is there any
efficient way to call only modified content from a file?

Because If it is possible to read only modified content from a file (which
already have it my local), it saves my job alot.

I apprecieate your time reading this, kindly suggest.

Regards
Ashok Gudise




--
View this message in context: 
http://camel.465427.n5.nabble.com/SFTP-component-help-Reading-only-modified-content-of-a-file-in-regular-invervals-tp5740713.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel's use of jsch/java.io

2013-10-01 Thread Bengt Rodehav
Hello Neil,

I use the sftp component quite a lot. Now and then (perhaps once in a
month) it stops polling. I think the problem to that lies in the Jsch
itself and not in Camel. I'm not sure if it is the same problem you have
though.

I also took stack traces and found that Jsch was stuck in a read operation
but I think that was a socket read operation. It seems like Jsch does not
use TCP keepalive. This means that if the other end disconnects (or someone
in between), Jsch will never be notified and hangs forever in a read.

Instead Jsch relies on a timeout higher up in the protocol level (it might
be part of SSH I'm not sure). This timeout can be set by specifying the
"serverAliveInterval" parameter in the sftp component.

Using a polling delay of 6 ms, we now set the serverAliveInterval to
1ms. We haven't had any problems since (no proof though since we've
only been doing it for less than three months).

Although it isn't necessarily the same problem, it might still be worth
trying the serverAliveInterval parameter.

/Bengt


2013/10/1 neil 

> The code that pointed out is in java.io.PipedInputStream.read().
>
> I believe Camel's thread management is triggering an infinite loop in it,
> although I am not certain.
>
> Is there a graceful way to have a Camel polling route completely reset
> itself periodically?  Or is bouncing the container a better option?
>
> Thanks,
> -neil
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-s-use-of-jsch-java-io-tp5740623p5740700.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: contentObjectId in XML Security (camel-xmlsecurity)

2013-10-01 Thread atiato
Hi Claus , 

I didn't get any reply for this ? should we open this as JIRA ?

thanks,
Omar Atia



--
View this message in context: 
http://camel.465427.n5.nabble.com/contentObjectId-in-XML-Security-camel-xmlsecurity-tp5740265p5740707.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Camel + myBatis Issue

2013-10-01 Thread Ankur
Hi all,

I am copying data from one datadource to another datasource using mybatis
component.

i achieved it but during insertion i'm getting issues.

how to perform batch insert using myBatis. Any other way as i'm using oracle
database.

Kindly help me to resolve this issue

thanks 




--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-myBatis-Issue-tp5740706.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Updating properties via JMX

2013-10-01 Thread PMulido
I know properties can be updated in a running camel instance by updating the
properties file directly.

Is there any way to expose / update  properties via JMX?

The use case would be turning a property of SEND_EMAIL=true to false via JMX
?




--
View this message in context: 
http://camel.465427.n5.nabble.com/Updating-properties-via-JMX-tp5740716.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: contentObjectId in XML Security (camel-xmlsecurity)

2013-10-01 Thread Claus Ibsen
We did some changes try with latest source code

On Tue, Oct 1, 2013 at 6:55 PM, atiato  wrote:
> Hi Claus ,
>
> I didn't get any reply for this ? should we open this as JIRA ?
>
> thanks,
> Omar Atia
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/contentObjectId-in-XML-Security-camel-xmlsecurity-tp5740265p5740707.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Bean component/Bean Binding: Body as InputStream parametr (specified as ${body} in route)

2013-10-01 Thread Claus Ibsen
Hi

Yeah sounds like a bug. Do you mind logging a JIRA ticket?

On Tue, Oct 1, 2013 at 11:25 AM,   wrote:
> Hello,
> I am playing with "bean binding" on bean component. I know, that I can solve 
> my requirements by another way.
> But anyway I think, that my "syntetic" example doesn't work how I expect (I 
> tested it with Camel 2.11.2, 2.12.1).
>
> I have a "streamBodyBindingBean" bean with this method:
>
> public void bodyBinding(InputStream in) throws IOException {
>   int byteCount = 0;
>   int c;
>   while((c = in.read()) != -1)
> byteCount++;
>   System.out.println("ByteCount: " + byteCount);
> }
>
> And this route:
>
> 
>   
>   
>   
>   
> 
>
> Here is a way how I send exchange from test stuff:
>
> ByteArrayInputStream in = new ByteArrayInputStream(
>   "Small body, which I want to bind as InputStream".getBytes("UTF-8")
> );
> Exchange exchange = createExchangeWithBody(in);
> exchange.getIn().setHeader("testHeader", "testHeader");
> exchange.setPattern(ExchangePattern.InOnly);
> template.send("direct://body-input-stream-binding-in", exchange);
>
> In this case I got a sysout message: "ByteCount: 0".
> When I used the commented variant in route, I got expected result: 
> "ByteCount: 47",  => is it an ${body} evaluation problem?
>
> I think that the reason is MethodInfo class, line 526 (with strange comment 
> for me):
>
> // the parameter value was not already valid, but since the simple language 
> have evaluated the expression
> // which may change the parameterValue, so we have to check it again to see 
> if its now valid
> exp = exchange.getContext().getTypeConverter().convertTo(String.class, 
> parameterValue);
> // String values from the simple language is always valid
> if (!valid) {
>   ...
> }
>
> The line after "strange" comment caused that my "InputStream" is transformed 
> into String (what can be a problem in case of "big" InputStream).
> The question is, why this line isn't in "if(!valid)" block? I am unable to 
> decide, if it is a problem, which should be reported to JIRA or
> I only don't understand how bean binding should work or if I have only 
> "stupid/incorrect" example.
>
> This i a reason, why I ask first here.
>
> Thank you for any feedback.
> Radek Kraus.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Updating properties via JMX

2013-10-01 Thread Christian Müller
Did you checked http://camel.apache.org/camel-jmx.html ?


Best,
Christian
-

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Tue, Oct 1, 2013 at 9:06 PM, PMulido  wrote:

> I know properties can be updated in a running camel instance by updating
> the
> properties file directly.
>
> Is there any way to expose / update  properties via JMX?
>
> The use case would be turning a property of SEND_EMAIL=true to false via
> JMX
> ?
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Updating-properties-via-JMX-tp5740716.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


AW: Creating routes dynamically like a for()

2013-10-01 Thread jhm
What you could do is generating a xml file with the new route definitions
and load that.
http://camel.apache.org/loading-routes-from-xml-files.html

from("sql ...")
.process( generateRoutesXmlProcessor )
.doTypeConversionFromXmlToInputStream
.process( loadRoutesProcessor )

Jan

> -Ursprüngliche Nachricht-
> Von: mamouros [mailto:csst0...@yahoo.gr]
> Gesendet: Dienstag, 1. Oktober 2013 17:58
> An: users@camel.apache.org
> Betreff: Creating routes dynamically like a for()
> 
> I would like to create a route for every query my sql route returns.
> From this:
> 
> from("sql:" + fromUri + "?dataSource=dataSource")
> .to("bean:SmsReceiver?method=creatingRoutes");
> 
> I want to make something hypothetically like this:
> 
> for( from("sql:" + fromUri + "?dataSource=dataSource") )  {
> 
>  .to("bean:SmsReceiver?method=creatingRoutes");
> 
> }
> 
> so if I have 3 entries in my table, I would create 3 routes.
> 
> How is that possible. Is there any EIP that does that?
> 
> 
> 
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Creating-routes-dynamically-like-a-
> for-tp5740703.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



Re: Apache Camel - Multicast - Is there a 'null' or a similar endpoint ?

2013-10-01 Thread Christian Müller
This doesn't sounds right.
Can you provide a unit test which shows this behavior and attach it to a
JIRA [1]!?

[1] http://camel.apache.org/contributing.html

Best,
Christian
-

Software Integration Specialist

Apache Camel committer: https://camel.apache.org/team
V.P. Apache Camel: https://www.apache.org/foundation/
Apache Member: https://www.apache.org/foundation/members.html

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Tue, Oct 1, 2013 at 12:28 PM, arunodhaya80  wrote:

> Please excuse stupidity as this is my first Camel application
>
> 1. To respond to a web request, I am sourcing the content from two
> different
> sources.
> 2. I am, therefore, making a multicast request to two methods and
> parallelizing it.
> 3. The response is an marshalled JSON object (using camel-jackson)
>
> All works fine.
>
> public class RestToBeanRouter extends RouteBuilder{
>
> @Override
> public void configure() throws Exception {
>
> from("cxfrs://bean://rsServer")
>
> .multicast()
> .parallelProcessing()
> .aggregationStrategy(new CoreSearchResponseAggregator())
> .beanRef("searchRestServiceImpl", "firstMethod")
> .beanRef("searchRestServiceImpl", "secondMethod")
> .end()
> .marshal().json(JsonLibrary.Jackson)
> .to("log://camelLogger?level=DEBUG");
>
> }
>
>
> **Question :**
>
> The Multicast routing expects a `to` in the DSL.  Currently, I am mapping
> this to a `log` endpoint.  Is this fine?
>
> Since I am not using the `to` and the last exchange of the Aggregator
> strategy is the one which is returned to the user, should my endpoint be
> configured to something else - like a null or something? (Ah, the stupidity
> kicks in)
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Apache-Camel-Multicast-Is-there-a-null-or-a-similar-endpoint-tp5740664.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Scala DSL lacks a way to specify return type of language expressions

2013-10-01 Thread Dale King
The language support in the Scala DSL is too simplistic in that it does not
support all the options of Java DSL.

In particular it does not allow setting the return type of the expression.
In my case I am trying to  set a header to the result of an xpath count
expression. In the Java DSL this fails unless you explicitly set the return
type of the xpath expression because the default return type for xpath is a
node set and it cannot convert a number to a node set.

It also lacks all the other overloads for things like Namespaces on xpath,
etc.

-- 
Dale King


Re: Bean component/Bean Binding: Body as InputStream parametr (specified as ${body} in route)

2013-10-01 Thread Taariq Levack
If you're not aware and you need a workaround and this suits your scenario,
you'll get the body as the InputStream if you don't use Simple.
ie 

Taariq


On Tue, Oct 1, 2013 at 9:35 PM, Claus Ibsen  wrote:

> Hi
>
> Yeah sounds like a bug. Do you mind logging a JIRA ticket?
>
> On Tue, Oct 1, 2013 at 11:25 AM,   wrote:
> > Hello,
> > I am playing with "bean binding" on bean component. I know, that I can
> solve my requirements by another way.
> > But anyway I think, that my "syntetic" example doesn't work how I expect
> (I tested it with Camel 2.11.2, 2.12.1).
> >
> > I have a "streamBodyBindingBean" bean with this method:
> >
> > public void bodyBinding(InputStream in) throws IOException {
> >   int byteCount = 0;
> >   int c;
> >   while((c = in.read()) != -1)
> > byteCount++;
> >   System.out.println("ByteCount: " + byteCount);
> > }
> >
> > And this route:
> >
> > 
> >   
> >   
> >   
> >   
> > 
> >
> > Here is a way how I send exchange from test stuff:
> >
> > ByteArrayInputStream in = new ByteArrayInputStream(
> >   "Small body, which I want to bind as InputStream".getBytes("UTF-8")
> > );
> > Exchange exchange = createExchangeWithBody(in);
> > exchange.getIn().setHeader("testHeader", "testHeader");
> > exchange.setPattern(ExchangePattern.InOnly);
> > template.send("direct://body-input-stream-binding-in", exchange);
> >
> > In this case I got a sysout message: "ByteCount: 0".
> > When I used the commented variant in route, I got expected result:
> "ByteCount: 47",  => is it an ${body} evaluation problem?
> >
> > I think that the reason is MethodInfo class, line 526 (with strange
> comment for me):
> >
> > // the parameter value was not already valid, but since the simple
> language have evaluated the expression
> > // which may change the parameterValue, so we have to check it again to
> see if its now valid
> > exp = exchange.getContext().getTypeConverter().convertTo(String.class,
> parameterValue);
> > // String values from the simple language is always valid
> > if (!valid) {
> >   ...
> > }
> >
> > The line after "strange" comment caused that my "InputStream" is
> transformed into String (what can be a problem in case of "big"
> InputStream).
> > The question is, why this line isn't in "if(!valid)" block? I am unable
> to decide, if it is a problem, which should be reported to JIRA or
> > I only don't understand how bean binding should work or if I have only
> "stupid/incorrect" example.
> >
> > This i a reason, why I ask first here.
> >
> > Thank you for any feedback.
> > Radek Kraus.
>
>
>
> --
> Claus Ibsen
> -
> Red Hat, Inc.
> Email: cib...@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>


Re: Creating routes dynamically like a for()

2013-10-01 Thread kraythe .
Just put the for outside. I do this all the time.

for (final String path : paths) {
  from("file://" + path +"?readlock=changed").to(...) ...
}

This will create four identical routes other than the file paths. if there
are four elements in paths.

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39*


On Tue, Oct 1, 2013 at 4:20 PM, Jan Matèrne (jhm)  wrote:

> What you could do is generating a xml file with the new route definitions
> and load that.
> http://camel.apache.org/loading-routes-from-xml-files.html
>
> from("sql ...")
> .process( generateRoutesXmlProcessor )
> .doTypeConversionFromXmlToInputStream
> .process( loadRoutesProcessor )
>
> Jan
>
> > -Ursprüngliche Nachricht-
> > Von: mamouros [mailto:csst0...@yahoo.gr]
> > Gesendet: Dienstag, 1. Oktober 2013 17:58
> > An: users@camel.apache.org
> > Betreff: Creating routes dynamically like a for()
> >
> > I would like to create a route for every query my sql route returns.
> > From this:
> >
> > from("sql:" + fromUri + "?dataSource=dataSource")
> > .to("bean:SmsReceiver?method=creatingRoutes");
> >
> > I want to make something hypothetically like this:
> >
> > for( from("sql:" + fromUri + "?dataSource=dataSource") )  {
> >
> >  .to("bean:SmsReceiver?method=creatingRoutes");
> >
> > }
> >
> > so if I have 3 entries in my table, I would create 3 routes.
> >
> > How is that possible. Is there any EIP that does that?
> >
> >
> >
> > --
> > View this message in context:
> > http://camel.465427.n5.nabble.com/Creating-routes-dynamically-like-a-
> > for-tp5740703.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


Re: Apache Camel - Multicast - Is there a 'null' or a similar endpoint ?

2013-10-01 Thread kraythe .
It would work. Multicast doesnt indicate anything more than more than one
destination. Those destinations could be two JMS queues, a queue and a log,
whatever you like. All your code would do is log the message but if that is
what you want then go for it.

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39*


On Tue, Oct 1, 2013 at 4:34 PM, Christian Müller <
christian.muel...@gmail.com> wrote:

> This doesn't sounds right.
> Can you provide a unit test which shows this behavior and attach it to a
> JIRA [1]!?
>
> [1] http://camel.apache.org/contributing.html
>
> Best,
> Christian
> -
>
> Software Integration Specialist
>
> Apache Camel committer: https://camel.apache.org/team
> V.P. Apache Camel: https://www.apache.org/foundation/
> Apache Member: https://www.apache.org/foundation/members.html
>
> https://www.linkedin.com/pub/christian-mueller/11/551/642
>
>
> On Tue, Oct 1, 2013 at 12:28 PM, arunodhaya80  wrote:
>
> > Please excuse stupidity as this is my first Camel application
> >
> > 1. To respond to a web request, I am sourcing the content from two
> > different
> > sources.
> > 2. I am, therefore, making a multicast request to two methods and
> > parallelizing it.
> > 3. The response is an marshalled JSON object (using camel-jackson)
> >
> > All works fine.
> >
> > public class RestToBeanRouter extends RouteBuilder{
> >
> > @Override
> > public void configure() throws Exception {
> >
> > from("cxfrs://bean://rsServer")
> >
> > .multicast()
> > .parallelProcessing()
> > .aggregationStrategy(new CoreSearchResponseAggregator())
> > .beanRef("searchRestServiceImpl", "firstMethod")
> > .beanRef("searchRestServiceImpl", "secondMethod")
> > .end()
> > .marshal().json(JsonLibrary.Jackson)
> > .to("log://camelLogger?level=DEBUG");
> >
> > }
> >
> >
> > **Question :**
> >
> > The Multicast routing expects a `to` in the DSL.  Currently, I am mapping
> > this to a `log` endpoint.  Is this fine?
> >
> > Since I am not using the `to` and the last exchange of the Aggregator
> > strategy is the one which is returned to the user, should my endpoint be
> > configured to something else - like a null or something? (Ah, the
> stupidity
> > kicks in)
> >
> >
> >
> > --
> > View this message in context:
> >
> http://camel.465427.n5.nabble.com/Apache-Camel-Multicast-Is-there-a-null-or-a-similar-endpoint-tp5740664.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
>


Re: Scala DSL lacks a way to specify return type of language expressions

2013-10-01 Thread kraythe .
Write an implicit conversion.

Scala doesnt manage return types much. Its unnecessary baggage. I rather
like that and wish I could use it in my work.

*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39*


On Tue, Oct 1, 2013 at 8:55 PM, Dale King  wrote:

> The language support in the Scala DSL is too simplistic in that it does not
> support all the options of Java DSL.
>
> In particular it does not allow setting the return type of the expression.
> In my case I am trying to  set a header to the result of an xpath count
> expression. In the Java DSL this fails unless you explicitly set the return
> type of the xpath expression because the default return type for xpath is a
> node set and it cannot convert a number to a node set.
>
> It also lacks all the other overloads for things like Namespaces on xpath,
> etc.
>
> --
> Dale King
>


Re: Bean component/Bean Binding: Body as InputStream parametr (specified as ${body} in route)

2013-10-01 Thread Radek Kraus
Yes, I know it. It is enough to use second variant (the commented one) of
bean component binding. I have already used it. 
I want only to know if using of simple language (${body}) is a problem,
which should be fixed. I will create the JIRA ticket, how Claus suggested.

Thanks all for help.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Bean-component-Bean-Binding-Body-as-InputStream-parametr-specified-as-body-in-route-tp5740656p5740738.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Updating properties via JMX

2013-10-01 Thread PMulido
We are using JMX within Camel and using JConsole to maniputes MBeans and
routes / contexts etc.

We are also using a jolokia agent and able to connect using hawtio.

The issue is we can't seem to see properties within JMX that are loaded via 
org.springframework.beans.factory.config.ListFactoryBean  and referenced as
{properties:DLC_EMAIL_ADDRESS} loaded from property files:

i.e.  
DLC_EMAIL_ADDRESS=x...@yyy.com


There does not seem to be a way expose / manipulate these vaules.  I may be
completely missing where this is located.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Updating-properties-via-JMX-tp5740716p5740724.html
Sent from the Camel - Users mailing list archive at Nabble.com.


AW: Creating routes dynamically like a for()

2013-10-01 Thread jhm
Sure, RouteBuilders are just Java objects and can be configured in Java -
Camel DSL is just Java and loops are available ;)

But you have to distinguish when you get your path-list: during startup time
or during runtime?

Startup time:
Use a DB connection / EntityManager for loading the infos from the database
and loop over the datasets and create the routes as usual.

Runtime:
- You have to react on an event (incoming exchange ...) (new)
- load the data (as before, maybe getting from the exchange)
- create the RouteBuilder (as before)
- add to the camel context (new, implicitly done before)

Or am I wrong here?


Jan 

> -Ursprüngliche Nachricht-
> Von: kraythe . [mailto:kray...@gmail.com]
> Gesendet: Mittwoch, 2. Oktober 2013 07:42
> An: Camel Users List
> Betreff: Re: Creating routes dynamically like a for()
> 
> Just put the for outside. I do this all the time.
> 
> for (final String path : paths) {
>   from("file://" + path +"?readlock=changed").to(...) ...
> }
> 
> This will create four identical routes other than the file paths. if
> there are four elements in paths.
> 
> *Robert Simmons Jr. MSc. - Lead Java Architect @ EA* *Author of:
> Hardcore Java (2003) and Maintainable Java (2012)*
> *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39*
> 
> 
> On Tue, Oct 1, 2013 at 4:20 PM, Jan Matèrne (jhm) 
> wrote:
> 
> > What you could do is generating a xml file with the new route
> > definitions and load that.
> > http://camel.apache.org/loading-routes-from-xml-files.html
> >
> > from("sql ...")
> > .process( generateRoutesXmlProcessor )
> > .doTypeConversionFromXmlToInputStream
> > .process( loadRoutesProcessor )
> >
> > Jan
> >
> > > -Ursprüngliche Nachricht-
> > > Von: mamouros [mailto:csst0...@yahoo.gr]
> > > Gesendet: Dienstag, 1. Oktober 2013 17:58
> > > An: users@camel.apache.org
> > > Betreff: Creating routes dynamically like a for()
> > >
> > > I would like to create a route for every query my sql route
> returns.
> > > From this:
> > >
> > > from("sql:" + fromUri + "?dataSource=dataSource")
> > > .to("bean:SmsReceiver?method=creatingRoutes");
> > >
> > > I want to make something hypothetically like this:
> > >
> > > for( from("sql:" + fromUri + "?dataSource=dataSource") )  {
> > >
> > >  .to("bean:SmsReceiver?method=creatingRoutes");
> > >
> > > }
> > >
> > > so if I have 3 entries in my table, I would create 3 routes.
> > >
> > > How is that possible. Is there any EIP that does that?
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > > http://camel.465427.n5.nabble.com/Creating-routes-dynamically-like-
> a
> > > -
> > > for-tp5740703.html
> > > Sent from the Camel - Users mailing list archive at Nabble.com.
> >
> >



"The Camel Components Poster" now available.

2013-10-01 Thread gliesian
For anyone who is interested:
http://fineartamerica.com/featured/the-camel-components-poster-robert-liguori.html

-- Robert.



--
View this message in context: 
http://camel.465427.n5.nabble.com/The-Camel-Components-Poster-now-available-tp5740730.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Apache Camel - Multicast - Is there a 'null' or a similar endpoint ?

2013-10-01 Thread Claus Ibsen
Hi

Yeah I dont see a problem either. Multicast can be 1 or N destinations.

Maybe you can try explain again what you see as a problem? and what
you want to do be able to do instead.

Are you wanting to do a multicast to zero destinations which doesnt make sense?


On Wed, Oct 2, 2013 at 7:44 AM, kraythe .  wrote:
> It would work. Multicast doesnt indicate anything more than more than one
> destination. Those destinations could be two JMS queues, a queue and a log,
> whatever you like. All your code would do is log the message but if that is
> what you want then go for it.
>
> *Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
> *Author of: Hardcore Java (2003) and Maintainable Java (2012)*
> *LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39*
>
>
> On Tue, Oct 1, 2013 at 4:34 PM, Christian Müller <
> christian.muel...@gmail.com> wrote:
>
>> This doesn't sounds right.
>> Can you provide a unit test which shows this behavior and attach it to a
>> JIRA [1]!?
>>
>> [1] http://camel.apache.org/contributing.html
>>
>> Best,
>> Christian
>> -
>>
>> Software Integration Specialist
>>
>> Apache Camel committer: https://camel.apache.org/team
>> V.P. Apache Camel: https://www.apache.org/foundation/
>> Apache Member: https://www.apache.org/foundation/members.html
>>
>> https://www.linkedin.com/pub/christian-mueller/11/551/642
>>
>>
>> On Tue, Oct 1, 2013 at 12:28 PM, arunodhaya80  wrote:
>>
>> > Please excuse stupidity as this is my first Camel application
>> >
>> > 1. To respond to a web request, I am sourcing the content from two
>> > different
>> > sources.
>> > 2. I am, therefore, making a multicast request to two methods and
>> > parallelizing it.
>> > 3. The response is an marshalled JSON object (using camel-jackson)
>> >
>> > All works fine.
>> >
>> > public class RestToBeanRouter extends RouteBuilder{
>> >
>> > @Override
>> > public void configure() throws Exception {
>> >
>> > from("cxfrs://bean://rsServer")
>> >
>> > .multicast()
>> > .parallelProcessing()
>> > .aggregationStrategy(new CoreSearchResponseAggregator())
>> > .beanRef("searchRestServiceImpl", "firstMethod")
>> > .beanRef("searchRestServiceImpl", "secondMethod")
>> > .end()
>> > .marshal().json(JsonLibrary.Jackson)
>> > .to("log://camelLogger?level=DEBUG");
>> >
>> > }
>> >
>> >
>> > **Question :**
>> >
>> > The Multicast routing expects a `to` in the DSL.  Currently, I am mapping
>> > this to a `log` endpoint.  Is this fine?
>> >
>> > Since I am not using the `to` and the last exchange of the Aggregator
>> > strategy is the one which is returned to the user, should my endpoint be
>> > configured to something else - like a null or something? (Ah, the
>> stupidity
>> > kicks in)
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> >
>> http://camel.465427.n5.nabble.com/Apache-Camel-Multicast-Is-there-a-null-or-a-similar-endpoint-tp5740664.html
>> > Sent from the Camel - Users mailing list archive at Nabble.com.
>> >
>>



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen


Re: Bean component/Bean Binding: Body as InputStream parametr (specified as ${body} in route)

2013-10-01 Thread Radek Kraus
The JIRA issue was create https://issues.apache.org/jira/browse/CAMEL-6810.
Thanks for help.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Bean-component-Bean-Binding-Body-as-InputStream-parametr-specified-as-body-in-route-tp5740656p5740741.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Scala DSL lacks a way to specify return type of language expressions

2013-10-01 Thread Claus Ibsen
We love contributions, so fell free to work on adding the pieces in
Scala DSL you would like.
http://camel.apache.org/contributing.html



On Wed, Oct 2, 2013 at 3:55 AM, Dale King  wrote:
> The language support in the Scala DSL is too simplistic in that it does not
> support all the options of Java DSL.
>
> In particular it does not allow setting the return type of the expression.
> In my case I am trying to  set a header to the result of an xpath count
> expression. In the Java DSL this fails unless you explicitly set the return
> type of the xpath expression because the default return type for xpath is a
> node set and it cannot convert a number to a node set.
>
> It also lacks all the other overloads for things like Namespaces on xpath,
> etc.
>
> --
> Dale King



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen