Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Camel: How to include an ampersand as data in a URI (NOT as a delimiter)?

(Camel 2.9.2)

Very simple use case, but I can't seem to find the answer. My code boils down to this:

String user = "user";
String password = "foo&bar";

String uri = "smtp://hostname:25?username=" + user +
    "&password=" + password + 
    "&[email protected]"; // etc. You get the idea

from("seda:queue:myqueue").to(uri);

Camel throws a ResolveEndpointFailedException with "Unknown parameters=[{bar=null}]."

If I try "foo%26bar," I get the same result.

If I try "foo&bar" camel responds with "Unknown parameters=[{amp;bar=null}]."

I tried using URISupport to create the URI. It escapes the & to %26, and then I get "Unknown parameters=[{bar=null}]" again.

Any ideas?

like image 241
Matt Flowers Avatar asked Jun 13 '12 16:06

Matt Flowers


1 Answers

As from Camel 2.11 you could use raw syntax

For instance:

.to("ftp:[email protected]?password=RAW(se+re?t&23)&binary=true"

In the above example, we have declare the password value as raw, and the actual password would be as typed, eg se+re?t&23

https://cwiki.apache.org/confluence/display/CAMEL/How+do+I+configure+endpoints

like image 121
tyuha Avatar answered Oct 05 '22 19:10

tyuha