STOMP Heart Beat

158 views
Skip to first unread message

Russell Bowman

unread,
Apr 10, 2018, 3:48:21 AM4/10/18
to A gathering place for the Open Rail Data community
Does someone have a code snippet they code share showing how to implement a heart beat using the stomp library?  Preferably in C#, but others will be helpful.

I don't have a problem with the connection to network rail as the it is kept alive by TD etc messages on the same connection, but internally I redistribute the feeds using separate queues access on separate connections by separate programs. The VSTP connection drops if there is a long(ish) gap between messages. There are several references on the net to heart beats in activemq, but blow me if I can find an example that hints at how to implement it!

(Also, if you've read this far...

For stomp I have two DLLs: Apache.NMS.dll and Apache.NMS.Stomp.dll.

I've seen references on here before to openwire perhaps being more stable (not that I have a problem with stomp), and I think setting activity limits with the openwire library is easier, but, I'm struggling to find the dll's for openwire.  The apache NMS download only has one dll (Apache.NMS.dll), and the connectionfactory call fails as it's unable to find the protocol support.  Pointers gratefully received and will save me an evening of searching. coding, trying, failing.)

Now I must go and do some real work!

Allan Blundell

unread,
Apr 10, 2018, 4:00:42 AM4/10/18
to A gathering place for the Open Rail Data community
OpenWire  is found in Apache.NMS.ActiveMQ.dll, currently i use the Stomp to connect to NROD using C# but only a single connection at,. So i am not sure i can help with your scenario.

Allan 

Chris Bailiss

unread,
Apr 10, 2018, 9:13:03 AM4/10/18
to A gathering place for the Open Rail Data community
I'm not sure this is supported.

The documentation on this page...
... states:

These values are currently not supported but are planned for a later release:
wireFormat.maxInactivityDuration
30000
The maximum inactivity duration (before which the socket is considered dead) in milliseconds. On some platforms it can take a long time for a socket to appear to die, so we allow the broker to kill connections if they are inactive for a period of time. Use by some transports to enable a keep alive heart beat feature. Set to a value <= 0 to disable inactivity monitoring.

WantStuff

unread,
Apr 10, 2018, 2:00:05 PM4/10/18
to A gathering place for the Open Rail Data community
Hi Russell

Its been a while since I used STOMP, but as far as I remember the heartbeats are handled for you by the C# Apache NMS libraries. I recommend using 'failover' rather that vanilla 'stomp' and I'd also recommend creating a Durable consumer to handle the reconnects. This old post of mine on StackOverflow covers these and may give you enough information... https://stackoverflow.com/questions/13590047/why-is-my-stream-being-closed-by-peer/23943450#23943450

Regards,
Martin

Russell Bowman

unread,
Apr 10, 2018, 5:49:28 PM4/10/18
to A gathering place for the Open Rail Data community
Thanks all, that's enough to be working with.  

My evening was lost however chasing down another 'behaviour'... Part of my project involves a plugin in another product, but I discovered that only supports .Net 3.5 and lower, and my plugin was built (like everything else) with .Net 4.6.1 (or whatever the latest is). In getting all the right libraries together, switching build targets and switching away from stomp (there was a good reason), I managed to break everything.  No matter, unwind it all, and it'll work again. Well no, actually. (Why do I not remember to change just one thing at a time! I've been in this game long enough.)

Hours later I have a simple fix, but a fix I'm not sure I should have to do. 


Reply all
Reply to author
Forward
0 new messages