zjnbshifox
Nov 10th, 2005, 07:29 PM
When I set the ClientAcknowlege in JMS, According to JMS Spec,No. 15th message will redelivered,I must receive NO.15th Message in next receive operation.
But when I use the code below,it would skip No. 15th message, I can't receive the NO.15th Message anymore.
What is the problem in my code or configuration?
ApplicationContext ac = new FileSystemXmlApplicationContext("send.xml");
JmsTemplate jms = (JmsTemplate) ac.getBean("jmsTemplate");
jms.setSessionAcknowledgeMode(Session.CLIENT_ACKNO WLEDGE);
for(int i=1; i<100000;i++){
System.out.println(i);
try {
Message tm = jms.receive();
if(i == 15) throw new RuntimeException();
log.info("[" + tm.getStringProperty("SN") + "]");
tm.acknowledge();
} catch (Exception e) {
System.exit(0);
}
//tm.acknowledge();
}
My config file:
<bean id="dest" class="org.activemq.message.ActiveMQQueue">
<constructor-arg index="0" value="TestHUGE66.Queue" />
</bean>
<bean id="jmsFactory" class="org.activemq.pool.PooledConnectionFactory">
<property name="connectionFactory">
<bean class="org.activemq.ActiveMQConnectionFactory" init-method="start">
<property name="brokerURL" value="tcp://localhost:61616"/>
</bean>
</property>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<bean class="org.springframework.jms.connection.SingleConnectio nFactory">
<property name="targetConnectionFactory">
<ref local="jmsFactory"/>
</property>
</bean>
</property>
<property name="defaultDestination">
<ref bean="dest"/>
</property>
</bean>
ActiveMq use postgres8.0.4,jdbc drivers is postgresql-8.0-314.jdbc3.jar
But when I use the code below,it would skip No. 15th message, I can't receive the NO.15th Message anymore.
What is the problem in my code or configuration?
ApplicationContext ac = new FileSystemXmlApplicationContext("send.xml");
JmsTemplate jms = (JmsTemplate) ac.getBean("jmsTemplate");
jms.setSessionAcknowledgeMode(Session.CLIENT_ACKNO WLEDGE);
for(int i=1; i<100000;i++){
System.out.println(i);
try {
Message tm = jms.receive();
if(i == 15) throw new RuntimeException();
log.info("[" + tm.getStringProperty("SN") + "]");
tm.acknowledge();
} catch (Exception e) {
System.exit(0);
}
//tm.acknowledge();
}
My config file:
<bean id="dest" class="org.activemq.message.ActiveMQQueue">
<constructor-arg index="0" value="TestHUGE66.Queue" />
</bean>
<bean id="jmsFactory" class="org.activemq.pool.PooledConnectionFactory">
<property name="connectionFactory">
<bean class="org.activemq.ActiveMQConnectionFactory" init-method="start">
<property name="brokerURL" value="tcp://localhost:61616"/>
</bean>
</property>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<bean class="org.springframework.jms.connection.SingleConnectio nFactory">
<property name="targetConnectionFactory">
<ref local="jmsFactory"/>
</property>
</bean>
</property>
<property name="defaultDestination">
<ref bean="dest"/>
</property>
</bean>
ActiveMq use postgres8.0.4,jdbc drivers is postgresql-8.0-314.jdbc3.jar