PublishOutboundInterceptor missing?

I’m using the Community Edition of HiveMQ, and am attempting to write an extension to log some PUBLISH message to a database. Looking through the SDK documentation, it would appear I should use a PublishOutboundInterceptor to accomplish this.

The hivemq-extension-sdk references it, and IntelliJ sees the interface just fine in the SDK, but it appears that the actual server jar does not contain an PublishOutboundInterceptor class, and I get this error:

java.lang.NoClassDefFoundError: com/hivemq/extension/sdk/api/interceptor/publish/PublishOutboundInterceptor

Is this something that is not included in the community edition, or am I missing something?


Hi hamster,

this can happen if you are using the HiveMQ CE version hivemq-ce-2019.1.
The publish outbound interceptor was introduced not long ago into the community edition (12. July) and isn’t contained in a release version yet.

Use the newest version and you should be fine (you will have to build it).


You’re right. Compiling the newest fixed that issue.

I note that if I connect a client and publish, the outbound interceptor does not fire if no one is subscribed, which I guess makes sense. I’m attempting to log all published messages to a database. Perhaps an inbound interceptor makes more sense, but the docs seem to want one to use the outbound interceptor for doing things with a database.

Hi hamster,

the PublishInboundInterceptor is called for each incoming PUBLISH message (Client -> Broker).

The PublishOutboundInterceptor is called for each PUBLISH message HiveMQ sends to subscribed clients (Broker -> Client), that means if for example one incoming PUBLISH message is sent to 100 subscriber the OutboundInterceptor is called 100 times.

So depending on what kind of messages you want to log, you can use one or the other (or maybe both).
If you roughly sketch your use case, I can give you some advice.


I swapped to an inbound interceptor and I think that will work better for my use case.

Basically, I want to log all published messages on a couple of topics out to a database.

Hi hamster,

This is quite vague, do you only care for incoming publish messages or also outgoing publish messages for those topics?

If you only care for the incoming publish messages (Clients → PUBLISH → Broker) then the inbound interceptor is the correct one.
But if you also should be interested in the outgoing publish messages (Broker → PUBLISH → Clients)
you will also need the outbound interceptor.