20.2. クライアントの設定
事前承認モードは、jndi.properties
ファイルなどでクライアントの JNDI コンテキスト環境で設定することが可能です。
java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory connection.ConnectionFactory=tcp://localhost:8080?preAcknowledge=true
java.naming.factory.initial=org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory
connection.ConnectionFactory=tcp://localhost:8080?preAcknowledge=true
または、JMS API を使用して事前確認モードを使用するには、ActiveMQSession.PRE_ACKNOWLEDGE
定数で JMS セッションを作成します。
// messages will be acknowledge on the server *before* being delivered to the client Session session = connection.createSession(false, ActiveMQJMSConstants.PRE_ACKNOWLEDGE);
// messages will be acknowledge on the server *before* being delivered to the client
Session session = connection.createSession(false, ActiveMQJMSConstants.PRE_ACKNOWLEDGE);