Class AMQPMessageIdHelper
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
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final AMQPMessageIdHelper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvertBinaryToHexString(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.byte[]convertHexStringToBinary(String hexString) Convert the provided hex-string into a binary representation where each byte represents two characters of the hex string.toBaseMessageIdString(Object messageId) Takes the provided AMQP messageId style object, and convert it to a base string.toIdObject(String baseId) Takes the provided base id string and return the appropriate amqp messageId style object.
-
Field Details
-
INSTANCE
-
AMQP_STRING_PREFIX
- See Also:
-
AMQP_UUID_PREFIX
- See Also:
-
AMQP_ULONG_PREFIX
- See Also:
-
AMQP_BINARY_PREFIX
- See Also:
-
-
Constructor Details
-
AMQPMessageIdHelper
public AMQPMessageIdHelper()
-
-
Method Details
-
toBaseMessageIdString
Takes the provided AMQP messageId style object, and convert it to a base string. Encodes type information as a prefix where necessary to convey or escape the type of the provided object.- Parameters:
messageId- the raw messageId object to process- Returns:
- the base string to be used in creating the actual id.
-
toIdObject
Takes the provided base id string and return the appropriate amqp messageId style object. Converts the type based on any relevant encoding information found as a prefix.- Parameters:
baseId- the object to be converted to an AMQP MessageId value.- Returns:
- the AMQP messageId style object
- Throws:
AmqpProtocolException- if the provided baseId String indicates an encoded type but can't be converted to that type.
-
convertHexStringToBinary
Convert 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 to a binary value.- Returns:
- a byte array containing the binary representation
- Throws:
IllegalArgumentException- if the provided String is a non-even length or contains non-hex characters
-
convertBinaryToHexString
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- the binary value to convert to a hex String instance.- Returns:
- a String containing a hex representation of the bytes
-