You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by "jbertram (via GitHub)" <gi...@apache.org> on 2024/12/10 21:19:42 UTC
[PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
jbertram opened a new pull request, #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390
@gemmellr, take a look at this as a potential replacement for #5334. I feel like this is much simpler and more intuitive.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#issuecomment-2532933061
@gemmellr, if you're good with this then I'll add more tests for the new `never-expire` address-setting.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1888973146
##########
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);
+ }
Review Comment:
I added 3 more tests that use a large message and restart the broker. That should cover all the permutations.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1886922435
##########
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;
Review Comment:
The even number, 10_000_000, would be more readable and better align with the later division by 2.
##########
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);
+ assertNotNull(m);
+ if (delayType == DelayType.NEVER) {
+ assertEquals(0, m.getJMSExpiration());
+ } else {
+ long duration = System.currentTimeMillis() - start;
+ long delayOnMessage = m.getJMSExpiration() - System.currentTimeMillis();
+ assertTrue(delayOnMessage >= (EXPIRY_DELAY - duration - WINDOW));
Review Comment:
Feels like WINDOW shouldnt really be doing anything (at least after using same reference for both calcs above) since you are already deducting a 'duration' which is including the consumer receive (and an assertNotNull) which necessarily makes it >= the broker-side elapsed time which could have influenced the actual expiration stamped by the broker, i.e you should already be deducting more than enough with just that?
##########
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);
+ }
Review Comment:
Given the differences in handling of 'large' and 'normal' messages I think both need covered in at least 1 test. Also, given there is explicit handling of expiration in the persisting and reload of durable messages, I think a test which restarts the broker before consumption is probably needed for both also.
##########
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());
Review Comment:
Would be better to create the message then record start, since the period of interest begins with the send itself.
##########
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:
Since we do expect to get a message, this seems a bit short and potentially brittle to sporadic failure.
##########
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);
+ assertNotNull(m);
+ if (delayType == DelayType.NEVER) {
+ assertEquals(0, m.getJMSExpiration());
+ } else {
+ long duration = System.currentTimeMillis() - start;
+ long delayOnMessage = m.getJMSExpiration() - System.currentTimeMillis();
Review Comment:
Could also just call System.currentTimeMillis() once after the receive and record it so both duration and delayOnMessage are more precisely calculated from the same reference.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#issuecomment-2542548685
@gemmellr, I added some integration tests and problem which I fixed. Let me know what you think.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1887623750
##########
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;
Review Comment:
Fixed.
##########
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());
Review Comment:
Fixed.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1888665804
##########
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);
+ }
Review Comment:
Looks like the additions only cover Large messages and a restart together. Given the runtime and persistence/reload handling of the messages differs significantly, specifically around expiration, we should have a restart test for a 'normal' message as well, and non-restarting test with a 'large' message.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1888713847
##########
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);
+ }
Review Comment:
In the most recent push I added three new tests using a large message (one for each protocol) and three new tests restarting the broker. The large message tests don't restart the broker and the tests restarting the broker don't use a large message.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1887624358
##########
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);
+ assertNotNull(m);
+ if (delayType == DelayType.NEVER) {
+ assertEquals(0, m.getJMSExpiration());
+ } else {
+ long duration = System.currentTimeMillis() - start;
+ long delayOnMessage = m.getJMSExpiration() - System.currentTimeMillis();
+ assertTrue(delayOnMessage >= (EXPIRY_DELAY - duration - WINDOW));
Review Comment:
I recall that being necessary for tests to pass at one point. I guess I changed something along the way that eliminated the need for it.
##########
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);
+ }
Review Comment:
Added.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr commented on PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#issuecomment-2541643432
You mentioned adding more tests...this is one I actually do think should have integration tests as well.
In particular, as I think about it more, I guess its likely there is a gotcha in there for AMQP messages (both for this and the existing min/max etc). I would not be surprised to see the broker apply the new expirations 'locally' but then send the original expiration to the consumer...so e.g if you _increase_ or _remove_ an original expiration, things may not turn out at all as intended.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "jbertram (via GitHub)" <gi...@apache.org>.
jbertram commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1887624901
##########
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);
+ assertNotNull(m);
+ if (delayType == DelayType.NEVER) {
+ assertEquals(0, m.getJMSExpiration());
+ } else {
+ long duration = System.currentTimeMillis() - start;
+ long delayOnMessage = m.getJMSExpiration() - System.currentTimeMillis();
Review Comment:
Fixed.
##########
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:
Fixed.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr merged PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "jbertram (via GitHub)" <gi...@apache.org>.
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.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1882331195
##########
artemis-server/src/main/resources/schema/artemis-configuration.xsd:
##########
@@ -3871,6 +3871,14 @@
</xsd:annotation>
</xsd:element>
+ <xsd:element name="never-expire" type="xsd:boolean" default="false" maxOccurs="1" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ Overrides the expiration time for all messages so that they never expire. "-1" disables this setting.
Review Comment:
This bit needs replaced:
"-1" disables this setting.
##########
artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java:
##########
@@ -1355,28 +1355,42 @@ private RoutingStatus maybeSendToDLA(final Message message,
return status;
}
- // HORNETQ-1029
- private static void applyExpiryDelay(Message message, AddressSettings settings) {
+ protected static void applyExpiryDelay(Message message, AddressSettings settings) {
long expirationOverride = settings.getExpiryDelay();
- // A -1 <expiry-delay> means don't do anything
- if (expirationOverride >= 0) {
- // only override the expiration on messages where the expiration hasn't been set by the user
+ if (settings.getNeverExpire()) {
+ if (message.getExpiration() != 0) {
+ message.setExpiration(0);
+ }
+ } else if (expirationOverride >= 0) {
+ // A -1 <expiry-delay> means don't do anything
if (message.getExpiration() == 0) {
- message.setExpiration(System.currentTimeMillis() + expirationOverride);
+ // only override the expiration on messages where the expiration hasn't been set by the user
+ message.setExpiration(getExpirationToSet(expirationOverride));
}
} else {
long minExpiration = settings.getMinExpiryDelay();
long maxExpiration = settings.getMaxExpiryDelay();
- if (maxExpiration != AddressSettings.DEFAULT_MAX_EXPIRY_DELAY && (message.getExpiration() == 0 || message.getExpiration() > (System.currentTimeMillis() + maxExpiration))) {
- message.setExpiration(System.currentTimeMillis() + maxExpiration);
+ if (message.getExpiration() == 0) {
+ // if the incoming message has NO expiration then apply the max if set and if not set then apply the min if set
+ if (maxExpiration != AddressSettings.DEFAULT_MAX_EXPIRY_DELAY) {
+ message.setExpiration(getExpirationToSet(maxExpiration));
+ } else if (minExpiration != AddressSettings.DEFAULT_MIN_EXPIRY_DELAY) {
+ message.setExpiration(getExpirationToSet(minExpiration));
+ }
+ } else if (maxExpiration != AddressSettings.DEFAULT_MAX_EXPIRY_DELAY && message.getExpiration() >= (System.currentTimeMillis() + maxExpiration)) {
Review Comment:
If not special casing 0 to unset expiration, can go back to > rather than >= here. No need to change it if its equal.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1888669238
##########
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:
500ms still seems quite short, with potential to be brittle in slow shared CI envs...an unfortunately timed GC, scheduling lottery, disk slowness, or combinations thereoff, seem like they could blow that limit. Its typical to use at least 1-2 seconds, often more, in cases we absolutely expect a message to arrive.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact
Re: [PR] ARTEMIS-5142 support never expiring incoming messages [activemq-artemis]
Posted by "gemmellr (via GitHub)" <gi...@apache.org>.
gemmellr commented on code in PR #5390:
URL: https://github.com/apache/activemq-artemis/pull/5390#discussion_r1888937842
##########
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);
+ }
Review Comment:
Yeah, I got it reversed when reading then later commenting and shoudl ahve said 'seperately', so also reverse the resulting points that there are still gaps in the combination testing (as you just outlined). Ones a bus is likely to fit through given the near completely seperate handling of these things for the two message types.
##########
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);
+ }
Review Comment:
Yeah, I got it reversed when reading then later commenting and should have said 'seperately', so also reverse the resulting points that there are still gaps in the combination testing (as you just outlined). Ones a bus is likely to fit through given the near completely seperate handling of these things for the two message types.
--
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org
For additional commands, e-mail: gitbox-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact