0

我收到此消息未确认错误:

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();
       }
   }
}

    }
4

1 回答 1

0

您如何创建 JMS 会话?您只能在非事务模式下进行客户端确认,因此请确保会话设置如下:

connection.createSession( false, Session.CLIENT_ACKNOWLEDGE);

此外,您正在执行message.acknowledge()in finally,这意味着如果performOperation()失败,则无论如何您都在确认该消息,这意味着该消息将不会被重新传递以进行另一次尝试。考虑做这样的事情,performOperation()在消息失败时根据代理配置重新传递:

public processMessage(Message pMessage){
    try{
        performOperation();
        pMessage.acknowledge();
    }
    catch(Exception e){
     }
于 2013-08-21T19:21:26.833 回答