Skip to content

feat(console): add user-friendly CLI commands for queues, topics, broker, and network connectors(#1816). - #1966

Open
anmol-saxena-14 wants to merge 2 commits into
apache:mainfrom
anmol-saxena-14:issues-1816
Open

feat(console): add user-friendly CLI commands for queues, topics, broker, and network connectors(#1816).#1966
anmol-saxena-14 wants to merge 2 commits into
apache:mainfrom
anmol-saxena-14:issues-1816

Conversation

@anmol-saxena-14

Copy link
Copy Markdown
Contributor

Adds four new action-oriented CLI commands as described in Issue#1816, making it straightforward to manage a running broker from the shell(and from AI agents such as Claude Code) without requiring JMX tooling.

New commands
activemq queues list | create | delete | purge | info | browse | produce | pause | resume
activemq topics list | create | delete | info
activemq broker info | connectors [list|add|remove] | scheduler
activemq network-connectors list | add | remove

Each command is registered via the existing ServiceLoader SPI (META-INF/services/...Command) so no existing code is modified to discover them.

The consume action is intentionally not implemented in the new commands. Receiving and acknowledging messages requires an active JMS connection,which is outside the scope of the JMX-based CLI facade. The existing activemq consumer command covers that use case.

Tests : 37 new unit tests across BrokerCommandTest, NetworkConnectorsCommandTest, QueuesCommandTest, and TopicsCommandTest covering all actions and error-handling paths.

@anmol-saxena-14
anmol-saxena-14 marked this pull request as ready for review April 26, 2026 00:15
@jbonofre
jbonofre self-requested a review April 27, 2026 04:00
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions Bot added the Stale label Jul 4, 2026
@anmol-saxena-14

Copy link
Copy Markdown
Contributor Author

This PR is not stale, it is still under review by reviewer.

@github-actions github-actions Bot removed the Stale label Jul 10, 2026

@jbonofre jbonofre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, this is a nice addition and follows the existing AbstractJmxCommand / ServiceLoader pattern cleanly. The tests spinning up real embedded brokers and verifying side effects via JMX proxies are much appreciated. A few comments inline — the main one to address before merge is the negative tests that can pass silently. The rest are cleanups (duplication, dead code) and are non-blocking.

}

@Test(timeout = 30000)
public void testAddMissingUriThrows() throws Exception {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test can pass silently: the try/catch has no fail() after execute("add"), so if the IllegalArgumentException is never thrown the assertion in the catch block simply doesn't run and the test still passes. It would keep passing even if the validation were removed. Please add a fail("expected IllegalArgumentException") after the execute(...) call, or switch to assertThrows(IllegalArgumentException.class, () -> execute("add")).

}

@Test(timeout = 30000)
public void testRemoveMissingNameThrows() throws Exception {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as testAddMissingUriThrows: no fail() after execute("remove"), so this passes even if no exception is thrown. Use assertThrows(...) or add a fail(...) after the call.

}

@Test(timeout = 30000)
public void testProduceMissingBody() throws Exception {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same silent-pass problem here: the try/catch around execute("produce", "Q1") has no fail(), so the test passes whether or not the exception is thrown. Please use assertThrows(IllegalArgumentException.class, ...) or add a fail(...).

}

@SuppressWarnings("unchecked")
private BrokerViewMBean getBrokerMBean() throws Exception {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getBrokerMBean() and dashes() are duplicated verbatim across all four new command classes (QueuesCommand, TopicsCommand, BrokerCommand, NetworkConnectorsCommand). Consider lifting a shared helper (e.g. getBrokerViewMBean()) into AbstractJmxCommand so all commands reuse it. Non-blocking, but it would avoid the copy-paste drift.

}
}

private static String dashes(int count) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dashes(int) can just be "-".repeat(count) (Java 11+ is available here), which would also let this duplicated helper disappear once the shared base is in place.

}

@SuppressWarnings("unchecked")
private void purgeQueue(String queueName) throws Exception {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

purge, info, browse, produce, pause, and resume all repeat the same ~6-line block: query by destinationName, bail with a not-found message if empty, otherwise build a QueueViewMBean proxy from the first result. Extracting a private QueueViewMBean lookupQueue(String name) helper (returning null and printing the not-found message on a miss) would remove most of the repetition and centralize the not-found behavior.

*/
package org.apache.activemq.console;

import static org.junit.Assert.assertFalse;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertFalse is imported but never used in this test — please remove the unused import.

return out.toString();
}

private TopicViewMBean getTopicProxy(String topicName) throws Exception {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getTopicProxy(...) is never called anywhere in this test class (unlike getQueueProxy in QueuesCommandTest, which is used). Please remove this dead helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants