[
https://issues.apache.org/jira/browse/ARTEMIS-2642?focusedWorklogId=401141&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-401141
]
ASF GitHub Bot logged work on ARTEMIS-2642:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 11/Mar/20 02:09
Start Date: 11/Mar/20 02:09
Worklog Time Spent: 10m
Work Description: clebertsuconic commented on pull request #3012:
ARTEMIS-2642 Fixing Drain Timeout Issue on AMQP
URL: https://github.com/apache/activemq-artemis/pull/3012#discussion_r390709382
##########
File path:
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/DrainTimeoutTest.java
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.amqp;
+
+import javax.jms.JMSConsumer;
+import javax.jms.JMSContext;
+import javax.jms.JMSProducer;
+import javax.jms.Message;
+import javax.jms.Queue;
+import javax.jms.Session;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.LongAdder;
+
+import org.apache.qpid.jms.JmsConnectionFactory;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DrainTimeoutTest extends AmqpClientTestSupport {
+
+ final int NUMBER_OF_MESSAGES = 1000;
+
+ @Test(timeout = 300_000)
+ public void testFlowControl() throws Exception {
+ final AtomicInteger errors = new AtomicInteger(0);
+ final String queueName = getQueueName();
+ JmsConnectionFactory connectionFactory =
+ new JmsConnectionFactory(
+ "tqadmin",
+ "admin",
+
"amqp://localhost:5672?jms.prefetchPolicy.all=1&jms.connectTimeout=60000&amqp.drainTimeout=1000");
+ connectionFactory.setExceptionListener(
+ e -> {
+ System.out.println("Got a JMSException. Terminating the VM.");
Review comment:
removing this line.. part of my own review.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 401141)
Time Spent: 0.5h (was: 20m)
> Client Drain requests can cause long drain times and client Timeouts
> --------------------------------------------------------------------
>
> Key: ARTEMIS-2642
> URL: https://issues.apache.org/jira/browse/ARTEMIS-2642
> Project: ActiveMQ Artemis
> Issue Type: Bug
> Components: Broker
> Affects Versions: 2.11.0
> Reporter: Mike Youngstrom
> Assignee: Clebert Suconic
> Priority: Major
> Fix For: 2.12.0
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> Using the Qpid JMS AMQP client attempting to receive messages with no wait
> can produce very long drain times causing a Drain Timeout on the client. If
> I change to using "receive()" (causing the qpid client to no longer send
> drain requests) the problem goes away.
> Test Case using Qpid AMQP JMS client
> {code:java}
> public static void main(String[] args) throws Exception {
> final String queueName = "queue";
> var connectionFactory =
> new JmsConnectionFactory(
> "tqadmin",
> "admin",
>
> "amqp://localhost:5672?jms.prefetchPolicy.all=1&jms.connectTimeout=60000&amqp.drainTimeout=10000");
> connectionFactory.setExceptionListener(
> e -> {
> System.out.println("Got a JMSException. Terminating the VM.");
> e.printStackTrace();
> Runtime.getRuntime().halt(100);
> });
> var sendCount = new LongAdder();
> var consumeCount = new LongAdder();
> var consumerThread =
> new Thread(
> () -> {
> try (var listenerContext =
> connectionFactory.createContext(Session.AUTO_ACKNOWLEDGE)) {
> try (var consumer =
> listenerContext.createConsumer(
> listenerContext.createQueue(queueName))) {
> while (!Thread.interrupted()) {
> while (consumer.receiveNoWait() != null) {
> consumeCount.increment();
> long consumed = consumeCount.sum();
> if (consumed % 100 == 0) {
> System.out.println("Messages Consumed: " + consumed);
> }
> }
> }
> }
> }
> });
> consumerThread.start();
> try (var context =
> connectionFactory.createContext(Session.AUTO_ACKNOWLEDGE)) {
> final Message message = context.createMessage();
> message.setStringProperty("selector", "dude");
> var producer = context.createProducer();
> var queue = context.createQueue(queueName);
> while (sendCount.sum() < 100000 && !Thread.interrupted()) {
> producer.send(queue, message);
> sendCount.increment();
> long sent = sendCount.sum();
> if (sent % 100 == 0) {
> System.out.println("Messages Sent: " + sent);
> }
> }
> }
> }
> {code}
> Error Thrown after about 2000 messages are consumed (in a default local
> environment)
> {code:java}
> Exception in thread "Thread-0" javax.jms.JMSRuntimeException: Remote did not
> respond to a drain request in time
> at
> org.apache.qpid.jms.exceptions.JmsExceptionSupport.createRuntimeException(JmsExceptionSupport.java:211)
> at org.apache.qpid.jms.JmsConsumer.receiveNoWait(JmsConsumer.java:100)
> at connections.TQTest2.lambda$1(TQTest2.java:33)
> at java.base/java.lang.Thread.run(Thread.java:834)
> Caused by: org.apache.qpid.jms.JmsOperationTimedOutException: Remote did not
> respond to a drain request in time
> at
> org.apache.qpid.jms.provider.exceptions.ProviderOperationTimedOutException.toJMSException(ProviderOperationTimedOutException.java:39)
> at
> org.apache.qpid.jms.provider.exceptions.ProviderOperationTimedOutException.toJMSException(ProviderOperationTimedOutException.java:1)
> at
> org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:80)
> at
> org.apache.qpid.jms.exceptions.JmsExceptionSupport.create(JmsExceptionSupport.java:112)
> at org.apache.qpid.jms.JmsConnection.pull(JmsConnection.java:915)
> at org.apache.qpid.jms.JmsConnection.pull(JmsConnection.java:899)
> at
> org.apache.qpid.jms.JmsMessageConsumer.performPullIfRequired(JmsMessageConsumer.java:726)
> at
> org.apache.qpid.jms.JmsMessageConsumer.dequeue(JmsMessageConsumer.java:332)
> at
> org.apache.qpid.jms.JmsMessageConsumer.receiveNoWait(JmsMessageConsumer.java:221)
> at org.apache.qpid.jms.JmsConsumer.receiveNoWait(JmsConsumer.java:98)
> ... 2 more
> Caused by:
> org.apache.qpid.jms.provider.exceptions.ProviderOperationTimedOutException:
> Remote did not respond to a drain request in time
> at
> org.apache.qpid.jms.provider.amqp.AmqpConsumer.lambda$1(AmqpConsumer.java:179)
> at
> io.netty.util.concurrent.PromiseTask$RunnableAdapter.call(PromiseTask.java:38)
> at
> io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:127)
> at
> io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
> at
> io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:416)
> at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:515)
> at
> io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:918)
> at
> io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
> ... 1 more
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)