Results 1 to 2 of 2

Thread: JmsTransactionManager and Message acknowledge

  1. #1
    Join Date
    Jan 2006
    Posts
    16

    Question JmsTransactionManager and Message acknowledge

    I implemented following code and the result is that it never actually pulls the message off the queue. That's the effect I desire but only until I acknowledge the message and commit the transaction. Once the transaction is committed, I want the message to be gone from the queue. Can anyone explain why is this occurring?

    Thanks in advance.

    TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
    Message msg = jmsTemplate.receive(queueName);
    TextMessage textMessage = (TextMessage) msg;
    if( msg!=null) {
    strMsg = textMessage.getText();
    msg.acknowledge(); //session is still open within the transaction
    }
    transactionManager.commit(status);

    related configuration in application context is as following.

    <!-- JMS Queue Template -->
    <bean id="jmsQueueTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory"><ref bean="jmsQueueConnectionFactory"/></property>
    <property name="sessionAcknowledgeMode"><value>2</value></property>
    <property name="priority"><value>4</value></property>
    <property name="explicitQosEnabled"><value>true</value></property>
    <property name="pubSubDomain"><value>false</value></property>
    <property name="receiveTimeout"><value>5000</value></property>
    </bean>

    <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTrans actionManager">
    <property name="connectionFactory"><ref local="jmsQueueConnectionFactory"/></property>
    </bean>

    <bean id="jmsOperations" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager"><ref local="jmsTransactionManager"/></property>
    <property name="target"><ref local="jmsQueueTemplate"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="convertAndSend*">PROPAGATION_REQUIRED</prop>
    <prop key="send*">PROPAGATION_REQUIRED</prop>
    <prop key="receive*">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
    </bean>

  2. #2
    Join Date
    Jan 2006
    Posts
    16

    Default

    No takers, huh? Any senior members?

    Quote Originally Posted by dshah
    I implemented following code and the result is that it never actually pulls the message off the queue. That's the effect I desire but only until I acknowledge the message and commit the transaction. Once the transaction is committed, I want the message to be gone from the queue. Can anyone explain why is this occurring?

    Thanks in advance.

    TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
    Message msg = jmsTemplate.receive(queueName);
    TextMessage textMessage = (TextMessage) msg;
    if( msg!=null) {
    strMsg = textMessage.getText();
    msg.acknowledge(); //session is still open within the transaction
    }
    transactionManager.commit(status);

    related configuration in application context is as following.

    <!-- JMS Queue Template -->
    <bean id="jmsQueueTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory"><ref bean="jmsQueueConnectionFactory"/></property>
    <property name="sessionAcknowledgeMode"><value>2</value></property>
    <property name="priority"><value>4</value></property>
    <property name="explicitQosEnabled"><value>true</value></property>
    <property name="pubSubDomain"><value>false</value></property>
    <property name="receiveTimeout"><value>5000</value></property>
    </bean>

    <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTrans actionManager">
    <property name="connectionFactory"><ref local="jmsQueueConnectionFactory"/></property>
    </bean>

    <bean id="jmsOperations" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager"><ref local="jmsTransactionManager"/></property>
    <property name="target"><ref local="jmsQueueTemplate"/></property>
    <property name="transactionAttributes">
    <props>
    <prop key="convertAndSend*">PROPAGATION_REQUIRED</prop>
    <prop key="send*">PROPAGATION_REQUIRED</prop>
    <prop key="receive*">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
    </bean>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •