Avatar
Please consider registering
guest
sp_LogInOut Log Insp_Registration Register
Register | Lost password?
Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSSsp_TopicIcon
How to listen to server status changes, especially on shutdown
January 17, 2019
15:46, EET
Avatar
Thomas Reuther
Member
Members
Forum Posts: 33
Member Since:
September 18, 2017
sp_UserOfflineSmall Offline

Hi,

I am using Java SDK 3.1.6. My server uses a timer to repeatedly trigger events in a separate thread. When the server shuts down there is always an exception when this thread is executed (“Exception in thread “Timer-0″ com.prosysopc.ua.server.UaInstantiationException: Could not get type node.”)
I want to stop the timer when the server is going to shut down. I assume it is not the best way to read a node’s value (e.g. ServerStatus) because the reading might fail.

Is there a good way to get notified when the server is going to shut down to stop my extra threads?

Luckily there are no damages when this exception occurs. But it looks awful if there is always an exception message on shutdown. And the return value of this process is always Bad (not 0/Success).

Thomas

January 18, 2019
15:53, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1047
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Is there any reason you cannot simply stop the timer before you call UaServer.shutdown?

If not possible then I would need more details, e.g. is also the JVM shutting down or just a single server? If whole JVM, most applications have a somewhat central place to handle shutdown and they usually register a shutdownhook via Runtime.getRuntime().addShutdownHook (https://docs.oracle.com/javase…..ng.Thread-). It of course depends on what conditions and how the shutdown is triggered.

Forum Timezone: Europe/Helsinki
Most Users Ever Online: 1919
Currently Online:
Guest(s) 31
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 90
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 735
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1545
Posts: 6521
Newest Members:
Jorsiz, wilfredoforeman, ptdenriqueta, basilpullman, Richardmip, mood edibles, LouieWreve, daniellabdx, janessan21, sammiebeak359
Moderators: Jouni Aro: 1029, Pyry: 1, Petri: 1, Bjarne Boström: 1047, Jimmy Ni: 26, Matti Siponen: 353, Lusetti: 0
Administrators: admin: 1