Avatar

Please consider registering
guest

sp_LogInOut Log In sp_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 RSS sp_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: 983
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/8/docs/api/java/lang/Runtime.html#addShutdownHook-java.lang.Thread-). It of course depends on what conditions and how the shutdown is triggered.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
15 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 681

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com

Moderators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1