@Override public void handleDelivery(String s, com.rabbitmq.client.Envelope envelope, AMQP.BasicProperties basicProperties, byte[] bytes) throws IOException { try { Map<String, Object> headers = basicProperties.getHeaders(); if (headers == null || !headers.containsKey(CloudBus.HEADER_MESSAGE_META_DATA)) { return; } LongString metaData = (LongString) headers.get(CloudBus.HEADER_MESSAGE_META_DATA); Map m = JSONObjectUtil.toObject(new String(metaData.getBytes()), LinkedHashMap.class); trackMessage((MessageMetaData) JSONObjectUtil.rehashObject(m, metaDataClassCache.get(m.get("className")))); } catch (Throwable t) { logger.warn("unhandled throwable", t); } }
/** * Converts a LongString value to either a String or DataInputStream based on a * length-driven threshold. If the length is {@link #longStringLimit} bytes or less, a * String will be returned, otherwise a DataInputStream is returned or the {@link LongString} * is returned unconverted if {@link #convertLongLongStrings} is true. * @param longString the long string. * @param charset the charset. * @return the converted string. */ private Object convertLongString(LongString longString, String charset) { try { if (longString.length() <= this.longStringLimit) { return new String(longString.getBytes(), charset); } else { return this.convertLongLongStrings ? longString.getStream() : longString; } } catch (Exception e) { throw RabbitExceptionTranslator.convertRabbitAccessException(e); } }
LongString returnCorrelation = (LongString) properties.getHeaders().get(RETURNED_MESSAGE_CORRELATION_KEY); if (returnCorrelation != null) { PendingConfirm confirm = this.pendingReturns.remove(returnCorrelation.toString()); if (confirm != null) { MessageProperties messageProperties = converter.toMessageProperties(properties,
/** * Converts a LongString value to either a String or DataInputStream based on a * length-driven threshold. If the length is {@link #longStringLimit} bytes or less, a * String will be returned, otherwise a DataInputStream is returned or the {@link LongString} * is returned unconverted if {@link #convertLongLongStrings} is true. * @param longString the long string. * @param charset the charset. * @return the converted string. */ private Object convertLongString(LongString longString, String charset) { try { if (longString.length() <= this.longStringLimit) { return new String(longString.getBytes(), charset); } else { return this.convertLongLongStrings ? longString.getStream() : longString; } } catch (Exception e) { throw RabbitExceptionTranslator.convertRabbitAccessException(e); } }
LongString returnCorrelation = (LongString) properties.getHeaders().get(RETURNED_MESSAGE_CORRELATION_KEY); if (returnCorrelation != null) { PendingConfirm confirm = this.pendingReturns.remove(returnCorrelation.toString()); if (confirm != null) { MessageProperties messageProperties = converter.toMessageProperties(properties,
@Before public void init() throws UnsupportedEncodingException { longStringString = new String(longString.getBytes(), "UTF-8"); }
assertEquals(longString1026.toString(), basicProperties.getHeaders().get("string1026").toString());