rgannu edited a comment 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}", ``` ``` 2020-10-29 07:46:05,843 DEBUG || Additional headers: {} [org.apache.camel.component.rabbitmq.RabbitMQComponent] 2020-10-29 07:46:05,843 DEBUG || Additional properties: {} [org.apache.camel.component.rabbitmq.RabbitMQComponent] : : ---------------------- [org.apache.camel.processor.errorhandler.DefaultErrorHandler] java.lang.UnsupportedOperationException at java.base/java.util.Collections$UnmodifiableMap.putAll(Collections.java:1463) at org.apache.camel.component.rabbitmq.RabbitMQMessageConverter.buildProperties(RabbitMQMessageConverter.java:103) at org.apache.camel.component.rabbitmq.RabbitMQMessagePublisher.publish(RabbitMQMessagePublisher.java:96) at org.apache.camel.component.rabbitmq.RabbitMQEndpoint.publishExchangeToChannel(RabbitMQEndpoint.java:232) at org.apache.camel.component.rabbitmq.RabbitMQProducer$2.doWithChannel(RabbitMQProducer.java:311) at org.apache.camel.component.rabbitmq.RabbitMQProducer$2.doWithChannel(RabbitMQProducer.java:308) at org.apache.camel.component.rabbitmq.RabbitMQProducer.execute(RabbitMQProducer.java:95) at org.apache.camel.component.rabbitmq.RabbitMQProducer.basicPublish(RabbitMQProducer.java:308) at org.apache.camel.component.rabbitmq.RabbitMQProducer.processInOnly(RabbitMQProducer.java:294) at org.apache.camel.component.rabbitmq.RabbitMQProducer.process(RabbitMQProducer.java:208) at org.apache.camel.support.LazyStartProducer.process(LazyStartProducer.java:57) ``` As the map is empty I believe the `java.lang.UnsupportedOperationException` exception is coming. 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