@@ -136,6 +136,46 @@ public void testRetryTopic() throws Exception {
136
136
checkConsumer .close ();
137
137
}
138
138
139
+ /**
140
+ * Retry topic feature relies on the delay queue feature when consumer produce a delayed message
141
+ * to the retry topic. The delay queue feature is only supported in shared and key-shared subscription type.
142
+ * As a result, the subscription type of the retry topic should be shared or key-shared.
143
+ * @throws Exception
144
+ */
145
+ @ Test
146
+ public void testRetryTopicWithExclusiveMode () throws Exception {
147
+ final String topic = "persistent://my-property/my-ns/retry-topic-exclusive" ;
148
+ final int maxRedeliveryCount = 2 ;
149
+
150
+ Consumer <byte []> consumer = pulsarClient .newConsumer (Schema .BYTES )
151
+ .topic (topic )
152
+ .subscriptionName ("my-subscription" )
153
+ .subscriptionType (SubscriptionType .Exclusive )
154
+ .enableRetry (true )
155
+ .deadLetterPolicy (DeadLetterPolicy .builder ().maxRedeliverCount (maxRedeliveryCount ).build ())
156
+ .receiverQueueSize (100 )
157
+ .subscriptionInitialPosition (SubscriptionInitialPosition .Earliest )
158
+ .subscribe ();
159
+
160
+ Producer <byte []> producer = pulsarClient .newProducer (Schema .BYTES )
161
+ .topic (topic )
162
+ .create ();
163
+
164
+ producer .send ("Hello Pulsar" .getBytes ());
165
+ producer .close ();
166
+
167
+ // receive message and set delay to 5 seconds
168
+ Message <byte []> message = consumer .receive ();
169
+ long timestamp = System .currentTimeMillis ();
170
+ consumer .reconsumeLater (message , 4 , TimeUnit .SECONDS );
171
+
172
+ // receive message and check the delay is at least 4 seconds
173
+ consumer .receive ();
174
+ long delay = System .currentTimeMillis () - timestamp ;
175
+ assertTrue (delay >= 2000 );
176
+ consumer .close ();
177
+ }
178
+
139
179
@ Data
140
180
public static class Foo {
141
181
@ Nullable
0 commit comments