Stopping a component

Added over 1 year ago

Does the method stop() in a component work before shutting down the server (tigase-server-8.0.0-SNAPSHOT-b5058)?

Replies (4)

Added by C P over 1 year ago

how can I call my method before shutting down the server?

Added by Wojciech Kapcia TigaseTeam over 1 year ago

It's described in the documentation

h3. Stopping a component

Component instance may be stopped at any point of Tigase XMPP Server runtime, ie. due to reconfiguration, or due to server graceful shutdown.

In both cases following methods of a component will be called:

void stop() - first method stops component internal processing queues.

void beforeUnregister() (optional) - if component implements UnregisterAware interface this method is called to notify instance of a component that it is being unloaded.

void unregister(Kernel kernel) (optional) - if component implements RegistrarBean called to give component a way to unregister beans (if needed).

So to answer your question - the method will be called before stopping the component instance but not necessarily server.

You can use method tigase.sys.TigaseRuntime#addShutdownHook() to add your custom hook, which will be executed during server shutdown.

Added by C P over 1 year ago

when I override method stop() I expect this method to be called when the component is stopping (to store data in database), but it is not called

Added by Wojciech Kapcia TigaseTeam over 1 year ago

Thank you for reporting - there may be some issue with calling this method, I've created the task to resolve this: #6411 - please watch it to be notified upon resolution.