4040import com .rabbitmq .client .Connection ;
4141import com .rabbitmq .client .ConnectionFactory ;
4242import com .rabbitmq .client .MessageProperties ;
43+ import com .rabbitmq .client .AMQP .BasicProperties ;
4344
4445public class ProducerMain implements Runnable {
4546 public static final int SUMMARY_EVERY_MS = 1000 ;
@@ -191,6 +192,9 @@ public void sendBatch(String queueName) throws IOException {
191192
192193 long nextSummaryTime = startTime + SUMMARY_EVERY_MS ;
193194 byte [] message = new byte [256 ];
195+ BasicProperties props = shouldPersist () ?
196+ MessageProperties .MINIMAL_PERSISTENT_BASIC :
197+ MessageProperties .MINIMAL_BASIC ;
194198 for (int i = 0 ; i < _messageCount ; i ++) {
195199 ByteArrayOutputStream acc = new ByteArrayOutputStream ();
196200 DataOutputStream d = new DataOutputStream (acc );
@@ -205,8 +209,7 @@ public void sendBatch(String queueName) throws IOException {
205209 acc .flush ();
206210 byte [] message0 = acc .toByteArray ();
207211 System .arraycopy (message0 , 0 , message , 0 , message0 .length );
208- _channel .basicPublish ("" , queueName , shouldPersist () ? MessageProperties .MINIMAL_PERSISTENT_BASIC : MessageProperties .MINIMAL_BASIC ,
209- message );
212+ _channel .basicPublish ("" , queueName , props , message );
210213 sent ++;
211214 if (shouldCommit ()) {
212215 if ((sent % _commitEvery ) == 0 ) {
0 commit comments