AMQ中Acknowledge那些事

应答模式和transaction的关系==>
0.Session.SESSION_TRANSACTED (0)
1.Session.AUTO_ACKNOWLEDGE (1)
2.Session.CLIENT_ACKNOWLEDGE (2)
3.Session.DUPS_OK_ACKNOWLEDGE (3)
4.EMQSession.INDIVIDUAL_ACKNOWLEDGE (4)
说明:SESSION_TRANSACTED是专门用作事务的应答模式的,非事务时,采用其他4种。
/////////////begin//////
1.AUTO_ACKNOWLEDGE     With this acknowledgment mode, the session automatically acknowledges a client's receipt of a message either
                        when the session has successfully returned from a call to receive or when the message listener the session has
            called to process the message successfully returns.
            ==>receive方法本身成功返回或者而onMessage时,是在成功处理消息返回,因为onMessage时,处理消息的过程在onMessage方法中完成。
2.DUPS_OK_ACKNOWLEDGE     With this acknowledgment mode, the session automatically acknowledges a client's receipt of a message either
                        when the session has successfully returned from a call to receive or when the message listener the session has
            called to process the message successfully returns. Acknowlegements may be delayed in this mode to increase
            performance at the cost of the message being redelivered this client fails.
3.CLIENT_ACKNOWLEDGE     With this acknowledgment mode, the client acknowledges a consumed message by calling the message's acknowledge method.
4.SESSION_TRANSACTED     Messages will be consumed when the transaction commits.
/////////////end////////
AUTO_ACKNOWLEDGE和DUPS_OK_ACKNOWLEDGE的区别是【DUPS_OK_ACKNOWLEDGE】会出现重复应答,即当客户端失败时,redelivered消息会被分发到客户端,
而【AUTO_ACKNOWLEDGE】时,redelivered消息不会分发到客户端,即仅当mq server重启后才会分发到客户端;

你可能感兴趣的:(activemq,jms)