[ https://issues.apache.org/jira/browse/AMQ-9481?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17839405#comment-17839405 ]
Christopher L. Shannon edited comment on AMQ-9481 at 4/21/24 4:41 PM: ---------------------------------------------------------------------- I don't have a windows environment to test but I was able to reproduce this by using a clientId like the example and just hitting the rest API from my browser multiple times. It works the first time, but then the second time I get the error since the original async request never completes correctly even on timeout when there are no messages. I took a look at this and it turns out this was _almost_ fixed in AMQ-9330. The root cause is AsyncServletRequest that was created to replace the Jetty Continuation object does not handle timeouts correctly. In AMQ-9330 the code was changed to call {{{}complete(){}}}but turns out that makes things better but is stil not all the way correct. As shown here, we should be calling {{dispatch()}} on the context when timing out: [https://github.com/jetty/jetty.project/blob/jetty-9.4.54.v20240208/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java#L239] I have a fix and test and will open up a Pull request, with the new fix after the async request times out then things are cleaned up correctly and future requests will work. If the original async request is still open then the concurrent access error will be given. was (Author: christopher.l.shannon): I don't have a windows environment to test but I was able to reproduce this by using a clientId like the example and just hitting the rest API from my browser multiple times. It works the first time, but then the second time I get the error since the original async request never completes correctly even on timeout when there are no messages. I took a look at this and it turns out this was _almost_ fixed in AMQ-9330. The root cause is AsyncServletRequest that was created to replace the Jetty Continuation object does not handle timeouts correctly. In AMQ-9330 the code was changed to call complete() but turns out that makes things better but is stil not all the way correct. As shown here, we should be calling dispatch() on the context when timing out: [https://github.com/jetty/jetty.project/blob/jetty-9.4.54.v20240208/jetty-continuation/src/main/java/org/eclipse/jetty/continuation/Servlet3Continuation.java#L239] I have a fix and test and will open up a Pull request, with the new fix after the async request times out then things are cleaned up correctly and future requests will work. If the original async request is still open then the concurrent access error will be given. > Concurrent access error attempting to consume messages via REST API in 5.18.2 > or higher > --------------------------------------------------------------------------------------- > > Key: AMQ-9481 > URL: https://issues.apache.org/jira/browse/AMQ-9481 > Project: ActiveMQ Classic > Issue Type: Bug > Affects Versions: 5.18.2, 5.18.3, 5.18.4 > Reporter: Andrew Smith > Assignee: Christopher L. Shannon > Priority: Major > Fix For: 5.18.5, 6.1.3 > > > I am attempting to download a file from a queue via PowerShell. This can be > done with the following 4 lines: > {code:java} > $user="admin" > $pass="admin" | ConvertTo-SecureString -AsPlainText -Force > $cred = New-Object Management.Automation.PSCredential($user,$pass) > $status = Invoke-WebRequest -Uri > "http://localhost:8161/api/message/TestQueue?type=queue&clientId=Importer" > -Credential $cred -ContentType "application/base64"{code} > When I do this using 5.18.1, it works and either downloads a file or times > out after a short period if there are no files on the queue. When I run the > same script against 5.18.2 or higher, I get the following error the first > time I try to download a file after starting the broker: > {noformat} > Invoke-WebRequest : HTTP ERROR 500 AsyncContext timeout > URI:/api/message/TestQueue > STATUS:500 > MESSAGE:AsyncContext timeout > SERVLET:MessageServlet > At line:1 char:11 > + $status = Invoke-WebRequest -Uri "http://localhost:8161/api/message/T ... > + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > + CategoryInfo : InvalidOperation: > (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc > eption > + FullyQualifiedErrorId : > WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand{noformat} > Then every time I try after that I get the following: > {noformat} > Invoke-WebRequest : HTTP ERROR 500 javax.servlet.ServletException: > javax.servlet.ServletException: > javax.servlet.ServletException: Concurrent access to consumer is not supported > URI:/api/message/TestQueue > STATUS:500 > MESSAGE:javax.servlet.ServletException: javax.servlet.ServletException: > javax.servlet.ServletException: Concurrent > access to consumer is not supported > SERVLET:MessageServlet > CAUSED BY:javax.servlet.ServletException: javax.servlet.ServletException: > javax.servlet.ServletException: Concurrent > access to consumer is not supported > CAUSED BY:javax.servlet.ServletException: javax.servlet.ServletException: > Concurrent access to consumer is not > supported > CAUSED BY:javax.servlet.ServletException: Concurrent access to consumer is > not supported > Caused by: > javax.servlet.ServletException: javax.servlet.ServletException: > javax.servlet.ServletException: Concurrent access to > consumer is not supported > at > org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:162) > at > org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) > at org.eclipse.jetty.server.Server.handle(Server.java:516) > at > org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487) > at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732) > at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479) > at > org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277) > at > org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311) > at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) > at > org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104) > at > org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338) > at > org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315) > at > org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173) > at > org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) > at > org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409) > at > org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) > at > org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) > at java.base/java.lang.Thread.run(Thread.java:1583) > Caused by: javax.servlet.ServletException: javax.servlet.ServletException: > Concurrent access to consumer is not > supported > at > org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:162) > at > org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560) > at > org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146) > ... 17 more > Caused by: javax.servlet.ServletException: Concurrent access to consumer is > not supported > at > org.apache.activemq.web.MessageServlet.doMessages(MessageServlet.java:196) > at > org.apache.activemq.web.MessageServlet.doGet(MessageServlet.java:170) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) > at > org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799) > at > org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:554) > at > org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) > at > org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560) > at > org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127) > at > org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:235) > at > org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624) > at > org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233) > at > org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440) > at > org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188) > at > org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:505) > at > org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594) > at > org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186) > at > org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355) > at > org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) > at > org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:146) > ... 19 more > At line:1 char:11 > + $status = Invoke-WebRequest -Uri "http://localhost:8161/api/message/T ... > + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > + CategoryInfo : InvalidOperation: > (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc > eption > + FullyQualifiedErrorId : > WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand{noformat} -- This message was sent by Atlassian Jira (v8.20.10#820010)