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

ASF GitHub Bot logged work on ARTEMIS-5142:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Dec/24 17:03
            Start Date: 18/Dec/24 17:03
    Worklog Time Spent: 10m 
      Work Description: jbertram commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1890570664


##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/multiprotocol/JMSMessageExpiryTest.java:
##########
@@ -0,0 +1,197 @@
+/*
+ * 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.artemis.tests.integration.jms.multiprotocol;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import java.lang.invoke.MethodHandles;
+
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class JMSMessageExpiryTest extends MultiprotocolJMSClientTestSupport {
+
+   protected static final Logger logger = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+   private final long EXPIRY_DELAY = 9999999L;
+   private final long WINDOW = 20L;
+
+   @Test
+   @Timeout(30)
+   public void testCoreMessageExpiryDelay() throws Exception {
+      testExpiry(createCoreConnection(), DelayType.NORMAL, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testAmqpMessageExpiryDelay() throws Exception {
+      testExpiry(createConnection(), DelayType.NORMAL, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testOpenWireMessageExpiryDelay() throws Exception {
+      testExpiry(createOpenWireConnection(), DelayType.NORMAL, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testCoreMaxExpiryDelayNoExpiration() throws Exception {
+      testExpiry(createCoreConnection(), DelayType.MAX, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testAmqpMaxExpiryDelayNoExpiration() throws Exception {
+      testExpiry(createConnection(), DelayType.MAX, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testOpenWireMaxExpiryDelayNoExpiration() throws Exception {
+      testExpiry(createOpenWireConnection(), DelayType.MAX, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testCoreMinExpiryDelayNoExpiration() throws Exception {
+      testExpiry(createCoreConnection(), DelayType.MIN, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testAmqpMinExpiryDelayNoExpiration() throws Exception {
+      testExpiry(createConnection(), DelayType.MIN, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testOpenWireMinExpiryDelayNoExpiration() throws Exception {
+      testExpiry(createOpenWireConnection(), DelayType.MIN, false);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testCoreMaxExpiryDelayWithExpiration() throws Exception {
+      testExpiry(createCoreConnection(), DelayType.MAX, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testAmqpMaxExpiryDelayWithExpiration() throws Exception {
+      testExpiry(createConnection(), DelayType.MAX, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testOpenWireMaxExpiryDelayWithExpiration() throws Exception {
+      testExpiry(createOpenWireConnection(), DelayType.MAX, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testCoreMinExpiryDelayWithExpiration() throws Exception {
+      testExpiry(createCoreConnection(), DelayType.MIN, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testAmqpMinExpiryDelayWithExpiration() throws Exception {
+      testExpiry(createConnection(), DelayType.MIN, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testOpenWireMinExpiryDelayWithExpiration() throws Exception {
+      testExpiry(createOpenWireConnection(), DelayType.MIN, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testCoreMessageNeverExpire() throws Exception {
+      testExpiry(createCoreConnection(), DelayType.NEVER, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testAmqpMessageNeverExpire() throws Exception {
+      testExpiry(createConnection(), DelayType.NEVER, true);
+   }
+
+   @Test
+   @Timeout(30)
+   public void testOpenWireMessageNeverExpire() throws Exception {
+      testExpiry(createOpenWireConnection(), DelayType.NEVER, true);
+   }
+
+   private void testExpiry(Connection connection, DelayType delayType, boolean 
setTimeToLive) throws Exception {
+      AddressSettings addressSettings = new AddressSettings();
+      if (delayType == DelayType.NORMAL) {
+         addressSettings.setExpiryDelay(EXPIRY_DELAY);
+      } else if (delayType == DelayType.MIN) {
+         addressSettings.setMinExpiryDelay(EXPIRY_DELAY);
+      } else if (delayType == DelayType.MAX) {
+         addressSettings.setMaxExpiryDelay(EXPIRY_DELAY);
+      } else if (delayType == DelayType.NEVER) {
+         addressSettings.setNeverExpire(true);
+      }
+      server.getAddressSettingsRepository().addMatch(getQueueName(), 
addressSettings);
+
+      Session s = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      Queue q = s.createQueue(getQueueName());
+      MessageProducer p = s.createProducer(q);
+      if (setTimeToLive) {
+         if (delayType == DelayType.MIN) {
+            p.setTimeToLive(EXPIRY_DELAY / 2);
+         } else if (delayType == DelayType.MAX) {
+            p.setTimeToLive(EXPIRY_DELAY * 2);
+         } else if (delayType == DelayType.NEVER) {
+            p.setTimeToLive(EXPIRY_DELAY);
+         }
+      }
+      long start = System.currentTimeMillis();
+      p.send(s.createMessage());
+      p.close();
+      MessageConsumer c = s.createConsumer(q);
+      connection.start();
+      Message m = c.receive(100);

Review Comment:
   Test is using `1500` now.





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

    Worklog Id:     (was: 948990)
    Time Spent: 8.5h  (was: 8h 20m)

> support never expiring incoming messages
> ----------------------------------------
>
>                 Key: ARTEMIS-5142
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5142
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>            Reporter: Justin Bertram
>            Assignee: Justin Bertram
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 8.5h
>  Remaining Estimate: 0h
>
> In an attempt to never expire messages I tried setting either 
> {{max-expiry-delay}} or {{min-expiry-delay}} to {{0}}. However, this caused 
> messages to be expired _immediately_ rather than not expired at. There 
> doesn't appear to be any way to categorically prevent incoming messages sent 
> to a particular from expiring.



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

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