0
我得到这个消息不承认错误:JMS消息不承认错误
javax.jms.IllegalStateException: Message not delivered
at com.tibco.tibjms.TibjmsxSessionImp._confirmNonTransacted(TibjmsxSessionImp.java:3295)
at com.tibco.tibjms.TibjmsxSessionImp._confirm(TibjmsxSessionImp.java:3644)
at com.tibco.tibjms.TibjmsxSessionImp._confirmNonAuto(TibjmsxSessionImp.java:4980)
at com.tibco.tibjms.TibjmsMessage.acknowledge(TibjmsMessage.java:609)
这里是我的代码:
public processMessage(Message pMessage){
try{
performOperation();
}
catch(Exception e){
}finally{
if (pMessage != null) {
try {
pMessage.acknowledge();
} catch (Exception e) {
try {
if (pMessage.getJMSRedelivered()) {
log.info("Message has been redelivered");
} else
log.error(("Message has not been delivered"),e);
} catch (JMSException e1) {
log.error(e1);
}
}
}
return null;
}
public boolean performOperation(somedata){
try{
insert into database
}
catch(DataIntegrityViolationException e){
do something
if (pMessage != null){
pMessage.acknowledge();
}
}
}
}
我不知道是如何被创建的JMS会话,我已经更新了代码。 APP在prop中配置了生产者和消费者。 – user1910892
这是行不通的,除非你将它作为参数传递,否则'pMessage'不在'processMessage()'的作用域中。您应该在processMessage()中确认并保留所有与消息相关的操作。 – raffian
我传递pMessage作为参数。看得更清楚我在performOperation方法中有不同的条件,并且我在每个条件之后都承认,但是对于每条成功的消息,我正在使用finally确认。 – user1910892