Messages that are sent to specific resource should only be received by that resource

Unfortunately I got no response in the Openfire Dev forum since 1 week, so I ask here:

We want to ensure that a message is sent to one specific resource only. If this resource is not available, it also should NOT be treated as if it were sent to user@domain.

From the XMPP specification:

Else if the JID is of the form <user@domain/resource> and no available resource matches the full JID, the recipient’s server […]SHOULD treat the stanza as if it were addressed to user@domain if it is a message stanza.

And Openfire does exactly this, so that the messages are routed to user@domain.

My question is, would it be possible to write an Openfire plugin, that prevents this behavior and instead stores the messages (which are addressed to an unavailable resource) in the OfflineMessageStore (or elsewhere)?

And the next time that specific resource logs in deliver these messages?

We really want messages to only be received by the resource, they were addressed to.

Thanks for help!

Hi,

We’ve implemented this using a Plugin which adds a packet interceptor and when a packet is received use the SessionManager to check to see if the resource is online. If not, it throws a PacketRejectedException.

I’m afraid I can’t share the source but have a look at the following classes and I’m sure you’ll be able to work it out:

Plugin

InterceptorManager

SessionManager

ClientSession

Good luck!

Thanks for your fast answer!

Is it possible to let the client know about the fact the recipient (resource) is not available?

When I throw the exception, that it gets informed about it, perhaps by sending a Message back to the sender with an information, why it was dropped?!

Well, that should be possible.

Do you think it is a valid option to throw the exception and then store it in the OfflineStorage, but only deliver the message, if that specific resource goes online?

I am not sure if that can be done with a plugin, because afaik the OfflineStorage logic is deep in the Openfire core. Can I intercept messages which are sent by Openfire’s OfflineStorage automatically and then reject them, if the resource is not online and then put it in the offline storage again. (which is basically the same logic as above then).