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 2626public class PerMessageTTL extends TTLHandling {
2727
2828 protected Object sessionTTL ;
29+ private volatile String retrievedMsg = null ;
2930
3031 @ Override
3132 protected void publish (String msg ) throws IOException {
@@ -58,4 +59,33 @@ public void testExpiryWhenConsumerIsLateToTheParty() throws Exception {
5859 assertNull ("Message should have been expired!!" , c .nextDelivery (100 ));
5960 }
6061
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+
6191}
You can’t perform that action at this time.
0 commit comments