public void send(
     Destination destination, Message message, int deliveryMode, int priority, long timeToLive)
     throws JMSException {
   session.lock();
   try {
     if (trace)
       log.trace(
           "send "
               + this
               + " destination="
               + destination
               + " message="
               + message
               + " deliveryMode="
               + deliveryMode
               + " priority="
               + priority
               + " ttl="
               + timeToLive);
     producer.send(destination, message, deliveryMode, priority, timeToLive);
     if (trace) log.trace("sent " + this + " result=" + message);
   } finally {
     session.unlock();
   }
 }
  /**
   * 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();
  }
 public void send(Destination destination, Message message) throws JMSException {
   session.lock();
   try {
     if (trace) log.trace("send " + this + " destination=" + destination + " message=" + message);
     producer.send(destination, message);
     if (trace) log.trace("sent " + this + " result=" + message);
   } finally {
     session.unlock();
   }
 }
  /** Sets true if message ids should be disabled by default. */
  public void setDisableMessageID(boolean disable) throws JMSException {
    if (_session == null || _session.isClosed())
      throw new javax.jms.IllegalStateException(
          L.l("setDisableMessageID(): message producer is closed."));

    _disableMessageId = disable;
  }
  /** Returns true if message ids are disabled by default. */
  public boolean getDisableMessageID() throws JMSException {
    if (_session == null || _session.isClosed())
      throw new javax.jms.IllegalStateException(
          L.l("getDisableMessageID(): message producer is closed."));

    return _disableMessageId;
  }
  /** Sets the default delivery mode. */
  public void setDeliveryMode(int deliveryMode) throws JMSException {
    if (_session == null || _session.isClosed())
      throw new javax.jms.IllegalStateException(
          L.l("setDeliveryMode(): message producer is closed."));

    _deliveryMode = deliveryMode;
  }
  /** Returns the default delivery mode. */
  public int getDeliveryMode() throws JMSException {
    if (_session == null || _session.isClosed())
      throw new javax.jms.IllegalStateException(
          L.l("getDeliveryMode(): message producer is closed."));

    return _deliveryMode;
  }
  /** Returns the producer's destination. */
  public Destination getDestination() throws JMSException {
    if (_session == null || _session.isClosed())
      throw new javax.jms.IllegalStateException(
          L.l("getDestination(): message producer is closed."));

    return _queue;
  }
  /** Sets the default time to live. */
  public void setTimeToLive(long timeToLive) throws JMSException {
    if (_session == null || _session.isClosed())
      throw new javax.jms.IllegalStateException(
          L.l("setTimeToLive(): message producer is closed."));

    _timeToLive = timeToLive;
  }
  /** Returns the default time to live */
  public long getTimeToLive() throws JMSException {
    if (_session == null || _session.isClosed())
      throw new javax.jms.IllegalStateException(
          L.l("getTimeToLive(): message producer is closed."));

    return _timeToLive;
  }
  /** Sets the default priority. */
  public void setPriority(int priority) throws JMSException {
    if (_session == null || _session.isClosed())
      throw new javax.jms.IllegalStateException(
          L.l("setDeliveryMode(): message producer is closed."));

    _priority = priority;
  }
 public void close() throws JMSException {
   if (trace) log.trace("close " + this);
   try {
     closeProducer();
   } finally {
     session.removeProducer(this);
   }
 }
  /** Returns the default priority */
  public int getPriority() throws JMSException {
    if (_session == null || _session.isClosed())
      throw new javax.jms.IllegalStateException(L.l("getPriority(): message producer is closed."));

    return _priority;
  }