从响应队列返回值的问题
我正在使用 Rabbitmq Java 客户端 API。我从 GUI 发送两个数字到生产者,生产者放入队列,另一端消费者可以监听队列并读取它,执行两个数字的加法并将结果放入队列,然后我的生产者将再次监听我的响应队列并检索结果。 代码:
while (runInfinite) { QueueingConsumer.Delivery 发货; 尝试 { 交付=消费者.nextDelivery(); } catch (InterruptedException 即) { 继续; } System.out.println("收到结果-" + new String(delivery.getBody())); 我的问题是,
当 while 循环无限运行时,我想将获取的结果发送到 GUI 以显示结果。我想知道,有可能吗?如果可能的话,我该怎么办?
谢谢
i am using Rabbitmq Java client API.i am sending two number from GUI to producer and producer put into queue another side consumer can listen the queue and read it and perform the addition of two number and put result on queue then again my producer will listen the my response queue and retrieve the result.
code:
while (runInfinite) {
QueueingConsumer.Delivery delivery;
try
{
delivery = consumer.nextDelivery();
} catch (InterruptedException ie)
{
continue;
}
System.out.println("Result received-"
+ new String(delivery.getBody()));
}
My problem is when the while loop run infinite time and i want to send the fetched result to an GUI to show result.i want to know that, it is possible ,if possible then what i do?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用两个队列。 GUI 将数字放入 1 个队列中。后台作业将其放入另一个队列。
但我不认为你想要像队列这样的东西来完成上述事情。
查看与您的 GUI 相关的事件操作和回调,看看它们是否适合您想要做的事情。
You can use two queues. The GUI puts the numbers in 1 queue. and the background job puts it another Queue.
But I do not think you want something like a queue to do the above thing.
Look at events actions and callbacks with respect to your GUI and see if they are suitable for the things you want to do.