/**
   * Publish message
   *
   * @param message The message
   * @param deliveryMode The delivery mode
   * @param priority The priority
   * @param timeToLive The time to live
   * @exception JMSException Thrown if an error occurs
   */
  public void publish(
      final Message message, final int deliveryMode, final int priority, final long timeToLive)
      throws JMSException {
    session.lock();
    try {
      if (HornetQRATopicPublisher.trace) {
        HornetQRALogger.LOGGER.trace(
            "send "
                + this
                + " message="
                + message
                + " deliveryMode="
                + deliveryMode
                + " priority="
                + priority
                + " ttl="
                + timeToLive);
      }

      checkState();

      ((TopicPublisher) producer).publish(message, deliveryMode, priority, timeToLive);

      if (HornetQRATopicPublisher.trace) {
        HornetQRALogger.LOGGER.trace("sent " + this + " result=" + message);
      }
    } finally {
      session.unlock();
    }
  }
  /**
   * Set the client id
   *
   * @param clientID The value
   */
  public void setClientID(final String clientID) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("setClientID(" + clientID + ")");
    }

    this.clientID = clientID;
  }
  /**
   * Get the client id
   *
   * @return The value
   */
  public String getClientID() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("getClientID()");
    }

    return clientID;
  }
  /**
   * Use transactions
   *
   * @return True if transacted; otherwise false
   */
  public boolean isTransacted() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("isTransacted() " + transacted);
    }

    return transacted;
  }
  /**
   * Get the password
   *
   * @return The value
   */
  public String getPassword() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("getPassword()");
    }

    return password;
  }
  /**
   * Set the user name
   *
   * @param userName The value
   */
  public void setUserName(final String userName) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("setUserName(" + userName + ")");
    }

    this.userName = userName;
  }
  /**
   * Get the user name
   *
   * @return The value
   */
  public String getUserName() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("getUserName()");
    }

    return userName;
  }
  /**
   * Get the acknowledge mode
   *
   * @return The mode
   */
  public int getAcknowledgeMode() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("getAcknowledgeMode()");
    }

    return acknowledgeMode;
  }
예제 #9
0
  /**
   * Create a new wrapper
   *
   * @param consumer the queue receiver
   * @param session the session
   */
  public HornetQRAQueueReceiver(final QueueReceiver consumer, final HornetQRASession session) {
    super(consumer, session);

    if (HornetQRAQueueReceiver.trace) {
      HornetQRALogger.LOGGER.trace("constructor(" + consumer + ", " + session + ")");
    }
  }
예제 #10
0
/**
 * A wrapper for a queue receiver
 *
 * @author <a href="mailto:[email protected]">Adrian Brock</a>
 * @author <a href="mailto:[email protected]">Jesper Pedersen</a>
 * @version $Revision: $
 */
public class HornetQRAQueueReceiver extends HornetQRAMessageConsumer implements QueueReceiver {
  /** Whether trace is enabled */
  private static boolean trace = HornetQRALogger.LOGGER.isTraceEnabled();

  /**
   * Create a new wrapper
   *
   * @param consumer the queue receiver
   * @param session the session
   */
  public HornetQRAQueueReceiver(final QueueReceiver consumer, final HornetQRASession session) {
    super(consumer, session);

    if (HornetQRAQueueReceiver.trace) {
      HornetQRALogger.LOGGER.trace("constructor(" + consumer + ", " + session + ")");
    }
  }

  /**
   * Get queue
   *
   * @return The queue
   * @exception JMSException Thrown if an error occurs
   */
  public Queue getQueue() throws JMSException {
    if (HornetQRAQueueReceiver.trace) {
      HornetQRALogger.LOGGER.trace("getQueue()");
    }

    checkState();
    return ((QueueReceiver) consumer).getQueue();
  }
}
예제 #11
0
  /**
   * Get the topic
   *
   * @return The topic
   * @exception JMSException Thrown if an error occurs
   */
  public Topic getTopic() throws JMSException {
    if (HornetQRATopicPublisher.trace) {
      HornetQRALogger.LOGGER.trace("getTopic()");
    }

    return ((TopicPublisher) producer).getTopic();
  }
예제 #12
0
  /**
   * Create a new wrapper
   *
   * @param producer the producer
   * @param session the session
   */
  public HornetQRATopicPublisher(final TopicPublisher producer, final HornetQRASession session) {
    super(producer, session);

    if (HornetQRATopicPublisher.trace) {
      HornetQRALogger.LOGGER.trace("constructor(" + producer + ", " + session + ")");
    }
  }
  /**
   * Get the connection type
   *
   * @return The type
   */
  public int getType() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("getType()");
    }

    return type;
  }
  /**
   * Set the password
   *
   * @param password The value
   */
  public void setPassword(final String password) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("setPassword(****)");
    }

    this.password = password;
  }
예제 #15
0
  /**
   * Get queue
   *
   * @return The queue
   * @exception JMSException Thrown if an error occurs
   */
  public Queue getQueue() throws JMSException {
    if (HornetQRAQueueReceiver.trace) {
      HornetQRALogger.LOGGER.trace("getQueue()");
    }

    checkState();
    return ((QueueReceiver) consumer).getQueue();
  }
예제 #16
0
  /**
   * Publish message
   *
   * @param message The message
   * @exception JMSException Thrown if an error occurs
   */
  public void publish(final Message message) throws JMSException {
    session.lock();
    try {
      if (HornetQRATopicPublisher.trace) {
        HornetQRALogger.LOGGER.trace("send " + this + " message=" + message);
      }

      checkState();

      ((TopicPublisher) producer).publish(message);

      if (HornetQRATopicPublisher.trace) {
        HornetQRALogger.LOGGER.trace("sent " + this + " result=" + message);
      }
    } finally {
      session.unlock();
    }
  }
  /**
   * Constructor
   *
   * @param type The connection type
   */
  public HornetQRAConnectionRequestInfo(final int type) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("constructor(" + type + ")");
    }

    this.type = type;
    transacted = true;
    acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
  }
  /**
   * Constructor
   *
   * @param transacted Use transactions
   * @param acknowledgeMode The acknowledge mode
   * @param type The connection type
   */
  public HornetQRAConnectionRequestInfo(
      final boolean transacted, final int acknowledgeMode, final int type) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace(
          "constructor(" + transacted + ", " + acknowledgeMode + ", " + type + ")");
    }

    this.transacted = transacted;
    this.acknowledgeMode = acknowledgeMode;
    this.type = type;
  }
  /**
   * Constructor
   *
   * @param prop The resource adapter properties
   * @param type The connection type
   */
  public HornetQRAConnectionRequestInfo(final HornetQRAProperties prop, final int type) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("constructor(" + prop + ")");
    }

    userName = prop.getUserName();
    password = prop.getPassword();
    clientID = prop.getClientID();
    this.type = type;
    transacted = true;
    acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
  }
  /**
   * Fill in default values if they are missing
   *
   * @param prop The resource adapter properties
   */
  public void setDefaults(final HornetQRAProperties prop) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("setDefaults(" + prop + ")");
    }

    if (userName == null) {
      userName = prop.getUserName();
    }
    if (password == null) {
      password = prop.getPassword();
    }
    if (clientID == null) {
      clientID = prop.getClientID();
    }
  }
  /**
   * Return the hash code for the object
   *
   * @return The hash code
   */
  @Override
  public int hashCode() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("hashCode()");
    }

    int hash = 7;

    hash += 31 * hash + (userName != null ? userName.hashCode() : 0);
    hash += 31 * hash + (password != null ? password.hashCode() : 0);
    hash += 31 * hash + Integer.valueOf(type).hashCode();
    hash += 31 * hash + (transacted ? 1 : 0);
    hash += 31 * hash + Integer.valueOf(acknowledgeMode).hashCode();

    return hash;
  }
  /**
   * Indicates whether some other object is "equal to" this one.
   *
   * @param obj Object with which to compare
   * @return True if this object is the same as the obj argument; false otherwise.
   */
  @Override
  public boolean equals(final Object obj) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("equals(" + obj + ")");
    }

    if (obj == null) {
      return false;
    }

    if (obj instanceof HornetQRAConnectionRequestInfo) {
      HornetQRAConnectionRequestInfo you = (HornetQRAConnectionRequestInfo) obj;
      return HornetQRaUtils.compare(userName, you.getUserName())
          && HornetQRaUtils.compare(password, you.getPassword())
          && HornetQRaUtils.compare(clientID, you.getClientID())
          && type == you.getType()
          && transacted == you.isTransacted()
          && acknowledgeMode == you.getAcknowledgeMode();
    } else {
      return false;
    }
  }
/**
 * Connection request information
 *
 * @author <a href="mailto:[email protected]">Adrian Brock</a>
 * @author <a href="mailto:[email protected]">Jesper Pedersen</a>
 * @author <a href="mailto:[email protected]">Andy Taylor</a>
 * @version $Revision: $
 */
public class HornetQRAConnectionRequestInfo implements ConnectionRequestInfo {
  /** Trace enabled */
  private static boolean trace = HornetQRALogger.LOGGER.isTraceEnabled();

  /** The user name */
  private String userName;

  /** The password */
  private String password;

  /** The client id */
  private String clientID;

  /** The type */
  private final int type;

  /** Use transactions */
  private final boolean transacted;

  /** The acknowledge mode */
  private final int acknowledgeMode;

  /**
   * Constructor
   *
   * @param prop The resource adapter properties
   * @param type The connection type
   */
  public HornetQRAConnectionRequestInfo(final HornetQRAProperties prop, final int type) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("constructor(" + prop + ")");
    }

    userName = prop.getUserName();
    password = prop.getPassword();
    clientID = prop.getClientID();
    this.type = type;
    transacted = true;
    acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
  }

  /**
   * Constructor
   *
   * @param type The connection type
   */
  public HornetQRAConnectionRequestInfo(final int type) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("constructor(" + type + ")");
    }

    this.type = type;
    transacted = true;
    acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
  }

  /**
   * Constructor
   *
   * @param transacted Use transactions
   * @param acknowledgeMode The acknowledge mode
   * @param type The connection type
   */
  public HornetQRAConnectionRequestInfo(
      final boolean transacted, final int acknowledgeMode, final int type) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace(
          "constructor(" + transacted + ", " + acknowledgeMode + ", " + type + ")");
    }

    this.transacted = transacted;
    this.acknowledgeMode = acknowledgeMode;
    this.type = type;
  }

  /**
   * Fill in default values if they are missing
   *
   * @param prop The resource adapter properties
   */
  public void setDefaults(final HornetQRAProperties prop) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("setDefaults(" + prop + ")");
    }

    if (userName == null) {
      userName = prop.getUserName();
    }
    if (password == null) {
      password = prop.getPassword();
    }
    if (clientID == null) {
      clientID = prop.getClientID();
    }
  }

  /**
   * Get the user name
   *
   * @return The value
   */
  public String getUserName() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("getUserName()");
    }

    return userName;
  }

  /**
   * Set the user name
   *
   * @param userName The value
   */
  public void setUserName(final String userName) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("setUserName(" + userName + ")");
    }

    this.userName = userName;
  }

  /**
   * Get the password
   *
   * @return The value
   */
  public String getPassword() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("getPassword()");
    }

    return password;
  }

  /**
   * Set the password
   *
   * @param password The value
   */
  public void setPassword(final String password) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("setPassword(****)");
    }

    this.password = password;
  }

  /**
   * Get the client id
   *
   * @return The value
   */
  public String getClientID() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("getClientID()");
    }

    return clientID;
  }

  /**
   * Set the client id
   *
   * @param clientID The value
   */
  public void setClientID(final String clientID) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("setClientID(" + clientID + ")");
    }

    this.clientID = clientID;
  }

  /**
   * Get the connection type
   *
   * @return The type
   */
  public int getType() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("getType()");
    }

    return type;
  }

  /**
   * Use transactions
   *
   * @return True if transacted; otherwise false
   */
  public boolean isTransacted() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("isTransacted() " + transacted);
    }

    return transacted;
  }

  /**
   * Get the acknowledge mode
   *
   * @return The mode
   */
  public int getAcknowledgeMode() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("getAcknowledgeMode()");
    }

    return acknowledgeMode;
  }

  /**
   * Indicates whether some other object is "equal to" this one.
   *
   * @param obj Object with which to compare
   * @return True if this object is the same as the obj argument; false otherwise.
   */
  @Override
  public boolean equals(final Object obj) {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("equals(" + obj + ")");
    }

    if (obj == null) {
      return false;
    }

    if (obj instanceof HornetQRAConnectionRequestInfo) {
      HornetQRAConnectionRequestInfo you = (HornetQRAConnectionRequestInfo) obj;
      return HornetQRaUtils.compare(userName, you.getUserName())
          && HornetQRaUtils.compare(password, you.getPassword())
          && HornetQRaUtils.compare(clientID, you.getClientID())
          && type == you.getType()
          && transacted == you.isTransacted()
          && acknowledgeMode == you.getAcknowledgeMode();
    } else {
      return false;
    }
  }

  /**
   * Return the hash code for the object
   *
   * @return The hash code
   */
  @Override
  public int hashCode() {
    if (HornetQRAConnectionRequestInfo.trace) {
      HornetQRALogger.LOGGER.trace("hashCode()");
    }

    int hash = 7;

    hash += 31 * hash + (userName != null ? userName.hashCode() : 0);
    hash += 31 * hash + (password != null ? password.hashCode() : 0);
    hash += 31 * hash + Integer.valueOf(type).hashCode();
    hash += 31 * hash + (transacted ? 1 : 0);
    hash += 31 * hash + Integer.valueOf(acknowledgeMode).hashCode();

    return hash;
  }

  @Override
  public String toString() {
    return "HornetQRAConnectionRequestInfo[type="
        + type
        + ", transacted="
        + transacted
        + ", acknowledgeMode="
        + acknowledgeMode
        + ", clientID="
        + clientID
        + ", userName="******", password="******"]";
  }
}
예제 #24
0
/**
 * HornetQQueueSender.
 *
 * @author <a href="*****@*****.**">Adrian Brock</a>
 * @author <a href="*****@*****.**">Jesper Pedersen</a>
 */
public class HornetQRATopicPublisher extends HornetQRAMessageProducer implements TopicPublisher {
  /** Whether trace is enabled */
  private static boolean trace = HornetQRALogger.LOGGER.isTraceEnabled();

  /**
   * Create a new wrapper
   *
   * @param producer the producer
   * @param session the session
   */
  public HornetQRATopicPublisher(final TopicPublisher producer, final HornetQRASession session) {
    super(producer, session);

    if (HornetQRATopicPublisher.trace) {
      HornetQRALogger.LOGGER.trace("constructor(" + producer + ", " + session + ")");
    }
  }

  /**
   * Get the topic
   *
   * @return The topic
   * @exception JMSException Thrown if an error occurs
   */
  public Topic getTopic() throws JMSException {
    if (HornetQRATopicPublisher.trace) {
      HornetQRALogger.LOGGER.trace("getTopic()");
    }

    return ((TopicPublisher) producer).getTopic();
  }

  /**
   * Publish message
   *
   * @param message The message
   * @param deliveryMode The delivery mode
   * @param priority The priority
   * @param timeToLive The time to live
   * @exception JMSException Thrown if an error occurs
   */
  public void publish(
      final Message message, final int deliveryMode, final int priority, final long timeToLive)
      throws JMSException {
    session.lock();
    try {
      if (HornetQRATopicPublisher.trace) {
        HornetQRALogger.LOGGER.trace(
            "send "
                + this
                + " message="
                + message
                + " deliveryMode="
                + deliveryMode
                + " priority="
                + priority
                + " ttl="
                + timeToLive);
      }

      checkState();

      ((TopicPublisher) producer).publish(message, deliveryMode, priority, timeToLive);

      if (HornetQRATopicPublisher.trace) {
        HornetQRALogger.LOGGER.trace("sent " + this + " result=" + message);
      }
    } finally {
      session.unlock();
    }
  }

  /**
   * Publish message
   *
   * @param message The message
   * @exception JMSException Thrown if an error occurs
   */
  public void publish(final Message message) throws JMSException {
    session.lock();
    try {
      if (HornetQRATopicPublisher.trace) {
        HornetQRALogger.LOGGER.trace("send " + this + " message=" + message);
      }

      checkState();

      ((TopicPublisher) producer).publish(message);

      if (HornetQRATopicPublisher.trace) {
        HornetQRALogger.LOGGER.trace("sent " + this + " result=" + message);
      }
    } finally {
      session.unlock();
    }
  }

  /**
   * Publish message
   *
   * @param destination The destination
   * @param message The message
   * @param deliveryMode The delivery mode
   * @param priority The priority
   * @param timeToLive The time to live
   * @exception JMSException Thrown if an error occurs
   */
  public void publish(
      final Topic destination,
      final Message message,
      final int deliveryMode,
      final int priority,
      final long timeToLive)
      throws JMSException {
    session.lock();
    try {
      if (HornetQRATopicPublisher.trace) {
        HornetQRALogger.LOGGER.trace(
            "send "
                + this
                + " destination="
                + destination
                + " message="
                + message
                + " deliveryMode="
                + deliveryMode
                + " priority="
                + priority
                + " ttl="
                + timeToLive);
      }

      checkState();

      ((TopicPublisher) producer).publish(destination, message, deliveryMode, priority, timeToLive);

      if (HornetQRATopicPublisher.trace) {
        HornetQRALogger.LOGGER.trace("sent " + this + " result=" + message);
      }
    } finally {
      session.unlock();
    }
  }

  /**
   * Publish message
   *
   * @param destination The destination
   * @param message The message
   * @exception JMSException Thrown if an error occurs
   */
  public void publish(final Topic destination, final Message message) throws JMSException {
    session.lock();
    try {
      if (HornetQRATopicPublisher.trace) {
        HornetQRALogger.LOGGER.trace(
            "send " + this + " destination=" + destination + " message=" + message);
      }

      checkState();

      ((TopicPublisher) producer).publish(destination, message);

      if (HornetQRATopicPublisher.trace) {
        HornetQRALogger.LOGGER.trace("sent " + this + " result=" + message);
      }
    } finally {
      session.unlock();
    }
  }
}