示例#1
0
  /**
   * process the redelivered message. If the Jms receiver should process the message, it should be
   * returned. Otherwise the connector should throw a <code>MessageRedeliveredException</code> to
   * indicate that the message should be handled by the connector Exception Handler.
   *
   * @param message
   */
  public void handleRedelivery(Message message) throws JMSException, MessagingException {
    if (connector.getMaxRedelivery() <= 0) return;

    String id = message.getJMSMessageID();
    Integer i = (Integer) messages.remove(id);
    if (i == null) {
      if (logger.isDebugEnabled()) {
        logger.debug("Message with id: " + id + " has been redelivered for the fist time");
      }
      messages.put(id, new Integer(1));
      return;
    } else if (i.intValue() == connector.getMaxRedelivery()) {
      if (logger.isDebugEnabled()) {
        logger.debug(
            "Message with id: "
                + id
                + " has been redelivered "
                + (i.intValue() + 1)
                + " times, which exceeds the maxRedelivery setting on the connector");
      }
      JmsMessageAdapter adapter = (JmsMessageAdapter) connector.getMessageAdapter(message);
      throw new MessageRedeliveredException(adapter);

    } else {
      messages.put(id, new Integer(i.intValue() + 1));
      if (logger.isDebugEnabled()) {
        logger.debug("Message with id: " + id + " has been redelivered " + i.intValue() + " times");
      }
    }
  }