简体   繁体   English

如何从app server(EJB)通知(或发送消息)swing客户端?

[英]How to notify(or send message) swing client from app server(EJB)?

I have a project that have clients(swing) and will have an EJB application running on server. 我有一个拥有客户端(swing)的项目,并且将在服务器上运行EJB应用程序。

My question is about communication. 我的问题是关于沟通。 I want to use MDB's (message driven beans) when client send message to server. 当客户端向服务器发送消息时,我想使用MDB(消息驱动的bean)。 But i've stucked on the issue that app server sends message (or any data) to notify client. 但我一直坚持app服务器发送消息(或任何数据)来通知客户端的问题。

For example, client1 has a form (a textbox and a button) and client2 has a list (lists data that client1 sends to server). 例如,client1有一个表单(文本框和按钮),client2有一个列表(列出client1发送给服务器的数据)。 When client1 sends the data (message etc) to server, do some job on it than send(notify) the data to client2. 当client1将数据(消息等)发送到服务器时,在其上做一些工作,而不是将数据发送(通知)给client2。

How can i do this? 我怎样才能做到这一点? Any help would be appreciated. 任何帮助,将不胜感激。 Thanks. 谢谢。

There are may ways to achieve what you are asking. 有很多方法可以实现您的要求。

What I personally prefer is: 我个人更喜欢的是:

client1 has a SB(Session Bean) running that connects to a JMS Queue (The JMS Queue is setup on the server) we will call it inQueue for now. client1有一个运行连接到JMS队列的SB(会话Bean)(服务器上设置了JMS队列),我们现在称之为inQueue。

once the form data is in the inQueue you will need an MDB (message driven bean running on the server which will pick up the data from the inQueue we will call it MDBInQueue. 一旦表单数据在inQueue中,您将需要一个MDB(在服务器上运行的消息驱动bean,它将从inQueue中获取数据,我们将其称为MDBInQueue。

The server within the MDBInQueue processes the data received in the form and generates the appropriate output format for client two. MDBInQueue中的服务器处理表单中收到的数据,并为客户端2生成适当的输出格式。

Now again within MDBInQueue it sends the response on another queue again residing in the server. 现在再次在MDBInQueue中,它将响应再次发送到驻留在服务器中的另一个队列。 we will call this outQueue. 我们称之为outQueue。

the client2 has an MDB running which we will call it MDBOutQueue. client2运行了一个MDB,我们称之为MDBOutQueue。 This will pick up the messages generated from the server which are ready to be viewed by the client2. 这将获取从服务器生成的消息,这些消息已准备好由client2查看。

Let me know if you need any additional details 如果您需要任何其他细节,请与我们联系

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM