I want to store retained messages externally (Azure Blob storage). In the HiveMQ extension SDK I can’t find an appropriate callback method that is called when HiveMQ receives a message that should be retained.
You can create your custom HiveMQ Broker Extension and register a custom PublishInboundInterceptor, that checks the retain property of the message and performs your custom actions:
public class myInterceptor implements PublishInboundInterceptor {
@Override
public void onInboundPublish(
final @NotNull PublishInboundInput publishInboundInput,
final @NotNull PublishInboundOutput publishInboundOutput) {
if (publishInboundOutput.getPublishPacket().getRetain()) {
// your code to store retained message
}
}
}
You can find a good open source example of creating a custom HiveMQ Extension in our HiveMQ 4 Hello World Extension repository.
I hope this will help you to implement your use case successfully.