Search in sources :

Example 1 with LongString

use of com.rabbitmq.client.LongString in project rabbitmq-java-client by rabbitmq.

the class LongStringTest method testToString.

@Test
public void testToString() throws UnsupportedEncodingException {
    String s = "abcdef";
    LongString ls = LongStringHelper.asLongString(s);
    assertTrue(ls.toString().equals(s));
    assertTrue(ls.toString().equals(new String(ls.getBytes(), "UTF-8")));
}
Also used : LongString(com.rabbitmq.client.LongString) LongString(com.rabbitmq.client.LongString) Test(org.junit.Test)

Example 2 with LongString

use of com.rabbitmq.client.LongString in project wso2-axis2-transports by wso2.

the class RabbitMQUtils method getTransportHeaders.

public static Map getTransportHeaders(RabbitMQMessage message) {
    Map<String, String> map = new HashMap<String, String>();
    // correlation ID
    if (message.getCorrelationId() != null) {
        map.put(RabbitMQConstants.CORRELATION_ID, message.getCorrelationId());
    }
    // if a AMQP message ID is found
    if (message.getMessageId() != null) {
        map.put(RabbitMQConstants.MESSAGE_ID, message.getMessageId());
    }
    // replyto destination name
    if (message.getReplyTo() != null) {
        String dest = message.getReplyTo();
        map.put(RabbitMQConstants.RABBITMQ_REPLY_TO, dest);
    }
    // any other transport properties / headers
    Map<String, Object> headers = message.getHeaders();
    if (headers != null && !headers.isEmpty()) {
        for (String headerName : headers.keySet()) {
            String value = new String(((LongString) (headers.get(headerName))).getBytes());
            map.put(headerName, value);
        }
    }
    return map;
}
Also used : HashMap(java.util.HashMap) LongString(com.rabbitmq.client.LongString)

Aggregations

LongString (com.rabbitmq.client.LongString)2 HashMap (java.util.HashMap)1 Test (org.junit.Test)1