You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Behrad <be...@gmail.com> on 2014/12/06 21:42:45 UTC

Building predicates/routes at runtime

This may not be the correct place to share this, but there's no dedicated
akka-camel, or scala-dsl camel community out there, so I ask it here.
I want to build my camel CBR when predicates at run-time based on user
input:
considering my CamelMessage bodies are of case class Book as below

case class Book( author: Person, title: String )
case class Person( name: String, age: Int )

when user inputs "author.name" and "startsWith" and "behrad" I should create

"fromEndpoint" when( _.in.asInstanceOf[Book].author.name.startsWith(
"behrad" ) ) to "actorPath"


I've decided to write when perdicate functions that use Scala's reflection,
or shapless lib to evaluate "author.name" and run "startsWith" on that and
check with the value.
Is this the best solution? or could I anyway take advantage of
PredicateBuilder's of Camel? or any other suggesstions?

-- 
--Behrad