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: 1026
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: 1919

Currently Online:
12 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 737

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1524

Posts: 6450

Newest Members:

fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1