Reputation: 41
I am able to send message to a specific subscription of azure service bus topic using apache camel using example here https://camel.apache.org/components/3.18.x/azure-servicebus-component.html#_azure_servicebus_producer_operations. But i cannot get the properties set up with my code. below my code -
from("direct:start")
.id("producerId")
.marshal(new JacksonDataFormat(String.class))
.process(exchange -> {
exchange.setProperty(ServiceBusConstants.SUBJECT, constant("test"));
})
.setProperty("subject", constant("test"))
.setProperty(ServiceBusConstants.CORRELATION_ID, constant("111111"))
.setHeader("subject", constant("test"))
.setHeader("label", constant("test"))
.setHeader(ServiceBusConstants.SUBJECT, constant("test"))
.to("azure-servicebus:testTopic?serviceBusType=topic&subscriptionName=testTopic-subscription&producerOperation=sendMessages&connectionString=RAW(Endpoint=sb://blablablablbalabla")
.log(LoggingLevel.INFO, "Message sent to test topic ${body} and ${headers}")
.setRouteProperties(propertyDefinitions);
as you see above i have tried with everything such as with "setProperty" and "setHeader" different way. i get below response-
Message sent to test topic "{\"accountId\": \"4471112323123\", \"url\": \"test.com\", \"status\": \"PASS\", \"statusMessage\": \"check if received\"}" and {applicationProperties={label: test}, CamelAzureServiceBusApplicationProperties={Label=test, Subject=test}, CamelAzureServiceBusSubject=test, Content-Type=application/json}
This is my producer code-
Test test = new test(uuid, "test.com", "PASS", "check if received");
ProducerTemplate producerTemplate;
producerTemplate.sendBody(direct:start, test.toString());
I have sent a message through azure portal(ui) and this is what looks like the properties:
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
Upvotes: 0
Views: 1130
Reputation: 20185
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
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");
Upvotes: 1