You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Vadim Chekan <ko...@gmail.com> on 2008/08/30 02:17:14 UTC

Expression pipe

I'm having problem with the following expression:
		from("activemq:Integration.Status").
		setHeader("Body").el("${in.body}").
		setBody().el("${in.headers}").
		marshal().
		xstream().convertBodyTo(String.class).
		setBody().el("declare @h uniqueidentifier; "+
		           "begin dialog conversation @h "+
		           "from service StatusResponseService "+
		           "to service 'StatusService' "+
		           "with encryption=off; "+
		           "send on conversation @h ('${in.body.replace('\'','\'\'')}'); ").
		to("jdbc:Status");

The line before last returns Object so it can not be sent "to".
I'm trying to serialize a message, including all headers into xml,
than craft a sql expression which would contain this xml as a
parameter and send it to jdbc endpoint.
I spent several hors trying all possible combinations and still have
no clue how to do this double body transform.
I feel like I need to use "pipeline" pattern but I can not understand
what two elements should be inside this pipe.

So far I made it working using 2 queues but it feels wrong:
		from("activemq:Integration.Status").
		setHeader("Body").el("${in.body}").
		setBody().el("${in.headers}").
		marshal().
		xstream().convertBodyTo(String.class).
		to("activemq:Integration.Status2");
		
		from("activemq:Integration.Status2").
		setBody().el("declare @h uniqueidentifier; "+
		           "begin dialog conversation @h "+
		           "from service StatusResponseService "+
		           "to service 'StatusService' "+
		           "with encryption=off; "+
		           "send on conversation @h ('${in.body.replace('\'','\'\'')}'); ").
		to("jdbc:Status");

And another question: in "el" this fragment
"'${in.body.replace('\'','\'\'')}" gives me an error: syntax error at
position 187, encountered ',', expected ')'
How can I replace single quote in the body with two single quote chars?

Vadim.

-- 
>From RFC 2631: In ASN.1, EXPLICIT tagging is implicit unless IMPLICIT
is explicitly specified

Re: Expression pipe

Posted by Vadim Chekan <ko...@gmail.com>.
I hate finding an answer a minute after sending email for help :)
It suppose to be a double escape symbol because it is inside in java
string. Copy-paste bug :)
But I steel need help with the first part of the problem.

On Fri, Aug 29, 2008 at 5:17 PM, Vadim Chekan <ko...@gmail.com> wrote:
> And another question: in "el" this fragment
> "'${in.body.replace('\'','\'\'')}" gives me an error: syntax error at
> position 187, encountered ',', expected ')'
> How can I replace single quote in the body with two single quote chars?

Re: Expression pipe

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

You could use direct endpoint instead of activemq endpoint to combine the
below 2  body transforms. In this way the message will not be send and take
from activemq again.

from("activemq:Integration.Status").setHeader("Body")...to("direct:ToJdbc");
from("direct:ToJdbc").setBody().el("declare @h uniqueidentifier; "+ ...
to("jdbc:Status");

I am also try to figure out the real reason of
https://issues.apache.org/activemq/browse/CAMEL-393,
It is may relate with your issue in Camel DSL implementation.
Please feel free to fill the JIRA if you have any thing to comment.

Willem

On Sat, Aug 30, 2008 at 8:17 AM, Vadim Chekan <ko...@gmail.com> wrote:

> I'm having problem with the following expression:
>                from("activemq:Integration.Status").
>                setHeader("Body").el("${in.body}").
>                setBody().el("${in.headers}").
>                marshal().
>                xstream().convertBodyTo(String.class).
>                setBody().el("declare @h uniqueidentifier; "+
>                           "begin dialog conversation @h "+
>                           "from service StatusResponseService "+
>                           "to service 'StatusService' "+
>                           "with encryption=off; "+
>                           "send on conversation @h
> ('${in.body.replace('\'','\'\'')}'); ").
>                to("jdbc:Status");
>
> The line before last returns Object so it can not be sent "to".
> I'm trying to serialize a message, including all headers into xml,
> than craft a sql expression which would contain this xml as a
> parameter and send it to jdbc endpoint.
> I spent several hors trying all possible combinations and still have
> no clue how to do this double body transform.
> I feel like I need to use "pipeline" pattern but I can not understand
> what two elements should be inside this pipe.
>
> So far I made it working using 2 queues but it feels wrong:
>                from("activemq:Integration.Status").
>                setHeader("Body").el("${in.body}").
>                setBody().el("${in.headers}").
>                marshal().
>                xstream().convertBodyTo(String.class).
>                to("activemq:Integration.Status2");
>
>                from("activemq:Integration.Status2").
>                setBody().el("declare @h uniqueidentifier; "+
>                           "begin dialog conversation @h "+
>                           "from service StatusResponseService "+
>                           "to service 'StatusService' "+
>                           "with encryption=off; "+
>                           "send on conversation @h
> ('${in.body.replace('\'','\'\'')}'); ").
>                to("jdbc:Status");
>
> And another question: in "el" this fragment
> "'${in.body.replace('\'','\'\'')}" gives me an error: syntax error at
> position 187, encountered ',', expected ')'
> How can I replace single quote in the body with two single quote chars?
>
> Vadim.
>
> --
> From RFC 2631: In ASN.1, EXPLICIT tagging is implicit unless IMPLICIT
> is explicitly specified
>

Re: Expression pipe

Posted by Vadim Chekan <vc...@cox.net>.
I'm trying to understand the camel code and I stumbled across two 
classes I can not understand:

1. class ProcessorType<Type extends ProcessorType>
2. class RouteType extends ProcessorType<ProcessorType>

Is this some kind of self-parametrization?

Simplified version of problem (it does not compile):
	from("src").
	convertBodyTo(String.class).
	setBody().el("").
	to("");

I'm trying to understand what's wrong but template usage is quite tricky 
here.


Vadim Chekan wrote:
> I'm having problem with the following expression:
> 		from("activemq:Integration.Status").
> 		setHeader("Body").el("${in.body}").
> 		setBody().el("${in.headers}").
> 		marshal().
> 		xstream().convertBodyTo(String.class).
> 		setBody().el("declare @h uniqueidentifier; "+
> 		           "begin dialog conversation @h "+
> 		           "from service StatusResponseService "+
> 		           "to service 'StatusService' "+
> 		           "with encryption=off; "+
> 		           "send on conversation @h ('${in.body.replace('\'','\'\'')}'); ").
> 		to("jdbc:Status");