package qlc.processor;

import net.sf.json.JSONObject;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;

import java.util.Map;

/**
 * Created by Zdm on 2016/7/13.
 */
public class Processor2 implements Processor {
    public void process(Exchange exchange) throws Exception {
        Message outMessage = exchange.getOut();
        Message inMessage = exchange.getIn();
        String body = inMessage.getBody(String.class);
        Map<String, Object> mapJson = JSONObject.fromObject(body);
        String queryString = "";
        for (String key : mapJson.keySet()) {
            queryString += key + "=" + mapJson.get(key) + "&";
        }
        outMessage.setHeader(Exchange.HTTP_QUERY, queryString);
    }

}
