Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

SSH return not working with isEqualTo

$
0
0
Hi I'm new to Camel. I'm using the SSH component to invoke a shell script on
a remote machine. The returned value is 0 for success and 1 for failure. I
want to branch conditionally in my route depending on which i get, but,
using isEqualTo, in, and startsWith, etc. isn't working.

I'm sure it's something basic, so my first question is: what is the
canonical way to do this?

Here's how i'm doing it and testing it. Very simple route

from("ssh://user:pwd [ at ] host?pollCommand=" + command)
.log("$$$$$$ ${body}")
.choice()
.when(body().isEqualTo("0")).log("@@@ IT IS 0")
.otherwise().log("@@@ NOT 0")
.end();

No matter what i do, the "otherwise" gets invoked. The logged body shows
that the contents are "0". I have tried of other approaches with no luck. I
understand that the message body is an Object, so maybe i need to cast it to
a String? If so, how to do that. I tried wrapping it in string() but that's
not legal.

For testing, I replaced my when with

.when(constant("0").isEqualTo("0")).log("@@@ IT IS 0")

and of course that worked.

Suggestions appreciated.....

Viewing all articles
Browse latest Browse all 5648

Trending Articles