コード例 #1
0
  /**
   * Sends a message to the destination
   *
   * @param destination the destination the message should be send to
   * @param message the message to send
   * @param deliveryMode the delivery mode
   * @param priority the priority
   * @param timeToLive how long the message should live
   */
  public void send(
      Destination destination, Message message, int deliveryMode, int priority, long timeToLive)
      throws JMSException {
    if (destination == null) destination = _queue;
    else if (_queue != null && destination != _queue)
      throw new UnsupportedOperationException(
          L.l("MessageProducer: '{0}' does not match the queue '{1}'", destination, _queue));

    if (destination == null)
      throw new UnsupportedOperationException(
          L.l("MessageProducer: null destination is not supported."));

    if (_session == null || _session.isClosed())
      throw new javax.jms.IllegalStateException(
          L.l("getDeliveryMode(): message producer is closed."));

    if (destination instanceof TemporaryTopicImpl) {

      // Message can not be sent on Temporary Queue if Session is not active.
      if (((TemporaryTopicImpl) destination).isClosed()) {
        throw new javax.jms.IllegalStateException(
            L.l("temporary queue '{0}' session is not active", destination));
      }
    }

    _session.send((AbstractDestination) destination, message, deliveryMode, priority, timeToLive);
    // _session.checkThread();
  }