Home > Software engineering >  how to add custom properties or label/subject for azure servicebus topic messages when using apache
how to add custom properties or label/subject for azure servicebus topic messages when using apache

Time:09-29

I am able to send message to a specific subscription of azure service bus topic using apache camel using exmaple here enter image description here

if you see "subject" is "test" and there is a custom property "test" that has value "test".

I want to see the same thing when i use apache camel to send it. Please help. Thanks

CodePudding user response:

Today it's not possible with the latest version of Camel, however it will be shipped in the next release.

Relevant ticket : https://issues.apache.org/jira/browse/CAMEL-18459

Code : https://github.com/apache/camel/blob/main/components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusProducer.java

And this is how it will look like :

from("timer:foo1?period=15000&delay=1000")
                .process(new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        exchange.getIn().setBody("{\"message\":\"hello\"}");
                        exchange.getIn().setHeader(ServiceBusConstants.APPLICATION_PROPERTIES, Map.of("prop1", "value1"));
                    }
                })
                .to("azure-servicebus:demo?serviceBusType=topic&connectionString=RAW(connection-string-here");
  • Related