You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Thai Le <ln...@gmail.com> on 2022/10/25 20:24:50 UTC
How to get list of queues in topic address
Hello,
I am using ActiveMQClient to talk to the artemis broker. I am trying to
move all the messages in a topic to another topic programmatically. The
only pieces of info I have is the broker URL, username, password and the
topic name (the address). However, since there are quite a number of
subscribers to this topic, I want to get the list of queues associated with
the address and run the move operation on each of them. Unfortunately, i do
not see any operation that return the list of queues associated with the
address (topic). Here is my current code:
> try (ServerLocator locator = ActiveMQClient.createServerLocator(broker.getUrl()); ClientSessionFactory factory = locator.createSessionFactory(); ClientSession session = factory.createSession(broker.getAdmin(), broker.getAdminPassword(), false, true, true, true, 10);) {
>
> ClientRequestor requestor = new ClientRequestor(session, "activemq.management"); ClientMessage message = session.createMessage(true); ManagementHelper.putOperationInvocation(
> message
> , String.format("%s%s", ResourceNames.ADDRESS, oldTopicAddress)
> , "?????"); session.start(); ClientMessage reply = requestor.request(message); requestor.close(); return extractQueueNames(reply);
>
> Hope to get some hint
Thai Le
Re: How to get list of queues in topic address
Posted by Thai Le <ln...@gmail.com>.
Thank you Justin
On Wed, 26 Oct 2022 at 01:37, Justin Bertram <jb...@apache.org> wrote:
> Use the "getQueueNames" method on the address control [1], e.g.:
>
> try (ServerLocator locator =
> ActiveMQClient.createServerLocator("vm://0");
> ClientSessionFactory factory = locator.createSessionFactory();
> ClientSession session = factory.createSession(false, true,
> true)) {
>
> ClientRequestor requestor = new ClientRequestor(session,
> "activemq.management");
> ClientMessage message = session.createMessage(true);
> ManagementHelper.putOperationInvocation(message,
> String.format("%s%s", ResourceNames.ADDRESS, "myAddress"),
> "getQueueNames");
> session.start();
> ClientMessage reply = requestor.request(message);
> requestor.close();
> for (Object results : ManagementHelper.getResults(reply)) {
> for (Object result : ((Object[])results))
> System.out.println(result);
> }
> }
>
>
> Justin
>
> [1]
>
> https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/management/AddressControl.html#getQueueNames()
>
> On Tue, Oct 25, 2022 at 3:26 PM Thai Le <ln...@gmail.com> wrote:
>
> > Hello,
> > I am using ActiveMQClient to talk to the artemis broker. I am trying to
> > move all the messages in a topic to another topic programmatically. The
> > only pieces of info I have is the broker URL, username, password and the
> > topic name (the address). However, since there are quite a number of
> > subscribers to this topic, I want to get the list of queues associated
> with
> > the address and run the move operation on each of them. Unfortunately, i
> do
> > not see any operation that return the list of queues associated with the
> > address (topic). Here is my current code:
> >
> > > try (ServerLocator locator =
> > ActiveMQClient.createServerLocator(broker.getUrl());
> > ClientSessionFactory factory = locator.createSessionFactory();
> > ClientSession session = factory.createSession(broker.getAdmin(),
> > broker.getAdminPassword(), false, true, true, true, 10);) {
> > >
> > > ClientRequestor requestor = new ClientRequestor(session,
> > "activemq.management"); ClientMessage message =
> > session.createMessage(true); ManagementHelper.putOperationInvocation(
> > > message
> > > , String.format("%s%s", ResourceNames.ADDRESS,
> oldTopicAddress)
> > > , "?????"); session.start(); ClientMessage reply =
> > requestor.request(message); requestor.close(); return
> > extractQueueNames(reply);
> > >
> > > Hope to get some hint
> >
> > Thai Le
> >
>
--
Where there is will, there is a way
Re: How to get list of queues in topic address
Posted by Justin Bertram <jb...@apache.org>.
Use the "getQueueNames" method on the address control [1], e.g.:
try (ServerLocator locator =
ActiveMQClient.createServerLocator("vm://0");
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession session = factory.createSession(false, true,
true)) {
ClientRequestor requestor = new ClientRequestor(session,
"activemq.management");
ClientMessage message = session.createMessage(true);
ManagementHelper.putOperationInvocation(message,
String.format("%s%s", ResourceNames.ADDRESS, "myAddress"), "getQueueNames");
session.start();
ClientMessage reply = requestor.request(message);
requestor.close();
for (Object results : ManagementHelper.getResults(reply)) {
for (Object result : ((Object[])results))
System.out.println(result);
}
}
Justin
[1]
https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/management/AddressControl.html#getQueueNames()
On Tue, Oct 25, 2022 at 3:26 PM Thai Le <ln...@gmail.com> wrote:
> Hello,
> I am using ActiveMQClient to talk to the artemis broker. I am trying to
> move all the messages in a topic to another topic programmatically. The
> only pieces of info I have is the broker URL, username, password and the
> topic name (the address). However, since there are quite a number of
> subscribers to this topic, I want to get the list of queues associated with
> the address and run the move operation on each of them. Unfortunately, i do
> not see any operation that return the list of queues associated with the
> address (topic). Here is my current code:
>
> > try (ServerLocator locator =
> ActiveMQClient.createServerLocator(broker.getUrl());
> ClientSessionFactory factory = locator.createSessionFactory();
> ClientSession session = factory.createSession(broker.getAdmin(),
> broker.getAdminPassword(), false, true, true, true, 10);) {
> >
> > ClientRequestor requestor = new ClientRequestor(session,
> "activemq.management"); ClientMessage message =
> session.createMessage(true); ManagementHelper.putOperationInvocation(
> > message
> > , String.format("%s%s", ResourceNames.ADDRESS, oldTopicAddress)
> > , "?????"); session.start(); ClientMessage reply =
> requestor.request(message); requestor.close(); return
> extractQueueNames(reply);
> >
> > Hope to get some hint
>
> Thai Le
>