Skip to content

Cannot find the constants (QUEUE_NAME/QUEUE_MESSAGE_COUNT/QUEUE_CONSUMER_COUNT) in RabbitTemplate #2956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
XiPengyuan opened this issue Feb 7, 2025 · 4 comments · Fixed by #2959

Comments

@XiPengyuan
Copy link
Contributor

XiPengyuan commented Feb 7, 2025

The keys for the properties returned are available as constants in the `RabbitTemplate` (`QUEUE_NAME`,

The getQueueProperties() method returns some limited information about the queue (message count and consumer count). The keys for the properties returned are available as constants in the RabbitTemplate (QUEUE_NAME, QUEUE_MESSAGE_COUNT, and QUEUE_CONSUMER_COUNT).

But I couldn't find a definition for any of these constants in the RabbitTemplate source code. Is this RabbitTemplate or RabbitAdmin?

@artembilan
Copy link
Member

See RabbitAdmin:

	/**
	 * Property key for the queue name in the {@link Properties} returned by
	 * {@link #getQueueProperties(String)}.
	 */
	public static final Object QUEUE_NAME = "QUEUE_NAME";

	/**
	 * Property key for the message count in the {@link Properties} returned by
	 * {@link #getQueueProperties(String)}.
	 */
	public static final Object QUEUE_MESSAGE_COUNT = "QUEUE_MESSAGE_COUNT";

	/**
	 * Property key for the consumer count in the {@link Properties} returned by
	 * {@link #getQueueProperties(String)}.
	 */
	public static final Object QUEUE_CONSUMER_COUNT = "QUEUE_CONSUMER_COUNT";

And they are used like:

	/**
	 * Returns 3 properties {@link #QUEUE_NAME}, {@link #QUEUE_MESSAGE_COUNT},
	 * {@link #QUEUE_CONSUMER_COUNT}, or null if the queue doesn't exist.
	 */
	@Override
	@ManagedOperation(description = "Get queue name, message count and consumer count")
	public @Nullable Properties getQueueProperties(final String queueName) {
		QueueInformation queueInfo = getQueueInfo(queueName);
		if (queueInfo != null) {
			Properties props = new Properties();
			props.put(QUEUE_NAME, queueInfo.getName());
			props.put(QUEUE_MESSAGE_COUNT, queueInfo.getMessageCount());
			props.put(QUEUE_CONSUMER_COUNT, queueInfo.getConsumerCount());
			return props;
		}
		else {
			return null;
		}
	}

I'm not sure why you talk about RabbitTemplate since this is a result exactly of the RabbitAdmin operation.

@artembilan artembilan closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2025
@XiPengyuan
Copy link
Contributor Author

However, the official documentation only mentions RabbitTemplate, not RabbitAdmin.

Image

Is this inconsistent with the actual code?

@artembilan
Copy link
Member

That looks like a bug in documentation.
Please, consider to contribute the fix: https://github.com/spring-projects/spring-amqp/blob/main/CONTRIBUTING.adoc

@artembilan artembilan reopened this Feb 10, 2025
@artembilan artembilan added this to the 4.0.0-M1 milestone Feb 10, 2025
XiPengyuan pushed a commit to XiPengyuan/spring-amqp that referenced this issue Feb 10, 2025
Cannot find the constants (QUEUE_NAME/QUEUE_MESSAGE_COUNT/QUEUE_CONSUMER_COUNT) in RabbitTemplate

Fixes spring-projects#2956
XiPengyuan pushed a commit to XiPengyuan/spring-amqp that referenced this issue Feb 10, 2025
Cannot find the constants (QUEUE_NAME/QUEUE_MESSAGE_COUNT/QUEUE_CONSUMER_COUNT) in RabbitTemplate

Fixes spring-projects#2956

Signed-off-by: Peter Xi <[email protected]>
@XiPengyuan
Copy link
Contributor Author

PR: #2959

spring-builds pushed a commit that referenced this issue Feb 10, 2025
Cannot find the constants (QUEUE_NAME/QUEUE_MESSAGE_COUNT/QUEUE_CONSUMER_COUNT) in RabbitTemplate

Fixes: #2956
Issue link: #2956

Signed-off-by: Peter Xi <[email protected]>
Co-authored-by: Peter Xi <[email protected]>

(cherry picked from commit ea16a02)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants