[ 
https://issues.apache.org/jira/browse/AMQ-9344?focusedWorklogId=900192&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-900192
 ]

ASF GitHub Bot logged work on AMQ-9344:
---------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Jan/24 18:10
            Start Date: 17/Jan/24 18:10
    Worklog Time Spent: 10m 
      Work Description: mattrpav commented on code in PR #1139:
URL: https://github.com/apache/activemq/pull/1139#discussion_r1456234113


##########
activemq-unit-tests/src/test/java/org/apache/activemq/usecases/MaxUncommittedCountExceededTest.java:
##########
@@ -0,0 +1,217 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.usecases;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.management.ManagementFactory;
+
+import javax.management.JMX;
+import javax.management.MBeanServer;
+
+import org.apache.activemq.ActiveMQConnection;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.jmx.BrokerMBeanSupport;
+import org.apache.activemq.broker.jmx.QueueViewMBean;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.command.ActiveMQQueue;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+
+import jakarta.jms.Connection;
+import jakarta.jms.JMSException;
+import jakarta.jms.Message;
+import jakarta.jms.MessageProducer;
+import jakarta.jms.Queue;
+import jakarta.jms.ResourceAllocationException;
+import jakarta.jms.Session;
+
+public class MaxUncommittedCountExceededTest {
+
+    public static final String DEFAULT_JMX_DOMAIN_NAME = "org.apache.activemq";
+    public static final String DEFAULT_JMX_BROKER_NAME = "localhost";
+
+    public static final String DEFAULT_JMS_USER = "admin";
+    public static final String DEFAULT_JMS_PASS = "admin";
+
+    protected ActiveMQConnectionFactory activemqConnectionFactory = null;
+    protected BrokerService brokerService = null;
+
+    @Rule
+    public TestName testName = new TestName();
+
+    // Control session
+    protected Connection connection = null;
+    protected Session session = null;
+    protected MessageProducer messageProducer = null;
+
+    protected String methodNameDestinationName = null;
+    protected MBeanServer mbeanServer = null;
+    protected QueueViewMBean queueViewMBean = null;
+
+    @Before
+    public void setUp() throws Exception {
+        brokerService = new BrokerService();
+        brokerService.setDeleteAllMessagesOnStartup(true);
+        brokerService.setPersistent(true);
+        brokerService.setUseJmx(true);
+        brokerService.addConnector("tcp://localhost:0").setName("Default");
+        brokerService.setBrokerName("localhost");
+        brokerService.start();
+        brokerService.waitUntilStarted(30_000);
+        brokerService.deleteAllMessages();
+        assertNotNull(brokerService);
+
+        activemqConnectionFactory = new 
ActiveMQConnectionFactory(brokerService.getTransportConnectorByScheme("tcp").getPublishableConnectString());
+        connection = activemqConnectionFactory.createConnection();
+        connection.start();
+        session = connection.createSession(true, Session.SESSION_TRANSACTED);
+        methodNameDestinationName = "AMQ.TX." + 
cleanParameterizedMethodName(testName.getMethodName().toUpperCase());
+        Queue queue = session.createQueue(methodNameDestinationName);
+        messageProducer = session.createProducer(queue);
+        mbeanServer = ManagementFactory.getPlatformMBeanServer();
+        brokerService.getAdminView().addQueue(methodNameDestinationName);
+        queueViewMBean = getQueueViewMBean(new 
ActiveMQQueue(methodNameDestinationName));
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        if (messageProducer != null) {

Review Comment:
   Agreed, I'd like to build a JUnit 5 set of tools to provide all this 
boilerplate code.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 900192)
    Time Spent: 50m  (was: 40m)

> Ability to configure a limit on uncommitted message count in a transaction
> --------------------------------------------------------------------------
>
>                 Key: AMQ-9344
>                 URL: https://issues.apache.org/jira/browse/AMQ-9344
>             Project: ActiveMQ
>          Issue Type: New Feature
>            Reporter: Matt Pavlovich
>            Assignee: Matt Pavlovich
>            Priority: Major
>             Fix For: 6.1.0
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> 1. Add a config flag to limit the max number (by count and/or bytes) of 
> uncommitted message per transaction
> 2. Add a config flag to limit the max number of simultaneous transactions per 
> destination
> On limit exceeding, rollback the tx and return a ResourceAllocationException 
> to the client
> Possible default values:
> 6.x - unlimited (current behavior)
> 7.x - 10,000 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to