我想到使用自定义变压器。所以我为此使用了Java转换器。
逻辑看起来像这样:
public class QueryBuilder extends AbstractMessageTransformer {@Overridepublic Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException { System.out.println("Query Params : " + message.getInboundProperty("http.query.params").getClass() .getName()); Map<?, ?> map = message.getInboundProperty("http.query.params"); System.out.println("Map keys : " + map.keySet()); String where = ""; for (Map.Entry<?, ?> entry : map.entrySet()) { System.out.println(entry.getKey() + "/" + entry.getValue()); where = where+" "+entry.getKey()+"="+"'"+entry.getValue()+"'"+" and"; } String whereCondition = where.substring(0, where.lastIndexOf(" ")); System.out.println("Where condition is : "+ where.substring(0, where.lastIndexOf(" "))); return whereCondition;}}现在,这将返回字符串类型的有效负载。
在数据库连接器中,将查询类型选择为 动态 。在 WHERe 条件之后,添加 #[payload] 。
干杯



