openfire-restAPI-plugin icon indicating copy to clipboard operation
openfire-restAPI-plugin copied to clipboard

Newly created MUC chat service(while creating MUC room) is not clustering.

Open mayurtailor009 opened this issue 5 years ago • 14 comments

Hi team,

I am working in openfire cluster environment. I have 2 node of openfire say as node_1 and node_2. When i create new MUC room(as chat_room1) with new chat service(as service_1). It creates MUC room as chat_room1 and service as service_1 on node_1 but not on node_2 because the chat service(service_1) is not clustering(sync) on another node(node_2).

As i see in createRoom method, call of ServiceAddedEvent is not there to cluster the chat service. Please fix this issue, it very critical for me.

Thanks

mayurtailor009 avatar Jul 31 '19 06:07 mayurtailor009

How is this related to Rest Api? Maybe you should close this and post in Hazelcast clustering plugin repo or in the forums, if the issue is with Openfire itself rather than with the plugin.

Btw, telling that this is critical to you won't do anything. There are only a few volunteers with limited time here. If this is really critical to you, pay someone to create a patch.

wrooot avatar Jul 31 '19 06:07 wrooot

Hi @wrooot Below code should be there(MUCRoomController.java->createRoom method) to clustering the chat service as doing for chat room while creating chat room using rest api:- if (ClusterManager.isClusteringStarted()) { CacheFactory.doClusterTask(new ServiceAddedEvent('service_1','service_1',false); }

Please let me know if i am going in another direction.

mayurtailor009 avatar Jul 31 '19 06:07 mayurtailor009

You can actually call just

CacheFactory.doClusterTask(...);

as it's a null event for non-clustered setups.

However, it's not a ServiceEvent you want - that just simply tells the other nodes that a service has been added, not that a room has been created. I'm not sure exactly what the cluster task you need is, you may have to dig a bit deeper in the code for that.

Greg

GregDThomas avatar Jul 31 '19 07:07 GregDThomas

@GregDThomas , Thanks for your input.

Let me explore more in code of rest api and openfire.

mayurtailor009 avatar Jul 31 '19 09:07 mayurtailor009

Hi @GregDThomas I want is to sync newly created chat service on all the clustered openfire nodes when new room with new chat service created.

mayurtailor009 avatar Aug 01 '19 08:08 mayurtailor009

I've not spent much time in this area of code, so am not entirely confident of my next statement, but ...

I would expect that there is only one chat service that serves all rooms - so there is no need to create a new one on the other nodes in the cluster.

I note that there is no code that references a ServiceAddedEvent in the core Openfire code; so whatever code creates a MUC room via the normal method manages to get it shared across the cluster without using ServiceAddedEvent. For example, MultiUserChatServiceImpl, c. line 728, does so by calling a cluster task for the new room and each of the new rooms occupants. https://github.com/igniterealtime/Openfire/blob/master/xmppserver/src/main/java/org/jivesoftware/openfire/muc/spi/MultiUserChatServiceImpl.java#L728

Aside; if you running Openfire 4.4.0 then clustering is broken, which may explain the problem you're seeing.

GregDThomas avatar Aug 01 '19 09:08 GregDThomas

@GregDThomas thanks for your inputs. I am working on multi-tenant web application where each tenant have own chat service and own chat rooms. User can create N number of tenant at run-time, that is the reason i need new chat service for new tenant and that chat service needs to sync in all nodes of cluster.

mayurtailor009 avatar Aug 01 '19 10:08 mayurtailor009

Ah, OK in which case you may well be right in your original use of ServiceAddedEvent() - but your best bet is to try and fix your proble, and if it works, submit a PR!

GregDThomas avatar Aug 01 '19 10:08 GregDThomas

This has also arised over at https://github.com/igniterealtime/openfire-hazelcast-plugin/issues/30

It's essentially the same issue (I think) so it looks to me like a bug in core Openfire, not any of the plugins.

GregDThomas avatar Aug 06 '19 10:08 GregDThomas

I believe this if fixed in I believe this is now fixed in https://github.com/igniterealtime/Openfire/pull/1479

GregDThomas avatar Sep 08 '19 16:09 GregDThomas

https://issues.igniterealtime.org/browse/OF-1858

GregDThomas avatar Sep 09 '19 12:09 GregDThomas

@GregDThomas hello, seems like the issue is not fixed and it persists.

ajaygajra avatar Dec 25 '19 13:12 ajaygajra

I'm seeing something similar. When I'm in a cluster and I create a room, the room exists properly in the database, but is incorrect in the cache. When I look at it in the cache, the settings are wrong, the ID is -1, and the savedToDB value is False.

I've opened PR #111 that duplicates the same code that the Admin interface uses, to explicitly sync the cache when creating or updating a MUC.

Fishbowler avatar Jun 24 '22 15:06 Fishbowler

@GregDThomas thanks for your inputs. I am working on multi-tenant web application where each tenant have own chat service and own chat rooms. User can create N number of tenant at run-time, that is the reason i need new chat service for new tenant and that chat service needs to sync in all nodes of cluster.

Hey, how did you finally solve the muc cluster problem? Is the MultiUserChatServiceImpl class modified? Or is it more wiretapping?

lijianM avatar Oct 31 '22 07:10 lijianM