protected IncomingMessage message(final boolean immediate, long size) throws AMQException { MessagePublishInfo publish = new MessagePublishInfo() { public AMQShortString getExchange() { return null; } public void setExchange(AMQShortString exchange) { // To change body of implemented methods use File | Settings | File Templates. } public boolean isImmediate() { return immediate; } public boolean isMandatory() { return false; } public AMQShortString getRoutingKey() { return null; } }; ContentHeaderBody contentHeaderBody = new ContentHeaderBody(); BasicContentHeaderProperties props = new BasicContentHeaderProperties(); contentHeaderBody.setProperties(props); contentHeaderBody.bodySize = size; // in bytes IncomingMessage message = new IncomingMessage(publish); message.setContentHeaderBody(contentHeaderBody); return message; }