• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing and concurrent message queues  RSS feed

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I am getting myself confused about how to design a set of application GUIs and core API that need to communicate with a server. The core API uses two simple blocking and concurrent message queues and several GUIs may be run at the same time.

The core API is designed around a simple message format (both ways) that consist of a length, command and optional payload area in raw bytes. A core set of message types are common to all GUIs and some messages are applicable to each GUI only.

A message writer takes commands and optional payloads from a GUI (via command buttons and/or user input), it then creates a message from this and puts the message on a write queue. A socket writing thread takes messages from the write queue and sends them to the server.

Meanwhile a message reader thread reads data from the socket, creates a message from it and puts it in a read queue.

The server may not reply to messages in the order it receives them, it may also send several different broadcast messages.

The original design using SwingWorker threads was fine in simple cases, however now that I am trying to design more complicated GUIs I am not sure how to proceed.

Sending messages is not a problem, for example I can write status information to the GUI before I send messages, such as "Performing action 1".

But I am not sure how to update the GUIs with information in messages on the read queue.

Can anyone offer suggestions?
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!