rgannu commented on pull request #4371:
URL: https://github.com/apache/camel/pull/4371#issuecomment-718425519


   @oscerd / @davsclaus, Could you please let me know how I can set the HashMap 
entries via sink connector configuration?
   
   I have tried these
   1. The map is empty.. 
   ```
       "camel.sink.endpoint.additionalHeaders": "#bean:addHeaders",
       "camel.beans.addHeaders": "#class:java.util.HashMap",
       "camel.beans.addHeaders[MSG_TYPE]": 
"${file:/secrets/amqp.properties:analytics.msg.type}",
       "camel.beans.addHeaders[MSG_ORIGINATOR]": 
"${file:/secrets/amqp.properties:analytics.msg.originator}",
       "camel.beans.addHeaders[DESTINATION]": 
"${file:/secrets/amqp.properties:analytics.destination}",
   ```
   
   2. I also tried by having my own class which extends from HashMap. Still 
only empty map is going in..
   ```
   package aero.unifly.analytics.bean;
   
   public class SimpleDataHolderBean extends java.util.HashMap<String, Object> {
   }
   ```
   ```
       "camel.sink.endpoint.additionalHeaders": "#bean:addHeaders",
       "camel.beans.addHeaders": 
"#class:aero.unifly.analytics.bean.SimpleDataHolderBean",
       "camel.beans.addHeaders[MSG_TYPE]": 
"${file:/secrets/amqp.properties:analytics.msg.type}",
       "camel.beans.addHeaders[MSG_ORIGINATOR]": 
"${file:/secrets/amqp.properties:analytics.msg.originator}",
       "camel.beans.addHeaders[DESTINATION]": 
"${file:/secrets/amqp.properties:analytics.destination}",
   ```
   
   3. When I do not have the `#class`, I get error `No bean could be found in 
the registry for: addHeaders of type: java.util.Map`
   ```
       "camel.sink.endpoint.additionalHeaders": "#bean:addHeaders",
       "camel.beans.addHeaders[MSG_TYPE]": 
"${file:/secrets/amqp.properties:analytics.msg.type}",
       "camel.beans.addHeaders[MSG_ORIGINATOR]": 
"${file:/secrets/amqp.properties:analytics.msg.originator}",
       "camel.beans.addHeaders[DESTINATION]": 
"${file:/secrets/amqp.properties:analytics.destination}",
   ```
   
   4.
   Test case I am able to set the map in the camel context and use
   ```
       @Override
       protected CamelContext createCamelContext() throws Exception {
           CamelContext context = super.createCamelContext();
   
           myMap = new HashMap<>();
           myMap.put("k1", "v1");
           myMap.put("k2", 1L);
   
           context.getRegistry().bind("myMap", myMap);
   
           return context;
       }
   
       @Test
       public void testResolveParameter() throws Exception {
           @SuppressWarnings("unchecked")
           Map<String, Object> mapGot = 
EndpointHelper.resolveParameter(context, "#myMap", Map.class);
           assertSame(myMap, mapGot);
       }
   ```
   
   Please let me know how I need to set the Map via the Connector Configuration.
   
   Thanks and Kind Regards
   Ganesh 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to