Setting HTTP path in Camel HTTP Netty producer

Solution Verified - Updated -

Environment

  • Red Hat JBoss Fuse
    • 6.1

Issue

  • How to dynamically set the path part of the destination HTTP address in the Camel Netty HTTP producer?
  • Setting HTTP path in Camel HTTP Netty producer.

Resolution

CamelHttpPath header can be used for setting HTTP path in Camel HTTP Netty producer. This option is available starting from Camel 2.13.1/2.12.4 (JBoss Fuse 6.1 Patch R1). It allows to provide URI context-path and query parameters as a String value that overrides the endpoint configuration. This allows to reuse the same producer for calling same remote http server, but using a dynamic context-path and query parameters.

For example to call the http://host.com/somepath URL, use the following code snippet:

producerTemplate.sendBodyAndHeader("netty-http:http://host.com", "message", Exchange.HTTP_PATH, "/somepath");

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.