I am working on a system with one master and multiple clients that communicate using JMS.
The server is a three tier application written in Java. In the server’s data access layer, I am sending out JMS messages with tasks on one queue and I am receiving task status messages from the clients on another JMS queue. From those status messages I basically only extract Strings.
I have chosen a three tier architecture because I also need to access databases and do other business related computations before I can send a task to the clients.
I want the Strings of the status messages to be handed through all layers to the GUI where they are displayed.
I had the idead to use the same interface for all layer classes where the Strings go through, to enforce that they all have the same methods for receiving the data.
The alternative would be having separate interfaces for the layer classes, but those would then be essentially the same, except having a different class name.
Which alternative would be the proper way to ensure clean communication between the layers?
I am assuming that this is a psuedo-synchronous response (You have somehow co-related request/response from different queues OR used some polling mechanism on response queue to tie things together). Otherwise I don’t understand how response can flow backwards from a JMS queue to the UI layer.
To your actual question, if list of possible status messages (Strings) is known upfront, why don’t you convert String message recieved from queue to a Status enumeration. This could be passed as response to the other layers (may be wrapped within a Value Object). This would give you better control on what you wish to show on UI as well as help you manage related business logic better (e.g. say you want to provide different business treatment based on Status recieved).