Configuring charset

Talend ESB Mediation Developer Guide

Talend ESB
Installation and Upgrade
Design and Development
Talend ESB

If you are using POST to send data you can configure the charset using the Exchange property:

exchange.setProperty(Exchange.CHARSET_NAME, "ISO-8859-1");

Sample with scheduled poll

This sample polls the Google homepage every 10 seconds and write the page to the file message.html:

   .setHeader(FileComponent.HEADER_FILE_NAME, "message.html")

URI Parameters from the endpoint URI

In this sample we have the complete URI endpoint that is just what you would have typed in a web browser. Multiple URI parameters can of course be set using the & character as separator, just as you would in the web browser. Camel does no tricks here.

// we query for Camel at the Google page
template.sendBody("http4://", null);

URI Parameters from the Message

Map headers = new HashMap();
headers.put(Exchange.HTTP_QUERY, "q=Camel&lr=lang_en");
// we query for Camel and English language at Google
template.sendBody("http4://", null, headers);

In the header value above notice that it should not be prefixed with ? and you can separate parameters as usual with the & char.

Getting the Response Code

You can get the HTTP response code from the HTTP4 component by getting the value from the Out message header with Exchange.HTTP_RESPONSE_CODE .

Exchange exchange = 
   template.send("http4://", new Processor() {
      public void process(Exchange exchange) throws Exception {
            Exchange.HTTP_QUERY, constant("hl=en&q=activemq"));
Message out = exchange.getOut();
int responseCode = out.getHeader(Exchange.HTTP_RESPONSE_CODE,