消费者在ActiveMQ中的致谢 [英] Acknowledgement from Consumer in ActiveMQ

查看:142
本文介绍了消费者在ActiveMQ中的致谢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ActiveMQ编写Java应用程序.我有一个生产者类(需要用户输入)和一个带有侦听器的消费者类,以便消息到达后,消息侦听器立即执行onMessage(msg)函数. 但是,我的问题是,消费者何时将确认发送回给经纪人,以使味精从经纪人中出队?是在完成onMessage(msg)函数中编写的动作之后还是只是在调用onMessage(msg)函数时?

I am writing a Java application using ActiveMQ. I have a Producer Class (which takes user input) and a Consumer Class with a listener, so that as soon as messages arrive, Message Listener executes the onMessage(msg) function. My question, though, is when does a consumer sends back the acknowledgement to the broker, so that the msg is de-queued from the broker? Is it after completing the actions written in the onMessage(msg) function or is it just when the onMessage(msg) function is invoked?

推荐答案

在正常情况下,ack是在onMessage完成后发送的,因为它需要处理onMessage引发异常的情况.

In the normal case the ack is sent after the onMessage completes since it needs to handle the case of onMessage throwing an exception.

这篇关于消费者在ActiveMQ中的致谢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆