private IncomingMessage message(final boolean immediate, boolean persistent) throws AMQException {
    MessagePublishInfo publish =
        new MessagePublishInfo() {

          public AMQShortString getExchange() {
            return null;
          }

          public void setExchange(AMQShortString exchange) {
            throw new NotImplementedException();
          }

          public void setRoutingKey(AMQShortString routingKey) {
            throw new NotImplementedException();
          }

          public boolean isImmediate() {
            return immediate;
          }

          public boolean isMandatory() {
            return false;
          }

          public AMQShortString getRoutingKey() {
            return null;
          }
        };

    ContentHeaderBody contentHeaderBody = new ContentHeaderBody();
    contentHeaderBody.bodySize = MESSAGE_SIZE; // in bytes
    contentHeaderBody.setProperties(new BasicContentHeaderProperties());
    ((BasicContentHeaderProperties) contentHeaderBody.getProperties())
        .setDeliveryMode((byte) (persistent ? 2 : 1));
    IncomingMessage msg = new IncomingMessage(publish);
    msg.setContentHeaderBody(contentHeaderBody);
    return msg;
  }