org.apache.activemq.command.Message.clearBody()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(17.6k)|赞(0)|评价(0)|浏览(208)

本文整理了Java中org.apache.activemq.command.Message.clearBody()方法的一些代码示例,展示了Message.clearBody()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.clearBody()方法的具体详情如下:
包路径:org.apache.activemq.command.Message
类名称:Message
方法名:clearBody

Message.clearBody介绍

暂无

代码示例

代码示例来源:origin: apache/activemq

@Override
public boolean sendToDeadLetterQueue(ConnectionContext context, MessageReference messageReference,
                   Subscription subscription, Throwable poisonCause) {
  boolean wasDLQd = super.sendToDeadLetterQueue(context, messageReference, subscription, poisonCause);
  if (wasDLQd) {
    try {
      if (!messageReference.isAdvisory()) {
        BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
        ActiveMQTopic topic = AdvisorySupport.getMessageDLQdAdvisoryTopic(baseDestination.getActiveMQDestination());
        Message payload = messageReference.getMessage().copy();
        if (!baseDestination.isIncludeBodyForAdvisory()) {
          payload.clearBody();
        }
        fireAdvisory(context, topic, payload);
      }
    } catch (Exception e) {
      handleFireFailure("add to DLQ", e);
    }
  }
  return wasDLQd;
}

代码示例来源:origin: apache/activemq

@Override
public void messageExpired(ConnectionContext context, MessageReference messageReference, Subscription subscription) {
  super.messageExpired(context, messageReference, subscription);
  try {
    if (!messageReference.isAdvisory()) {
      BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
      ActiveMQTopic topic = AdvisorySupport.getExpiredMessageTopic(baseDestination.getActiveMQDestination());
      Message payload = messageReference.getMessage().copy();
      if (!baseDestination.isIncludeBodyForAdvisory()) {
        payload.clearBody();
      }
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("expired", e);
  }
}

代码示例来源:origin: apache/activemq

@Override
public void messageConsumed(ConnectionContext context, MessageReference messageReference) {
  super.messageConsumed(context, messageReference);
  try {
    if (!messageReference.isAdvisory()) {
      BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
      ActiveMQTopic topic = AdvisorySupport.getMessageConsumedAdvisoryTopic(baseDestination.getActiveMQDestination());
      Message payload = messageReference.getMessage().copy();
      if (!baseDestination.isIncludeBodyForAdvisory()) {
        payload.clearBody();
      }
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_DESTINATION, baseDestination.getActiveMQDestination().getQualifiedName());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("consumed", e);
  }
}

代码示例来源:origin: apache/activemq

@Override
public void messageDelivered(ConnectionContext context, MessageReference messageReference) {
  super.messageDelivered(context, messageReference);
  try {
    if (!messageReference.isAdvisory()) {
      BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
      ActiveMQTopic topic = AdvisorySupport.getMessageDeliveredAdvisoryTopic(baseDestination.getActiveMQDestination());
      Message payload = messageReference.getMessage().copy();
      if (!baseDestination.isIncludeBodyForAdvisory()) {
        payload.clearBody();
      }
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_DESTINATION, baseDestination.getActiveMQDestination().getQualifiedName());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("delivered", e);
  }
}

代码示例来源:origin: apache/activemq

@Override
public void messageDiscarded(ConnectionContext context, Subscription sub, MessageReference messageReference) {
  super.messageDiscarded(context, sub, messageReference);
  try {
    if (!messageReference.isAdvisory()) {
      BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
      ActiveMQTopic topic = AdvisorySupport.getMessageDiscardedAdvisoryTopic(baseDestination.getActiveMQDestination());
      Message payload = messageReference.getMessage().copy();
      if (!baseDestination.isIncludeBodyForAdvisory()) {
        payload.clearBody();
      }
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      if (sub instanceof TopicSubscription) {
        advisoryMessage.setIntProperty(AdvisorySupport.MSG_PROPERTY_DISCARDED_COUNT, ((TopicSubscription) sub).discarded());
      }
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, sub.getConsumerInfo().getConsumerId().toString());
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_DESTINATION, baseDestination.getActiveMQDestination().getQualifiedName());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("discarded", e);
  }
}

代码示例来源:origin: pierre/meteo

@Override
public void sendToDeadLetterQueue(ConnectionContext context, MessageReference messageReference,
                 Subscription subscription){
  super.sendToDeadLetterQueue(context, messageReference, subscription);
  try {
    if(!messageReference.isAdvisory()) {
      ActiveMQTopic topic = AdvisorySupport.getMessageDLQdAdvisoryTopic(messageReference.getMessage().getDestination());
      Message payload = messageReference.getMessage().copy();
      payload.clearBody();
      fireAdvisory(context, topic,payload);
    }
  } catch (Exception e) {
    handleFireFailure("add to DLQ", e);
  } 
}

代码示例来源:origin: pierre/meteo

@Override
public void messageConsumed(ConnectionContext context, MessageReference messageReference) {
  super.messageConsumed(context, messageReference);
  try {
    if(!messageReference.isAdvisory()) {
      ActiveMQTopic topic = AdvisorySupport.getMessageConsumedAdvisoryTopic(messageReference.getMessage().getDestination());
      Message payload = messageReference.getMessage().copy();
      payload.clearBody();
      fireAdvisory(context, topic,payload);
    }
  } catch (Exception e) {
    handleFireFailure("consumed", e);
  }
}

代码示例来源:origin: pierre/meteo

@Override
public void messageDelivered(ConnectionContext context, MessageReference messageReference) {
  super.messageDelivered(context, messageReference);
  try {
    if (!messageReference.isAdvisory()) {
      ActiveMQTopic topic = AdvisorySupport.getMessageDeliveredAdvisoryTopic(messageReference.getMessage().getDestination());
      Message payload = messageReference.getMessage().copy();
      payload.clearBody();
      fireAdvisory(context, topic,payload);
    }
  } catch (Exception e) {
    handleFireFailure("delivered", e);
  }
}

代码示例来源:origin: org.apache.activemq/activemq-broker

@Override
public boolean sendToDeadLetterQueue(ConnectionContext context, MessageReference messageReference,
                   Subscription subscription, Throwable poisonCause) {
  boolean wasDLQd = super.sendToDeadLetterQueue(context, messageReference, subscription, poisonCause);
  if (wasDLQd) {
    try {
      if (!messageReference.isAdvisory()) {
        BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
        ActiveMQTopic topic = AdvisorySupport.getMessageDLQdAdvisoryTopic(baseDestination.getActiveMQDestination());
        Message payload = messageReference.getMessage().copy();
        if (!baseDestination.isIncludeBodyForAdvisory()) {
          payload.clearBody();
        }
        fireAdvisory(context, topic, payload);
      }
    } catch (Exception e) {
      handleFireFailure("add to DLQ", e);
    }
  }
  return wasDLQd;
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

@Override
public boolean sendToDeadLetterQueue(ConnectionContext context, MessageReference messageReference,
                   Subscription subscription, Throwable poisonCause) {
  boolean wasDLQd = super.sendToDeadLetterQueue(context, messageReference, subscription, poisonCause);
  if (wasDLQd) {
    try {
      if (!messageReference.isAdvisory()) {
        BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
        ActiveMQTopic topic = AdvisorySupport.getMessageDLQdAdvisoryTopic(baseDestination.getActiveMQDestination());
        Message payload = messageReference.getMessage().copy();
        if (!baseDestination.isIncludeBodyForAdvisory()) {
          payload.clearBody();
        }
        fireAdvisory(context, topic, payload);
      }
    } catch (Exception e) {
      handleFireFailure("add to DLQ", e);
    }
  }
  return wasDLQd;
}

代码示例来源:origin: pierre/meteo

@Override
public void messageExpired(ConnectionContext context, MessageReference messageReference, Subscription subscription) {
  super.messageExpired(context, messageReference, subscription);
  try {
    if(!messageReference.isAdvisory()) {
      ActiveMQTopic topic = AdvisorySupport.getExpiredMessageTopic(messageReference.getMessage().getDestination());
      Message payload = messageReference.getMessage().copy();
      payload.clearBody();
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("expired", e);
  }
}

代码示例来源:origin: org.apache.activemq/activemq-all

@Override
public void messageExpired(ConnectionContext context, MessageReference messageReference, Subscription subscription) {
  super.messageExpired(context, messageReference, subscription);
  try {
    if (!messageReference.isAdvisory()) {
      BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
      ActiveMQTopic topic = AdvisorySupport.getExpiredMessageTopic(baseDestination.getActiveMQDestination());
      Message payload = messageReference.getMessage().copy();
      if (!baseDestination.isIncludeBodyForAdvisory()) {
        payload.clearBody();
      }
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("expired", e);
  }
}

代码示例来源:origin: org.apache.activemq/activemq-broker

@Override
public void messageExpired(ConnectionContext context, MessageReference messageReference, Subscription subscription) {
  super.messageExpired(context, messageReference, subscription);
  try {
    if (!messageReference.isAdvisory()) {
      BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
      ActiveMQTopic topic = AdvisorySupport.getExpiredMessageTopic(baseDestination.getActiveMQDestination());
      Message payload = messageReference.getMessage().copy();
      if (!baseDestination.isIncludeBodyForAdvisory()) {
        payload.clearBody();
      }
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("expired", e);
  }
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

@Override
public void messageExpired(ConnectionContext context, MessageReference messageReference, Subscription subscription) {
  super.messageExpired(context, messageReference, subscription);
  try {
    if (!messageReference.isAdvisory()) {
      BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
      ActiveMQTopic topic = AdvisorySupport.getExpiredMessageTopic(baseDestination.getActiveMQDestination());
      Message payload = messageReference.getMessage().copy();
      if (!baseDestination.isIncludeBodyForAdvisory()) {
        payload.clearBody();
      }
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("expired", e);
  }
}

代码示例来源:origin: pierre/meteo

@Override
public void messageDiscarded(ConnectionContext context, Subscription sub, MessageReference messageReference) {
  super.messageDiscarded(context, sub, messageReference);
  try {
    if (!messageReference.isAdvisory()) {
      ActiveMQTopic topic = AdvisorySupport.getMessageDiscardedAdvisoryTopic(messageReference.getMessage().getDestination());
      Message payload = messageReference.getMessage().copy();
      payload.clearBody();
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      if (sub instanceof TopicSubscription) {
        advisoryMessage.setIntProperty(AdvisorySupport.MSG_PROPERTY_DISCARDED_COUNT, ((TopicSubscription)sub).discarded());
      }
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, sub.getConsumerInfo().getConsumerId().toString());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("discarded", e);
  }
}

代码示例来源:origin: org.apache.activemq/activemq-osgi

@Override
public void messageConsumed(ConnectionContext context, MessageReference messageReference) {
  super.messageConsumed(context, messageReference);
  try {
    if (!messageReference.isAdvisory()) {
      BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
      ActiveMQTopic topic = AdvisorySupport.getMessageConsumedAdvisoryTopic(baseDestination.getActiveMQDestination());
      Message payload = messageReference.getMessage().copy();
      if (!baseDestination.isIncludeBodyForAdvisory()) {
        payload.clearBody();
      }
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_DESTINATION, baseDestination.getActiveMQDestination().getQualifiedName());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("consumed", e);
  }
}

代码示例来源:origin: org.apache.activemq/activemq-broker

@Override
public void messageDelivered(ConnectionContext context, MessageReference messageReference) {
  super.messageDelivered(context, messageReference);
  try {
    if (!messageReference.isAdvisory()) {
      BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
      ActiveMQTopic topic = AdvisorySupport.getMessageDeliveredAdvisoryTopic(baseDestination.getActiveMQDestination());
      Message payload = messageReference.getMessage().copy();
      if (!baseDestination.isIncludeBodyForAdvisory()) {
        payload.clearBody();
      }
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_DESTINATION, baseDestination.getActiveMQDestination().getQualifiedName());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("delivered", e);
  }
}

代码示例来源:origin: org.apache.activemq/activemq-all

@Override
public void messageDelivered(ConnectionContext context, MessageReference messageReference) {
  super.messageDelivered(context, messageReference);
  try {
    if (!messageReference.isAdvisory()) {
      BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
      ActiveMQTopic topic = AdvisorySupport.getMessageDeliveredAdvisoryTopic(baseDestination.getActiveMQDestination());
      Message payload = messageReference.getMessage().copy();
      if (!baseDestination.isIncludeBodyForAdvisory()) {
        payload.clearBody();
      }
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_DESTINATION, baseDestination.getActiveMQDestination().getQualifiedName());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("delivered", e);
  }
}

代码示例来源:origin: org.apache.activemq/activemq-broker

@Override
public void messageConsumed(ConnectionContext context, MessageReference messageReference) {
  super.messageConsumed(context, messageReference);
  try {
    if (!messageReference.isAdvisory()) {
      BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
      ActiveMQTopic topic = AdvisorySupport.getMessageConsumedAdvisoryTopic(baseDestination.getActiveMQDestination());
      Message payload = messageReference.getMessage().copy();
      if (!baseDestination.isIncludeBodyForAdvisory()) {
        payload.clearBody();
      }
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_DESTINATION, baseDestination.getActiveMQDestination().getQualifiedName());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("consumed", e);
  }
}

代码示例来源:origin: org.apache.activemq/activemq-broker

@Override
public void messageDiscarded(ConnectionContext context, Subscription sub, MessageReference messageReference) {
  super.messageDiscarded(context, sub, messageReference);
  try {
    if (!messageReference.isAdvisory()) {
      BaseDestination baseDestination = (BaseDestination) messageReference.getMessage().getRegionDestination();
      ActiveMQTopic topic = AdvisorySupport.getMessageDiscardedAdvisoryTopic(baseDestination.getActiveMQDestination());
      Message payload = messageReference.getMessage().copy();
      if (!baseDestination.isIncludeBodyForAdvisory()) {
        payload.clearBody();
      }
      ActiveMQMessage advisoryMessage = new ActiveMQMessage();
      if (sub instanceof TopicSubscription) {
        advisoryMessage.setIntProperty(AdvisorySupport.MSG_PROPERTY_DISCARDED_COUNT, ((TopicSubscription) sub).discarded());
      }
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_MESSAGE_ID, payload.getMessageId().toString());
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_CONSUMER_ID, sub.getConsumerInfo().getConsumerId().toString());
      advisoryMessage.setStringProperty(AdvisorySupport.MSG_PROPERTY_DESTINATION, baseDestination.getActiveMQDestination().getQualifiedName());
      fireAdvisory(context, topic, payload, null, advisoryMessage);
    }
  } catch (Exception e) {
    handleFireFailure("discarded", e);
  }
}

相关文章

Message类方法