【发布时间】:2022-10-05 05:16:25
【问题描述】:
我可以使用此处的示例https://camel.apache.org/components/3.18.x/azure-servicebus-component.html#_azure_servicebus_producer_operations 使用 apache camel 向 azure service bus topic 的特定订阅发送消息。但我无法使用我的代码设置属性.在我的代码下方 -
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);
正如您在上面看到的,我已经尝试了所有方法,例如使用“setProperty”和“setHeader”不同的方式。我得到以下回应-
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}
这是我的生产者代码-
Test test = new test(uuid, "test.com", "PASS", "check if received");
ProducerTemplate producerTemplate;
producerTemplate.sendBody(direct:start, test.toString());
我已经通过 azure portal(ui) 发送了一条消息,这看起来像属性:
如果您看到“主题”是“测试”并且有一个自定义属性“测试”具有值“测试”。
当我使用 apache camel 发送它时,我想看到同样的东西。请帮忙。谢谢
【问题讨论】:
标签: java apache-camel azure-servicebus-topics