示例#1
0
  public final void sendMessage(NevadoDestination destination, NevadoMessage message)
      throws JMSException {
    if (destination == null) {
      throw new NullPointerException();
    }

    // Initialize message as needed
    if (message.isDisableMessageID()) {
      message.setNevadoProperty(NevadoProperty.DisableMessageID, true);
    }
    if (!message.isDisableTimestamp()) {
      message.setJMSTimestamp(System.currentTimeMillis());
    }

    if (destination instanceof NevadoQueue) {
      if (isAsync() && !message.isDisableMessageID() && message.getJMSMessageID() == null) {
        message.setJMSMessageID(MessageIdUtil.createMessageId());
      }
      String serializedMessage = serializeMessage(message);
      String sqsMessageId = sendSQSMessage((NevadoQueue) destination, serializedMessage);
      if (!message.isDisableMessageID() && message.getJMSMessageID() == null) {
        message.setJMSMessageID("ID:" + sqsMessageId);
      }
      _log.info("Sent message to SQS " + sqsMessageId);
    } else if (destination instanceof NevadoTopic) {
      if (!message.isDisableMessageID() && message.getJMSMessageID() == null) {
        message.setJMSMessageID("ID:" + MessageIdUtil.createMessageId());
      }
      String serializedMessage = serializeMessage(message);
      sendSNSMessage((NevadoTopic) destination, serializedMessage);
    } else {
      throw new IllegalStateException("Invalid destination: " + destination.getClass().getName());
    }
  }
示例#2
0
  protected final SQSQueue getSQSQueue(NevadoDestination destination) throws JMSException {
    if (destination == null) {
      throw new JMSException("Destination is null");
    }

    if (destination.isDeleted()) {
      throw new InvalidDestinationException("Destination " + destination + " has been deleted");
    }

    NevadoQueue queue =
        (destination instanceof NevadoQueue)
            ? (NevadoQueue) destination
            : ((NevadoTopic) destination).getTopicEndpoint();
    return getSQSQueueImpl(queue);
  }