Open BigGitWorld opened 10 months ago
Moquette (by way of Netty) uses reference-counted buffers to avoid duplicating data. The last one to receive the buffer realeases it. In this case you pass the buffer on to the super-class, thus the super class releases the buffer and you can no longer use it afterwards. To avoid the release, you have to add a "claim" to it by increasing the reference count before passing it on, and releasing the claim again once you are done:
@Override
public void onPublish(InterceptPublishMessage msg) {
msg.getPayload().retain();
super.onPublish(msg);
final String decodedPayload = msg.getPayload().toString(UTF_8);
System.out.println("Received on topic: " + msg.getTopicName() + " content: " + decodedPayload);
msg.getPayload().release();
}
Or, alternatively, move the call to super to be the last in your method.
Hello. I have embedded the Moquette version
0.17
in a spring boot project and overrided theAbstractInterceptHandler
class to handleonPublish
callback, but I get the following error when I publish a simple json message to the broker.error: