Openfire with hazelcast clustering

Hi all,

I am new to Openfire and trying to understand how can we use it for messaging platform.

Usecase is to send messages from one service (Service X) to different clients. There can be more than one connection between client to the XMPP server. Service X will send messages for all the clients.

I am looking for inputs on how can it be achieved. I see MUC for multi user chat. But what are the option for same users chat but with multiple connections. And does hazelcast support the multiple connections?

In XMPP clients are identified by their jid eg: “node@domain/ressource”
node = username
domain = xmpp domain
ressource = part of the jid to identify the “connection”
clients can log into server with same bare-jid (node@domain) + resource. This is known as full-jid.
If one client / service sends a message to a bare-jid all connections will normaly receive it.
If the message was sent to a full-jid the server will route it to that specific client only. (If you dont enable special preferences in openfire: route.all-resources or route.really-all-resources).

On MUC the clients are also identified by their jid. But for security reasons the real jid is normaly masked.
In MUCs you have to select a nickname. The server will then route messages from the masked jid to the realjid and back…
muc-jid: roomname@domain/nickname
In MUCs nicknames have to be unique per room for different users, but same user could join a room with the same nickname:

eg: User A with following jids:

userA@domain/ressource1, userA@domain/ressource2, userA@domain/ressource3
can join the muc room@conference.domain

User A could select “COOLNAME” as nickname and will join the room with room@conferenec.domain/COOLNAME

All messages to the jid above will be routed to all jids of UserA. If UserA takes different nicknames for every three jids when joining the room, the messages could be sent to one or all jids

Thanks for the reply. Is there any other option apart from muc to support chat between client and servers? and any idea how will hazelcast support this usecase?

Basically the whole xmpp ecosystem is a client - server architecture.
And hazelcast is used as a plugin. It will then connect two or more openfire instances and let them act as one scaled service.

What do you mean by connect two or more instances here?

Sevice X —> XMPP servers <–> Clients
So does that mean service X will just send the message to any XMPP server instance and the instances will know which instance is connected to client? If yes, can you please elaborate more on how are messages passed on to other instance.
If no, can you please explain how does it work.

If you like to use a clustered environment, than you first have to set up a load balancer in front of the openfire servers. The openfire servers are connected to each other on port 5701…
Clients should connect to the loadbalancer, which will then connect to one of the openfire instances.
All openfire instances have to connect to the same database backend.

Should look like this:

Server X                               --> Openfire 1 <-------
                                      |       |              |
Client X     <----> Load Balancer <----> Openfire 2 <---> Database
                                      |       |              |
                                       --> Openfire 3 <-------

More infos here: Hazelcast Clustering Plugin Readme

Each XMPP entity (which can be a server, a client, or a service) is an addressable entity. Routing of XMPP data takes place on the XMPP level, not on the TCP level. This means that a client uses only one TCP connection to the server, over which it sends and receives all its data. The XMPP server acts as a router: it will look at the addressing of the data that is sent by the client, and forward it to the corresponding entity.

As an aside: I’m not sure if a load balancer is all that imporant, as XMPP implementations will use DNS SRV resolution to find a suitable server to use.

I mentioned the load balancer because the original question was about clustering too. Thats all…

“I’m not sure if a load balancer is all that imporant, as XMPP implementations will use DNS SRV resolution to find a suitable server to use.”

Could you please elaborate more on this? I am not aware about DNS SRV resolution. How does it work?

How DNS is used with XMPP is detailled in the XMPP specifications. Of particular interest is section 3.2.1 of RFC 6120. If you Google around, you’ll easily find a couple of example configurations that will illustrate the mechanisms that are used.