Project

General

Profile

Stopping a component

C P
Added 2 months 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 2 months ago

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

Added by Wojciech Kapcia 2 months ago

It's described in the documentation http://docs.tigase.org/tigase-server/snapshot/Development_Guide/html_chunk/cil8.html:

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 about 2 months 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 about 2 months 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.

    (1-4/4)