You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by arko1983 <ar...@gmail.com> on 2014/03/18 10:24:51 UTC

Camel routing using Predicates

My code are as follows.

public void camelRedirect(String Rqvalue,String oprcode) {
		
	final String urlOprn=oprcode;//					
		
		final CamelContext context = new DefaultCamelContext();	
		try {
			 context.start();
		 
		     RouteBuilder builder=new RouteBuilder() {				
			
			@Override
			public void configure() throws Exception { 			
						
				Predicate isWidgets = simple("${oprcode} == 'ATM'");
				from(urlOprn) 
				.choice()

	                .when(isWidgets)
	                    .process(new Processor() {								
								String recv="";
								@Override
								public void process(Exchange data) throws Exception {
									System.out.println("----");
									
								}
							})
	                .otherwise()
	                    .process(new Processor() {					
							
							@Override
							public void process(Exchange data) throws Exception {}
						});		
			}
			
			
		};	
		context.addRoutes(builder);	
		
		}
		catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
	}
----------------------------------------------------------------------------------------------------
String value of oprcode="ATM".I am getting the following exceptions:-
Failed to create route route1: Route[[From[ATM]] ->
[Choice[[When[simple{${oprcode} == 'ATM... because of No endpoint could be
found for: ATM, please check your classpath contains the needed Camel
component jar.


I want to channel the requests through camel.



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-routing-using-Predicates-tp5749029.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel routing using Predicates

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

${oprcode} is not a valid simple function.
http://camel.apache.org/simple

On Tue, Mar 18, 2014 at 10:24 AM, arko1983 <ar...@gmail.com> wrote:
> My code are as follows.
>
> public void camelRedirect(String Rqvalue,String oprcode) {
>
>         final String urlOprn=oprcode;//
>
>                 final CamelContext context = new DefaultCamelContext();
>                 try {
>                          context.start();
>
>                      RouteBuilder builder=new RouteBuilder() {
>
>                         @Override
>                         public void configure() throws Exception {
>
>                                 Predicate isWidgets = simple("${oprcode} == 'ATM'");
>                                 from(urlOprn)
>                                 .choice()
>
>                         .when(isWidgets)
>                             .process(new Processor() {
>                                                                 String recv="";
>                                                                 @Override
>                                                                 public void process(Exchange data) throws Exception {
>                                                                         System.out.println("----");
>
>                                                                 }
>                                                         })
>                         .otherwise()
>                             .process(new Processor() {
>
>                                                         @Override
>                                                         public void process(Exchange data) throws Exception {}
>                                                 });
>                         }
>
>
>                 };
>                 context.addRoutes(builder);
>
>                 }
>                 catch (Exception e) {
>                         // TODO Auto-generated catch block
>                         e.printStackTrace();
>                 }
>         }
> ----------------------------------------------------------------------------------------------------
> String value of oprcode="ATM".I am getting the following exceptions:-
> Failed to create route route1: Route[[From[ATM]] ->
> [Choice[[When[simple{${oprcode} == 'ATM... because of No endpoint could be
> found for: ATM, please check your classpath contains the needed Camel
> component jar.
>
>
> I want to channel the requests through camel.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-routing-using-Predicates-tp5749029.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io