File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
test/src/com/rabbitmq/client/test/functional Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 26
26
public class PerMessageTTL extends TTLHandling {
27
27
28
28
protected Object sessionTTL ;
29
+ private volatile String retrievedMsg = null ;
29
30
30
31
@ Override
31
32
protected void publish (String msg ) throws IOException {
@@ -58,4 +59,33 @@ public void testExpiryWhenConsumerIsLateToTheParty() throws Exception {
58
59
assertNull ("Message should have been expired!!" , c .nextDelivery (100 ));
59
60
}
60
61
62
+ public void testRestartingExpiry () throws Exception {
63
+ final String restartDelay = "3000" ;
64
+ declareDurableQueue (TTL_QUEUE_NAME );
65
+ bindQueue ();
66
+ channel .basicPublish (TTL_EXCHANGE , TTL_QUEUE_NAME ,
67
+ MessageProperties .MINIMAL_PERSISTENT_BASIC
68
+ .builder ()
69
+ .expiration (restartDelay )
70
+ .build (), new byte []{});
71
+
72
+ Thread delayedConsume =
73
+ new Thread (new Runnable () {
74
+ @ Override
75
+ public void run () {
76
+ try {
77
+ Thread .sleep (Integer .parseInt (restartDelay ));
78
+ retrievedMsg = get ();
79
+ } catch (IOException e ) {
80
+ } catch (InterruptedException e ) {
81
+ }
82
+
83
+ }
84
+ });
85
+ delayedConsume .start ();
86
+ restart ();
87
+ delayedConsume .join ();
88
+ assertNull ("Message should have expired after broker restart" , retrievedMsg );
89
+ }
90
+
61
91
}
You can’t perform that action at this time.
0 commit comments