Consider the code for consuming messages from Apache Pulsar that is set up with spring-pulsar:
@PulsarListener(
subscriptionName = "hello-pulsar-sub-2",
topics = "#{dataAssetService.getCompactedTopicsArray()}",
properties = {"readCompacted=true"}
)
public void consumeEntireTopic(
@Payload(required = false) String jsonString,
@Header(PulsarHeaders.TOPIC_NAME) String topic,
@Header(PulsarHeaders.KEY) String key,
@Header(PulsarHeaders.PUBLISH_TIME) String ts
) throws IOException {
// code to handle message here
}
I need an information in listener on when is a given key deleted, i.e. a null payload (a.k.a. tombstone) is sent for that key.
With the code above, an assertion is thrown deep in spring code (org.springframework.messaging.support.MessageBuilder
), when null payload arrives.
So the question is: how to configure @PulsarListener
to receive messages with null payloads?
This is not currently supported, but will be supported via https://github.com/spring-projects/spring-pulsar/issues/506.