You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "web_nabble@sunilsamuel.com" <we...@sunilsamuel.com> on 2016/01/25 22:34:27 UTC

Re: "Dynamic" data format in route

Hello, 

I wanted to provide a solution for anyone else who may have the same
questions.  I also had a similar requirement where I create several data
formats via blueprint but I wanted a way for the route to determine which
data format to use.  That is, use a property value to determine the data
format name.  There is a component named "dataformat:" which is not
documented very well.  I was able to use the 'recipientList' and dataformat
component to do this as follows:

from("direct-vm:moxy-marshal")
	.choice()
	.when(simple("${property.moxyDataFormat} == null"))
		.throwException(new ExpressionIllegalSyntaxException("no property"))
	.otherwise()
		.recipientList(simple("dataformat:${property.moxyDataFormat}:marshal"))
;

from("direct-vm:moxy-unmarshal")
	.choice()
	.when(simple("${property.moxyDataFormat} == null"))
		.throwException(new ExpressionIllegalSyntaxException("no property"))
	.otherwise()
		.recipientList(simple("dataformat:${property.moxyDataFormat}:unmarshal"))
;




--
View this message in context: http://camel.465427.n5.nabble.com/Dynamic-data-format-in-route-tp5726853p5776681.html
Sent from the Camel - Users mailing list archive at Nabble.com.