|
22 | 22 | import java.util.Map;
|
23 | 23 |
|
24 | 24 | import com.rabbitmq.client.AMQP;
|
| 25 | +import com.rabbitmq.client.Consumer; |
| 26 | +import com.rabbitmq.client.DefaultConsumer; |
25 | 27 | import com.rabbitmq.client.test.BrokerTestCase;
|
26 | 28 |
|
27 | 29 | public class QueueLease extends BrokerTestCase {
|
@@ -178,6 +180,33 @@ public void testPassiveQueueDeclareExtendsLease()
|
178 | 180 | }
|
179 | 181 | }
|
180 | 182 |
|
| 183 | + public void testExpiresWithConsumers() |
| 184 | + throws InterruptedException, IOException { |
| 185 | + Map<String, Object> args = new HashMap<String, Object>(); |
| 186 | + args.put("x-expires", QUEUE_EXPIRES); |
| 187 | + channel.queueDeclare(TEST_EXPIRE_QUEUE, false, false, false, args); |
| 188 | + |
| 189 | + Consumer consumer = new DefaultConsumer(channel); |
| 190 | + String consumerTag = channel.basicConsume(TEST_EXPIRE_QUEUE, consumer); |
| 191 | + |
| 192 | + Thread.sleep(SHOULD_EXPIRE_WITHIN); |
| 193 | + try { |
| 194 | + channel.queueDeclarePassive(TEST_EXPIRE_QUEUE); |
| 195 | + } catch (IOException e) { |
| 196 | + checkShutdownSignal(AMQP.NOT_FOUND, e); |
| 197 | + fail("Queue expired before before passive re-declaration."); |
| 198 | + } |
| 199 | + |
| 200 | + channel.basicCancel(consumerTag); |
| 201 | + Thread.sleep(SHOULD_EXPIRE_WITHIN); |
| 202 | + try { |
| 203 | + channel.queueDeclarePassive(TEST_EXPIRE_QUEUE); |
| 204 | + fail("Queue should have been expired by now."); |
| 205 | + } catch (IOException e) { |
| 206 | + checkShutdownSignal(AMQP.NOT_FOUND, e); |
| 207 | + } |
| 208 | + } |
| 209 | + |
181 | 210 | void verifyQueueExpires(String name, boolean expire) throws IOException,
|
182 | 211 | InterruptedException {
|
183 | 212 | Map<String, Object> args = new HashMap<String, Object>();
|
|
0 commit comments