Domanda


I'm writing java-ee application which needs to communicate with java-se clients. I have a use case in which user chooses city to send a package and application sends to jms topic a question which client can take this package. After gathering replies user should see a list of clients to choose the desired one. The problem is that I don't have an idea how to receive those replies. I have tried completion listener, but it's for java-se only. I was thinking about synchronous send/receive, but as far as I know first reply will close receiving. Any hints would be appreciated.
Mariusz

È stato utile?

Soluzione

In the message published on the topic, you could include a message id (perhaps a UUID). The clients could send responses back on a different queue that the server listens to. If each of those responses also contained that message id, your sever would be able to match up the responses to the initial request.

Given that you are using JMS, the whole process is necessarily asynchronous anyway.

You could have an EJB Singleton that stores all the responses in a map, keyed by message id. After a certain amount of time (perhaps use an EJB timer that is scheduled to fire after however long you are willing to wait for a response) check to see what responses have returned and display that list of responding clients to the user.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top