protected JBossMessage(final Message foreign, final byte type, final ClientSession session)
      throws JMSException {
    this(type, session);

    setJMSTimestamp(foreign.getJMSTimestamp());

    try {
      byte[] corrIDBytes = foreign.getJMSCorrelationIDAsBytes();
      setJMSCorrelationIDAsBytes(corrIDBytes);
    } catch (JMSException e) {
      // specified as String
      String corrIDString = foreign.getJMSCorrelationID();
      if (corrIDString != null) {
        setJMSCorrelationID(corrIDString);
      }
    }

    setJMSReplyTo(foreign.getJMSReplyTo());
    setJMSDestination(foreign.getJMSDestination());
    setJMSDeliveryMode(foreign.getJMSDeliveryMode());
    setJMSExpiration(foreign.getJMSExpiration());
    setJMSPriority(foreign.getJMSPriority());
    setJMSType(foreign.getJMSType());

    // We can't avoid a cast warning here since getPropertyNames() is on the JMS API
    for (Enumeration<String> props = foreign.getPropertyNames(); props.hasMoreElements(); ) {
      String name = (String) props.nextElement();

      Object prop = foreign.getObjectProperty(name);

      this.setObjectProperty(name, prop);
    }
  }
  /**
   * Get correlation id
   *
   * @return The value
   * @throws JMSException Thrown if an error occurs
   */
  @Override
  public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
    if (ActiveMQRAMessage.trace) {
      ActiveMQRALogger.LOGGER.trace("getJMSCorrelationIDAsBytes()");
    }

    return message.getJMSCorrelationIDAsBytes();
  }
  protected HornetQMessage(final Message foreign, final byte type, final ClientSession session)
      throws JMSException {
    this(type, session);

    setJMSTimestamp(foreign.getJMSTimestamp());

    String value =
        System.getProperty(
            HornetQJMSConstants.JMS_HORNETQ_ENABLE_BYTE_ARRAY_JMS_CORRELATION_ID_PROPERTY_NAME);

    boolean supportBytesId = !"false".equals(value);

    if (supportBytesId) {
      try {
        byte[] corrIDBytes = foreign.getJMSCorrelationIDAsBytes();
        setJMSCorrelationIDAsBytes(corrIDBytes);
      } catch (JMSException e) {
        // specified as String
        String corrIDString = foreign.getJMSCorrelationID();
        if (corrIDString != null) {
          setJMSCorrelationID(corrIDString);
        }
      }
    } else {
      // Some providers, like WSMQ do automatic conversions between native byte[] correlation id
      // and String correlation id. This makes it impossible for HQ to guarantee to return the
      // correct
      // type as set by the user
      // So we allow the behaviour to be overridden by a system property
      // https://jira.jboss.org/jira/browse/HORNETQ-356
      // https://jira.jboss.org/jira/browse/HORNETQ-332
      String corrIDString = foreign.getJMSCorrelationID();
      if (corrIDString != null) {
        setJMSCorrelationID(corrIDString);
      }
    }

    setJMSReplyTo(foreign.getJMSReplyTo());
    setJMSDestination(foreign.getJMSDestination());
    setJMSDeliveryMode(foreign.getJMSDeliveryMode());
    setJMSExpiration(foreign.getJMSExpiration());
    setJMSPriority(foreign.getJMSPriority());
    setJMSType(foreign.getJMSType());

    // We can't avoid a cast warning here since getPropertyNames() is on the JMS API
    for (Enumeration<String> props = foreign.getPropertyNames(); props.hasMoreElements(); ) {
      String name = props.nextElement();

      Object prop = foreign.getObjectProperty(name);

      setObjectProperty(name, prop);
    }
  }
Beispiel #4
0
 private static Map<String, Object> headers(final javax.jms.Message message) throws JMSException {
   final Map<String, Object> result = new HashMap<>();
   putHeadedIfPresent(result, CorrelationID, message.getJMSCorrelationID());
   putHeadedIfPresent(result, CorrelationIDAsBytes, message.getJMSCorrelationIDAsBytes());
   putHeadedIfPresent(result, DeliveryMode, message.getJMSDeliveryMode());
   putHeadedIfPresent(result, Destination, message.getJMSDestination());
   putHeadedIfPresent(result, Expiration, message.getJMSExpiration());
   putHeadedIfPresent(result, MessageID, message.getJMSMessageID());
   putHeadedIfPresent(result, Priority, message.getJMSPriority());
   putHeadedIfPresent(result, Redelivered, message.getJMSRedelivered());
   putHeadedIfPresent(result, ReplyTo, message.getJMSReplyTo());
   putHeadedIfPresent(result, Timestamp, message.getJMSTimestamp());
   putHeadedIfPresent(result, Type, message.getJMSType());
   return result;
 }