public class AmqpMessageIdHelper extends Object
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.
Modifier and Type | Field and Description |
---|---|
static String |
AMQP_BINARY_PREFIX |
static String |
AMQP_STRING_PREFIX |
static String |
AMQP_ULONG_PREFIX |
static String |
AMQP_UUID_PREFIX |
static AmqpMessageIdHelper |
INSTANCE |
static String |
JMS_ID_PREFIX |
Constructor and Description |
---|
AmqpMessageIdHelper() |
Modifier and Type | Method and Description |
---|---|
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.
|
byte[] |
convertHexStringToBinary(String hexString)
Convert the provided hex-string into a binary representation where each byte represents
two characters of the hex string.
|
boolean |
hasMessageIdPrefix(String string)
Checks whether the given string begins with "ID:" prefix used to denote a JMSMessageID
|
String |
stripMessageIdPrefix(String id)
Returns the suffix of the given string after removing the first "ID:" prefix (if present).
|
String |
toBaseMessageIdString(Object messageId)
Takes the provided amqp messageId style object, and convert it to a base string.
|
Object |
toIdObject(String baseId)
Takes the provided base id string and return the appropriate amqp messageId style object.
|
public static final AmqpMessageIdHelper INSTANCE
public static final String AMQP_STRING_PREFIX
public static final String AMQP_UUID_PREFIX
public static final String AMQP_ULONG_PREFIX
public static final String AMQP_BINARY_PREFIX
public static final String JMS_ID_PREFIX
public boolean hasMessageIdPrefix(String string)
string
- the string to checkpublic String stripMessageIdPrefix(String id)
id
- the string to processpublic String toBaseMessageIdString(Object messageId)
messageId
- the object to processpublic Object toIdObject(String baseId) throws IdConversionException
baseId
- the object to be convertedIdConversionException
- if the provided baseId String indicates an encoded type but can't be converted to that type.public byte[] convertHexStringToBinary(String hexString) throws IllegalArgumentException
hexString
- string to convertIllegalArgumentException
- if the provided String is a non-even length or contains non-hex characterspublic String convertBinaryToHexString(byte[] bytes)
bytes
- binary to convertCopyright © 2013–2016 The Apache Software Foundation. All rights reserved.