mattrpav commented on code in PR #2165:
URL: https://github.com/apache/activemq/pull/2165#discussion_r3509732870
##########
activemq-broker/src/main/java/org/apache/activemq/broker/region/cursors/FilePendingMessageCursor.java:
##########
@@ -516,12 +561,44 @@ public PList getDiskList() {
return diskList;
}
+ private void discardMessage(MessageReference reference, DiscardType
discardType) {
+ if (discardType == DiscardType.EXPIRED) {
+ discardExpiredMessage(reference);
+ } else {
+ discardMessage(reference);
+ }
+ }
+
private void discardExpiredMessage(MessageReference reference) {
LOG.debug("Discarding expired message {}", reference);
- if (reference.isExpired() && broker.isExpired(reference)) {
- ConnectionContext context = new ConnectionContext();
- context.setBroker(broker);
-
((Destination)reference.getRegionDestination()).messageExpired(context, null,
new IndirectMessageReference(reference.getMessage()));
+ try {
+ if (reference.isExpired() && broker.isExpired(reference)) {
+ ConnectionContext context = broker.getAdminConnectionContext();
+ ((Destination)
reference.getRegionDestination()).messageExpired(context, sub,
+ new IndirectMessageReference(reference.getMessage()));
+ }
+ } catch (Exception e) {
+ LOG.warn("Error discarding expired message {}",
reference.getMessageId());
+ LOG.debug(e.getMessage(), e);
+ } finally {
+ // we can now drop the reference count
+ reference.decrementReferenceCount();
+ }
+ }
+
+ private void discardMessage(MessageReference reference) {
+ try {
+ LOG.debug("Discarding message {}", reference);
Review Comment:
nit: I think the log should say _why_ it is discarding in the message --
temp space full, temp space disabled, expired, etc
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact