How to add a Map to a query parameter in a Camel Endpoint

The Problem

In Camel, a String or Boolean is typically used as a query parameter. You can chain multiple query parameters together. For example in the following we have fileName and delete as query parameters.


But what happens when you want a Map as a query parameter? E.g. for the Bean-Component, you have „parameters“ as a Map parameter. But how can you write this parameter in the Java-DSL?

Map Query Parameters for Consumer

Let’s first look at the consumer. Let’s say we have a „myMapParam“ as a String – String Map

public class MyConsumerComponent extends DefaultComponent {
    private Map<String, String> myMapParam;

    // ... other code ...

    public Map<String, String> getMyMapParam() {
        return myMapParam;

    public void setMyMapParam(Map<String, String> myMapParam) {
        this.myMapParam = myMapParam;

Now to add multiple values to this Map, we do it the following way:


Map Query Parameters for Producers

Now let’s take a look at the producers

There we can also use the same technique as in the consumers part.

But Additionally, we can also use headers. But make sure this component also uses the headers!

    .setHeader(MY_COMPONENT.MY_MAP_PARAM, constant(Collections.singletonMap("key1", "value1")))

Kommentar verfassen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Nach oben scrollen