You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Blair <bl...@gmail.com> on 2011/07/27 09:08:16 UTC

anyone else want changes to the DSL?

Hi all, I'd like to add expressions to .to in the DSL... this is why....

My code is littered with 

.recipientList(constant("activemq:receiving:").append(header("app"))

Because I am wanting to send the message to an endpoint that we define in an
expression. (mostly queues)
however... it is a single endpoint, and will only ever be a single
endpoint... I would greatly prefer to be able to use

.to(constant("activemq:receiving:").append(header("app"))

just for clarity if nothing else

The other thing with using .recipientList(Expression) is that you can't use
it in a where clause if you are going to continue with the clause....  since
it returns RecipientListDefinition<Type> where to be in a choice statement
requires a ChoiceDefinition...

so we end up with code that looks like...

... beginning of route here....
.choice()
               .when(header("statusId").isNotEqualTo(""))
                   .to("direct:receipting")
               .otherwise()
                   .to("direct:receiving")
           .end();

       
from("direct:receipting").routeId("receiptingRestService").recipientList(constant("activemq:receipting:").append(header("app")));
// queue for each app so one customer service can't interfere with
another...
       
from("direct:receiving").routeId("receivingRestService").recipientList(constant("activemq:receiving:").append(header("app")));
// queue for each app so one customer service can't interfere with
another...



where what I would like to say is....
               .when(header("statusId").isNotEqualTo("")) // we have a
receipt...
                  
.to(constant("activemq:receipting:").append(header("app")))
               .otherwise() // it must be a message to be passed back...
                  
.to(constant("activemq:receiving:").append(header("app")))
           .end();

I'm happy to make the changes and submit a patch if that helps :)


--
View this message in context: http://camel.465427.n5.nabble.com/anyone-else-want-changes-to-the-DSL-tp4637768p4637768.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: anyone else want changes to the DSL?

Posted by Claus Ibsen <cl...@gmail.com>.
In Java DSL you can do like this

                from("direct:a")

.recipientList().simple("activemq:receiving:${header.app}").to("mock:xxx");

Then there is no issue with RecipientListDefinition as that type is not in use.



On Wed, Jul 27, 2011 at 9:08 AM, Blair <bl...@gmail.com> wrote:
> Hi all, I'd like to add expressions to .to in the DSL... this is why....
>
> My code is littered with
>
> .recipientList(constant("activemq:receiving:").append(header("app"))
>
> Because I am wanting to send the message to an endpoint that we define in an
> expression. (mostly queues)
> however... it is a single endpoint, and will only ever be a single
> endpoint... I would greatly prefer to be able to use
>
> .to(constant("activemq:receiving:").append(header("app"))
>
> just for clarity if nothing else
>
> The other thing with using .recipientList(Expression) is that you can't use
> it in a where clause if you are going to continue with the clause....  since
> it returns RecipientListDefinition<Type> where to be in a choice statement
> requires a ChoiceDefinition...
>
> so we end up with code that looks like...
>
> ... beginning of route here....
> .choice()
>               .when(header("statusId").isNotEqualTo(""))
>                   .to("direct:receipting")
>               .otherwise()
>                   .to("direct:receiving")
>           .end();
>
>
> from("direct:receipting").routeId("receiptingRestService").recipientList(constant("activemq:receipting:").append(header("app")));
> // queue for each app so one customer service can't interfere with
> another...
>
> from("direct:receiving").routeId("receivingRestService").recipientList(constant("activemq:receiving:").append(header("app")));
> // queue for each app so one customer service can't interfere with
> another...
>
>
>
> where what I would like to say is....
>               .when(header("statusId").isNotEqualTo("")) // we have a
> receipt...
>
> .to(constant("activemq:receipting:").append(header("app")))
>               .otherwise() // it must be a message to be passed back...
>
> .to(constant("activemq:receiving:").append(header("app")))
>           .end();
>
> I'm happy to make the changes and submit a patch if that helps :)
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/anyone-else-want-changes-to-the-DSL-tp4637768p4637768.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: anyone else want changes to the DSL?

Posted by boday <be...@initekconsulting.com>.
Blair, see this JIRA for a similar discussion on this...

https://issues.apache.org/jira/browse/CAMEL-4226


Blair wrote:
> 
> Hi all, I'd like to add expressions to .to in the DSL... this is why....
> 
> My code is littered with 
> 
> .recipientList(constant("activemq:receiving:").append(header("app"))
> 
> Because I am wanting to send the message to an endpoint that we define in
> an expression. (mostly queues)
> however... it is a single endpoint, and will only ever be a single
> endpoint... I would greatly prefer to be able to use
> 
> .to(constant("activemq:receiving:").append(header("app"))
> 
> just for clarity if nothing else
> 
> The other thing with using .recipientList(Expression) is that you can't
> use it in a where clause if you are going to continue with the clause.... 
> since it returns RecipientListDefinition<Type> where to be in a choice
> statement requires a ChoiceDefinition...
> 
> so we end up with code that looks like...
> 
> ... beginning of route here....
> .choice()
>                .when(header("statusId").isNotEqualTo(""))
>                    .to("direct:receipting")
>                .otherwise()
>                    .to("direct:receiving")
>            .end();
> 
>        
> from("direct:receipting").routeId("receiptingRestService").recipientList(constant("activemq:receipting:").append(header("app")));
> // queue for each app so one customer service can't interfere with
> another...
>        
> from("direct:receiving").routeId("receivingRestService").recipientList(constant("activemq:receiving:").append(header("app")));
> // queue for each app so one customer service can't interfere with
> another...
> 
> 
> 
> where what I would like to say is....
>                .when(header("statusId").isNotEqualTo("")) // we have a
> receipt...
>                   
> .to(constant("activemq:receipting:").append(header("app")))
>                .otherwise() // it must be a message to be passed back...
>                   
> .to(constant("activemq:receiving:").append(header("app")))
>            .end();
> 
> I'm happy to make the changes and submit a patch if that helps :)
> 


-----
Ben O'Day
IT Consultant -http://consulting-notes.com

--
View this message in context: http://camel.465427.n5.nabble.com/anyone-else-want-changes-to-the-DSL-tp4637768p4643998.html
Sent from the Camel - Users mailing list archive at Nabble.com.