Forums Register Login

GUI becomes unresponsive when handling high rate of inbound events

+Pie Number of slices to send: Send
Hi,

This is my first post so apologies in advance if this subject has been covered already - I searched through the forum but didn't find anything that seemed quite right.

I am trying to develop a Java GUI which displays the subject tree of TIBCO Rendezvous messages arriving on a UDP transport, and maintains a running count of the number of messages on each subject element within the tree. Each TIBCO message contains a subject which can be made up of several elements. I am breaking the subject elements into a tree (if you imagine each subject element as being equivalent to a subfolder in an explorer window that's not far off).

When a new TIBCO event arrives my code parses the subject to figure out where in my TreeModel (DefaultTreeModel) this node should live. If it exists already (as a previous event with the same subject may have already created a DefaultMutableTreeNode then the count of events received at this node is incremented and DefaultTreeModel.nodeChanged(node) is called, otherwise a new DefaultMutableTreeNode is inserted into the model.
I then also need to increment the message count on each parent node, and again use DefaultTreeModel.nodeChanged(node) on these parents to update the model/tree view.

This all seems to work pretty fine until the rate of TIBCO RV events increases above a certain point. I can have situations where there may be 1,000 events per second coming in off the TIBCO listener.

Initially, when this happened I was seeing 'ArrayIndexOutOfBounds' exceptions originating from the DefaultTreeModel.insertNodeInto() call.

Doing some reading around the problem (Swing tutorial, this and other forums) I think this is because this call wasn't being performed by the Event Dispatch Thread, with the result that the model wasn't being synchronized.

I wrapped the DefaultTreeModel.insertNodeInto() and the DefaultTreeModel.nodeChanged(node) calls within SwingUtilities.invokeLater() as per the code snippet below:



However, now I've done this the GUI becomes unresponsive to user input - I suspect because there are so many events coming in off the TIBCO queue that they might be swamping the 'invokeLater' capability?

Can anyone shed any light on whether this might be the problem. If it is, can anyone suggest a solution - I seem to be between a rock and a hard place of having to update the model very quickly to handle the number of events but having to call SwingUtilities.invokeLater() to ensure it all remains synchronized.

TIA
Steve
I don't always make ads but when I do they're tiny
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 657 times.
Similar Threads
MutableTreeNode that does not allow duplicate Objects
Many (really many) tasks in Swing thread
self-generating JTable
how to add a new node to already existing node but i dont know the parent node
SAX Parser
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:42:54.