AlexejTimonin commented on code in PR #1275:
URL: https://github.com/apache/activemq/pull/1275#discussion_r1693942546


##########
activemq-jdbc-store/src/main/java/org/apache/activemq/store/jdbc/adapter/DefaultJDBCAdapter.java:
##########
@@ -620,12 +618,12 @@ public void doRecoverNextMessages(TransactionContext c, 
ActiveMQDestination dest
 
     @Override
     public void doRecoverNextMessagesWithPriority(TransactionContext c, 
ActiveMQDestination destination, String clientId,
-            String subscriptionName, long seq, long priority, int maxReturned, 
JDBCMessageRecoveryListener listener) throws Exception {
+                                                  String subscriptionName, 
long seq, long priority, int maxReturned, JDBCMessageRecoveryListener listener) 
throws Exception {
 
         PreparedStatement s = null;
         ResultSet rs = null;
         try {
-            s = 
c.getConnection().prepareStatement(this.statements.getFindDurableSubMessagesByPriorityStatement());
+            s = 
c.getConnection().prepareStatement(this.limitQuery(this.statements.getFindDurableSubMessagesByPriorityStatement()));
             s.setMaxRows(Math.min(maxReturned * 2, maxRows));

Review Comment:
   Not an expert, but I did some git blame digging, the * 2 got introduced in 
https://issues.apache.org/jira/browse/AMQ-2980, to take into account the 
messages from low and high priority queues, to ensure that none get lost. Down 
the road this happened ``java.sql.SQLException: setMaxRows() out of range. 
50871918 > 50000000.`` (https://issues.apache.org/jira/browse/AMQ-1870). The 
solution to this was to pick the lowest of two values ``(maxReturner * 2) and 
maxRows``, to ensure such exception does not happen.



-- 
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


Reply via email to