이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 20. Configuring Pre-Acknowledgments


JMS specifies three acknowledgement modes:

  • AUTO_ACKNOWLEDGE
  • CLIENT_ACKNOWLEDGE
  • DUPS_OK_ACKNOWLEDGE

In some cases you can afford to lose messages in the event of a failure, so it would make sense to acknowledge the message on the server before delivering it to the client. This extra mode is supported by JBoss EAP messaging and is called pre-acknowledge mode.

The disadvantage of pre-acknowledging on the server before delivery is that the message will be lost if the server’s system crashes after acknowledging the message but before it is delivered to the client. In that case, the message is lost and will not be recovered when the system restarts.

Depending on your messaging case, pre-acknowledge mode can avoid extra network traffic and CPU usage at the cost of coping with message loss.

An example use case for pre-acknowledgement is for stock price update messages. With these messages, it might be reasonable to lose a message in event of a crash since the next price update message will arrive soon, overriding the previous price.

Note

If you use pre-acknowledge mode, you will lose transactional semantics for messages being consumed since they are being acknowledged first on the server, not when you commit the transaction.

20.1. Configuring the Server

A connection factory can be configured to use pre-acknowledge mode by setting its pre-acknowledge attribute to true using the management CLI as below:

/subsystem=messaging-activemq/server=default/connection-factory=RemoteConnectionFactory:write-attribute(name=pre-acknowledge,value=true)

20.2. Configuring the Client

Pre-acknowledge mode can be configured in a client’s JNDI context environment, e.g. in a jndi.properties file:

java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
connection.ConnectionFactory=tcp://localhost:8080?preAcknowledge=true

Alternatively, to use pre-acknowledge mode using the JMS API, create a JMS Session with the ActiveMQSession.PRE_ACKNOWLEDGE constant.

// messages will be acknowledge on the server *before* being delivered to the client
Session session = connection.createSession(false, ActiveMQJMSConstants.PRE_ACKNOWLEDGE);
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.