Repository navigation
Conversation
added 2 commits
December 1, 2026 08:51
The HTTP transport delivers broker-to-client commands through a long-poll GET that returns exactly one command, so a client drains a backlog at one command per network round trip no matter how many are already queued for it. - Client: new transport option maxCommandsPerPoll (default 1). When greater than 1 the GET carries the header ActiveMQ-Max-Commands. - Broker: HttpTunnelServlet keeps the existing blocking poll for the first command, then drains whatever is already queued, without waiting, up to the requested number, capped by the connector option http.maxCommandsPerPoll (default 100). The number sent is returned in ActiveMQ-Command-Count. Commands keep the existing length-prefixed framing, back to back. - Either side alone behaves as before: an old client sends no header and gets one command; an old broker ignores the header and sends one command without a count header, which a new client reads as one.
Replace the fixed command count with limits the broker already has, as suggested in review: - Drop the client option maxCommandsPerPoll and the connector option http.maxCommandsPerPoll. The client now sends ActiveMQ-Batched-Poll: true when batchedPoll=true. - The broker returns every command already queued for the client. The queue only holds what has been dispatched, so consumer prefetch bounds the count. - The response is capped by the connector's existing wireFormat.maxFrameSize, previously only applied to POST. The first command is always sent, as before; a command that would exceed the limit goes back to the head of the queue, now a LinkedBlockingDeque, so order is kept.
kiril-me
force-pushed
the
several_commands_per_http_get
branch
from
December 2, 2026 09:30
9504854 to
b747abe
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue: #2902
Why
JMS clients that can only reach a broker over the
http://transport receive exactly one commandper long-poll GET. Over a WAN this caps broker->client throughput at one command per round trip
per connection, even when many commands are already queued. Use case and alternatives (REST,
ws://,stomp://) are discussed in #2902.What
batchedPoll(defaultfalse). Whentrue, each GET sendsActiveMQ-Batched-Poll: true.HttpTunnelServlet.doGetkeeps the existing blocking poll for the first command,then appends whatever is already queued for that client, without waiting:
dispatched, so no new count option is needed.
wireFormat.maxFrameSize(until now onlyenforced on POST). The first command is always sent, as today. A command that would exceed the
limit goes back to the head of the queue.
LinkedBlockingDeque, so a command put back keeps its order.A
ShutdownInfotaken while batching is also put back at the head and ends the batch.ActiveMQ-Command-Count: <k>. The body format is unchanged:TextWireFormatalready writes a length prefix per command, so it is k commands back to back.Compatibility
maxFrameSizeTests
HttpTunnelServletBatchedPollTest: today's single-command response, returns everything queuedin order, stops before exceeding
maxFrameSizewith the remainder kept at the head, first commandsent even when larger than
maxFrameSize,ShutdownInfoleft at the head, header other thantruefalls back to one command, a non-deque queue falls back to one command.HttpClientTransportBatchedPollTest: reads every command of a batched response in order,missing count header = 1, default client sends no header.
HttpBatchedPollTest: end-to-end over real HTTP connectors, 500 messages in order withauto-acknowledge and transacted sessions, against a connector with
wireFormat.maxFrameSize=8192(forces split batches), and an old client against the new broker.
Measurements
Simulated 20 ms per-request round trip, 200 messages, prefetch 100:
batchedPoll=trueThe gain shows up when commands are already queued, for example batched commits or acks.
Consumers that acknowledge every message let only one dispatch queue up at a time.
Open points
wireFormat.maxFrameSizeis unset (unlimited by default), is prefetch alone an acceptablebound, or would you like a fallback size cap?
batchedPolldefault totrue? It is compatible with old brokers and old clients.batchedPoll: I'll send a separate PR toactivemq-websiteonce agreed.