@@ -142,7 +142,8 @@ public int getMinMsgSize() {
142142 return minMsgSize ;
143143 }
144144
145- public Producer createProducer (Connection connection , Channel channel , Stats stats , String id ) throws IOException {
145+ public Producer createProducer (Connection connection , Stats stats , String id ) throws IOException {
146+ Channel channel = connection .createChannel ();
146147 if (producerTxSize > 0 ) channel .txSelect ();
147148 if (confirm >= 0 ) channel .confirmSelect ();
148149 if (!exchangeExists (connection , exchangeName )) {
@@ -158,9 +159,10 @@ public Producer createProducer(Connection connection, Channel channel, Stats sta
158159 return producer ;
159160 }
160161
161- public Consumer createConsumer (Connection connection , Channel channel , Stats stats , String id ) throws IOException {
162+ public Consumer createConsumer (Connection connection , Stats stats , String id ) throws IOException {
163+ Channel channel = connection .createChannel ();
162164 if (consumerTxSize > 0 ) channel .txSelect ();
163- String qName = configureQueue (connection , channel , id );
165+ String qName = configureQueue (connection , id );
164166 if (prefetchCount > 0 ) channel .basicQos (prefetchCount );
165167 return new Consumer (channel , id , qName ,
166168 consumerTxSize , autoAck , multiAckEvery ,
@@ -171,7 +173,8 @@ public boolean shouldConfigureQueue() {
171173 return consumerCount == 0 && !queueName .equals ("" );
172174 }
173175
174- public String configureQueue (Connection connection , Channel channel , String id ) throws IOException {
176+ public String configureQueue (Connection connection , String id ) throws IOException {
177+ Channel channel = connection .createChannel ();
175178 if (!exchangeExists (connection , exchangeName )) {
176179 channel .exchangeDeclare (exchangeName , exchangeType );
177180 }
@@ -183,6 +186,7 @@ public String configureQueue(Connection connection, Channel channel, String id)
183186 null ).getQueue ();
184187 }
185188 channel .queueBind (qName , exchangeName , id );
189+ channel .close ();
186190 return qName ;
187191 }
188192
0 commit comments