Search code examples
javaapache-cameljmscamel-jms

How do I set a component parameter of type object to a route using Java DSL?


My objective is to use Camel along with its JMS component.

The route config looks like below-

from("jms:queue:test").to(mybean) 

I would like to add the option of kind 'parameter' and type 'object' to this route -for example the option 'jmsMessageType'.

I saw some other posts that talks about using setProperty() on route definition but I could not find a definite answer. Options of type 'string' and numbers can be appended to the URI but not objects.

JMS has an option of taskExecutor but how can i add an instance of this to URI for routing.


Solution

  • I had to resolve this by adding the instances to a custom registry and using them from the endpoint URI

    From official Apache Camel page

    From Camel 2.0:

    When configuring endpoints using URI syntax you can now refer to beans in the Registry using the # notation. If the parameter value starts with a # sign then Camel will lookup in the Registry for a bean of the given type. For instance:

    file://inbox?sorter=#mySpecialFileSorter