powered by Jive Software

Message vs. IQ routing

Why does this arrive at the intended receipient…

MessageRouter messageRouter = XMPPServer.getInstance().getMessageRouter();

Message message = new Message();

message.setTo(receiver);

message.setFrom(originator);

message.setSubject(“test”);

message.setBody(“Useless content.”);

messageRouter.route(message);

/code

…while this does not?

IQRouter iqRouter = XMPPServer.getInstance().getIQRouter();

IQ iq = new IQ(IQ.Type.set);

iq.setTo(receiver);

iq.setFrom(originator);

Document document = DocumentHelper.createDocument();

Element jingle = document.addElement(“jingle”, “http://jabber.org/protocol/jingle”);

iq.setChildElement(jingle);

iqRouter.route(iq);

/code

(both using the same strings for receiver and originator).

Hey Guus,

I don’'t have access to the “receiver” variable but I bet that it contains a bare JID rather than a full JID. When a message is sent to a bare JID then the server will forward the message to the “best” resource that the target user is using. However, IQ packets sent to bare JIDs are being handled by the server itself. If you want an IQ packet to be delivered to a client then you should send it to the full JID of the user (i.e. includes the resource).

Regards,

– Gato

That must be it. Is there any quick way to get a (full) JID for the highest priority connection for a specific user?

Message was edited by:

Guus

Hey Guus,

Currently the best way is to do something like this:

XMPPServer.getInstance().getRoutingTable().getBestRoute(bareJID).

Regards,

– Gato

Ok, thanks. I’'ll try it that way.