Is it possible to share global variables between nodes?
I'm in a situation where I need to track how many messages are in a Subscriber's Queue. Since there's no straightforward size() function for the queue, I need to track both the amount of publishing and the amount of subscribing. In other words, I am tracking how much one node -- let's call it PubNode -- can keep up with another node -- let's call it SubNode. I've tried to create a brand new node that will track both PubNode and SubNode, but in practice it seems to create unnecessary overhead.
To resolve this, I want to create a "PubNode counter" that SubNode can access. Is it possible to create global variables that two separate nodes can access? It seems that PubNode and SubNode would have to be linked, but I'm pretty sure this isn't possible.
A more radical suggestion might be to simply use the callback to copy the incoming message to a local queue. If this is fast, then you shouldn't end up with (m)any messages on the subscriber queue. Then, you have direct access to the local queue. Of course, there's copy overhead.
Given that you now have your publisher listening to your subscriber, have you looked into using a service for the subscriber to request the next message? Another alternative, depending on the rest of your design specs, would be for the subscriber to implement a queue_size service.