Class AmqpMessageIdHelper
- java.lang.Object
-
- org.apache.qpid.jms.provider.amqp.message.AmqpMessageIdHelper
-
public class AmqpMessageIdHelper extends java.lang.ObjectHelper class for identifying and converting message-id and correlation-id values between the AMQP types and the Strings values used by JMS.AMQP messages allow for 4 types of message-id/correlation-id: message-id-string, message-id-binary, message-id-uuid, or message-id-ulong. In order to accept or return a string representation of these for interoperability with other AMQP clients, the following encoding can be used after removing or before adding the "ID:" prefix used for a JMSMessageID value:
"AMQP_BINARY:<hex representation of binary content>"
"AMQP_UUID:<string representation of uuid>"
"AMQP_ULONG:<string representation of ulong>"
"AMQP_STRING:<string>"
The AMQP_STRING encoding exists only for escaping message-id-string values that happen to begin with one of the encoding prefixes (including AMQP_STRING itself). It MUST NOT be used otherwise.
When provided a string for conversion which attempts to identify itself as an encoded binary, uuid, or ulong but can't be converted into the indicated format, an exception will be thrown.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAMQP_BINARY_PREFIXstatic java.lang.StringAMQP_NO_PREFIXstatic java.lang.StringAMQP_STRING_PREFIXstatic java.lang.StringAMQP_ULONG_PREFIXstatic java.lang.StringAMQP_UUID_PREFIXstatic java.lang.StringJMS_ID_PREFIX
-
Constructor Summary
Constructors Constructor Description AmqpMessageIdHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringconvertBinaryToHexString(byte[] bytes)Convert the provided binary into a hex-string representation where each character represents 4 bits of the provided binary, i.e each byte requires two characters.static byte[]convertHexStringToBinary(java.lang.String hexString)Convert the provided hex-string into a binary representation where each byte represents two characters of the hex string.static booleanhasMessageIdPrefix(java.lang.String string)Checks whether the given string begins with "ID:" prefix used to denote a JMSMessageIDstatic java.lang.StringtoCorrelationIdString(java.lang.Object idObject)static java.lang.ObjecttoIdObject(java.lang.String origId)Takes the provided id string and return the appropriate amqp messageId style object.static java.lang.StringtoMessageIdString(java.lang.Object idObject)
-
-
-
Field Detail
-
AMQP_STRING_PREFIX
public static final java.lang.String AMQP_STRING_PREFIX
- See Also:
- Constant Field Values
-
AMQP_UUID_PREFIX
public static final java.lang.String AMQP_UUID_PREFIX
- See Also:
- Constant Field Values
-
AMQP_ULONG_PREFIX
public static final java.lang.String AMQP_ULONG_PREFIX
- See Also:
- Constant Field Values
-
AMQP_BINARY_PREFIX
public static final java.lang.String AMQP_BINARY_PREFIX
- See Also:
- Constant Field Values
-
AMQP_NO_PREFIX
public static final java.lang.String AMQP_NO_PREFIX
- See Also:
- Constant Field Values
-
JMS_ID_PREFIX
public static final java.lang.String JMS_ID_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
hasMessageIdPrefix
public static boolean hasMessageIdPrefix(java.lang.String string)
Checks whether the given string begins with "ID:" prefix used to denote a JMSMessageID- Parameters:
string- the string to check- Returns:
- true if and only id the string begins with "ID:"
-
toMessageIdString
public static java.lang.String toMessageIdString(java.lang.Object idObject)
-
toCorrelationIdString
public static java.lang.String toCorrelationIdString(java.lang.Object idObject)
-
toIdObject
public static java.lang.Object toIdObject(java.lang.String origId) throws IdConversionExceptionTakes the provided id string and return the appropriate amqp messageId style object. Converts the type based on any relevant encoding information found as a prefix.- Parameters:
origId- the object to be converted- Returns:
- the amqp messageId style object
- Throws:
IdConversionException- if the provided baseId String indicates an encoded type but can't be converted to that type.
-
convertHexStringToBinary
public static byte[] convertHexStringToBinary(java.lang.String hexString) throws java.lang.IllegalArgumentExceptionConvert the provided hex-string into a binary representation where each byte represents two characters of the hex string. The hex characters may be upper or lower case.- Parameters:
hexString- string to convert- Returns:
- a byte array containing the binary representation
- Throws:
java.lang.IllegalArgumentException- if the provided String is a non-even length or contains non-hex characters
-
convertBinaryToHexString
public static java.lang.String convertBinaryToHexString(byte[] bytes)
Convert the provided binary into a hex-string representation where each character represents 4 bits of the provided binary, i.e each byte requires two characters. The returned hex characters are upper-case.- Parameters:
bytes- binary to convert- Returns:
- a String containing a hex representation of the bytes
-
-