请问message的properties可选属性在哪里设置呢

public class MyMessageListener implements MessageListener {
@Override
public void received(Consumer consumer, Message msg) {
System.out.println(“Value / data payload:” + msg.getValue());
System.out.println(“Key:” + msg.getKey());
System.out.println(“Properties:” + msg.getKey());
Map<String, String> properties = msg.getProperties();
Iterator iterator = properties.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
System.out.println(" key=" + key + " value=" + properties.get(key));
}

我可以通过上面的代码获取,但不知道如何set,感谢。

这是我的生产者:
@RequestMapping(“sendMessage”)
public String sendMessage() throws PulsarClientException {
for (int i = 0; i < 10; i++) {
String sendMessage = “生产的消息” + (i + 1);
producer.send(sendMessage);
System.out.println(sendMessage);
}
return “成功生产”;
}
没有看到可以set properites的API

properites需要在创建producer对象时设置

Producer<String> producer = client.newProducer(Schema.STRING)
        .topic(topic)
        .properties(new HashMap<>())
        .sendTimeout(3, TimeUnit.SECONDS)
        .create();

@FuJun 这个是对生产者设置的,可以对指定的消息设置吗?

producer.newMessage().properties(new HashMap<>()).value("xxxx").send();