Commit 4deb40c
committed
GH-2941: Fix BlockingQueueConsumer race condition on cancel
Fixes: #2941
Issue link: #2941
Now `BlockingQueueConsumer.basicCancel()` performs `RabbitUtils.closeMessageConsumer()`
to initiate `basicRecovery` on the transactional consumer to re-queue all the un-acked messages.
However, there is a race condition when one in-flight message may still be delivered
to the listener and then TX commit is initiated.
There a `basicAck()` is initiated.
However, such a tag might already be discarded because of the previous `basicRecovery`.
Therefore, adjust `BlockingQueueConsumer.commitIfNecessary()` to skip `basicAck()` if locally transacted and already cancelled.
Right, this may lead to the duplication delivery, but having abnormal shutdown situation we cannot guarantee that this message
to commit has been processed properly.
Also, adjust `BlockingQueueConsumer.nextMessage()` to rollback a message if consumer is canceled instead of
going through the loop via listener
* Increase `replyTimeout` in the `EnableRabbitReturnTypesTests` for resource-sensitive builds1 parent bc81ebc commit 4deb40c
File tree
2 files changed
+41
-21
lines changed- spring-rabbit/src
- main/java/org/springframework/amqp/rabbit/listener
- test/java/org/springframework/amqp/rabbit/annotation
2 files changed
+41
-21
lines changedLines changed: 40 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
| 173 | + | |
| 174 | + | |
174 | 175 | | |
175 | 176 | | |
176 | 177 | | |
| |||
468 | 469 | | |
469 | 470 | | |
470 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
471 | 475 | | |
472 | 476 | | |
473 | 477 | | |
474 | 478 | | |
475 | | - | |
476 | | - | |
477 | 479 | | |
478 | 480 | | |
479 | 481 | | |
| |||
560 | 562 | | |
561 | 563 | | |
562 | 564 | | |
563 | | - | |
564 | | - | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
565 | 580 | | |
566 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
567 | 584 | | |
568 | | - | |
569 | 585 | | |
570 | 586 | | |
571 | 587 | | |
| |||
792 | 808 | | |
793 | 809 | | |
794 | 810 | | |
795 | | - | |
| 811 | + | |
796 | 812 | | |
797 | 813 | | |
798 | 814 | | |
| |||
894 | 910 | | |
895 | 911 | | |
896 | 912 | | |
897 | | - | |
898 | | - | |
899 | | - | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
900 | 917 | | |
901 | 918 | | |
902 | 919 | | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
913 | 932 | | |
914 | 933 | | |
915 | 934 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
| |||
0 commit comments