public static void setList(final Message message, final List list) throws JMSException
{
String type = getContentType(message);
if (!type.equals("amqp/list"))
{
throw new MessageFormatException("Can only do setList() on amqp/list encoded Message");
}
if (message == null)
{
throw new MessageFormatException("Attempting to do AMQPMessage.setList() on null Message");
}
else if (message instanceof BytesMessage)
{
BBEncoder encoder = new BBEncoder(1024);
encoder.writeList(list);
ByteBuffer buf = encoder.segment();
byte[] data = new byte[buf.limit()];
buf.get(data);
((BytesMessage)message).writeBytes(data);
}
else
{
throw new MessageFormatException("Attempting to do setList() on " + message.getClass().getCanonicalName());
}
}