0

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.

NishM
  • 1,706
  • 2
  • 15
  • 26

2 Answers2

1

I think you confuse parameter with option.

jmsMessageType you are referring is an option of Camel's jms component. Each component can have many options and you can use them by appending with "?" character. For example

from("jms:queue:test?jmsMessageType=text").to(mybean) 

More particular, for the jms component avalable options can be found in http://camel.apache.org/jms.html (see Common and Advanced Options sections)

Property is something different, it has nothing to do with the component, but with the Exchange message that is passed through the endpoints. More details are in Passing values between processors in apache camel

Themis Pyrgiotis
  • 876
  • 5
  • 15
  • I missed the heading in component page. They term it as properties in the component definition. Coming back to my question, How do i set an object instance to an option in the URI?. Update the question to avoid confusion. – NishM Jan 31 '18 at 18:28
  • So to pass an object you put **jmsMessageType=Object**. According to JMS Component documentation, you must set the object to the Exchange In body first and then send it with jms component. Maybe this is helpful for you https://stackoverflow.com/questions/18129983/camel-retrieving-object-in-activemq-message – Themis Pyrgiotis Jan 31 '18 at 19:30
  • It still isnt clear to me how i can set parameters of type object in an endpoint. – NishM Feb 04 '18 at 07:19
1

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

NishM
  • 1,706
  • 2
  • 15
  • 26