@@ -65,17 +65,17 @@ protected void releaseResources() throws IOException {
65
65
channel .queueDelete (Q );
66
66
}
67
67
68
- protected void setMemoryAlarm ( ) throws IOException , InterruptedException {
69
- Host .executeCommand ("cd ../rabbitmq-test; make set-memory -alarm" );
68
+ protected void setResourceAlarm ( String source ) throws IOException , InterruptedException {
69
+ Host .executeCommand ("cd ../rabbitmq-test; make set-resource -alarm SOURCE=" + source );
70
70
}
71
71
72
- protected void clearMemoryAlarm ( ) throws IOException , InterruptedException {
73
- Host .executeCommand ("cd ../rabbitmq-test; make clear-memory -alarm" );
72
+ protected void clearResourceAlarm ( String source ) throws IOException , InterruptedException {
73
+ Host .executeCommand ("cd ../rabbitmq-test; make clear-resource -alarm SOURCE=" + source );
74
74
}
75
75
76
76
public void testFlowControl () throws IOException , InterruptedException {
77
77
basicPublishVolatile (Q );
78
- setMemoryAlarm ( );
78
+ setResourceAlarm ( "memory" );
79
79
// non-publish actions only after an alarm should be fine
80
80
assertNotNull (basicGet (Q ));
81
81
QueueingConsumer c = new QueueingConsumer (channel );
@@ -86,12 +86,34 @@ public void testFlowControl() throws IOException, InterruptedException {
86
86
// by heartbeat (3x heartbeat interval + epsilon)
87
87
assertNull (c .nextDelivery (3100 ));
88
88
// once the alarm has cleared the publishes should go through
89
- clearMemoryAlarm ( );
89
+ clearResourceAlarm ( "memory" );
90
90
assertNotNull (c .nextDelivery ());
91
91
// everything should be back to normal
92
92
channel .basicCancel (consumerTag );
93
93
basicPublishVolatile (Q );
94
94
assertNotNull (basicGet (Q ));
95
95
}
96
96
97
+
98
+ public void testOverlappingAlarmsFlowControl () throws IOException , InterruptedException {
99
+ QueueingConsumer c = new QueueingConsumer (channel );
100
+ String consumerTag = channel .basicConsume (Q , true , c );
101
+
102
+ setResourceAlarm ("memory" );
103
+ basicPublishVolatile (Q );
104
+
105
+ assertNull (c .nextDelivery (100 ));
106
+ setResourceAlarm ("disk" );
107
+ assertNull (c .nextDelivery (100 ));
108
+ clearResourceAlarm ("memory" );
109
+ assertNull (c .nextDelivery (100 ));
110
+ clearResourceAlarm ("disk" );
111
+ assertNotNull (c .nextDelivery ());
112
+
113
+ channel .basicCancel (consumerTag );
114
+ basicPublishVolatile (Q );
115
+ assertNotNull (basicGet (Q ));
116
+ }
117
+
118
+
97
119
}
0 commit comments