public Producer createProducer(Connection connection, Stats stats, String id) throws IOException {
Channel channel = connection.createChannel();
if (producerTxSize > 0) channel.txSelect();
if (confirm >= 0) channel.confirmSelect();
if (!predeclared || !exchangeExists(connection, exchangeName)) {
channel.exchangeDeclare(exchangeName, exchangeType);
}
final Producer producer = new Producer(channel, exchangeName, id,
randomRoutingKey, flags, producerTxSize,
producerRateLimit, producerMsgCount,
minMsgSize, timeLimit,