Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI becomes unresponsive when handling high rate of inbound events

Steven Earl
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic