Announcement Announcement Module
Collapse
No announcement yet.
JmsTransactionManager and Message acknowledge Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    No takers, huh? Any senior members?

    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>

    Comment

    Working...
    X