You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by titou10 titou10 <ti...@gmail.com> on 2017/03/22 18:01:31 UTC

Artemis 2.0: How to get the list of Queues and Topics from a server? (Fails in 2.0 with v1.5.3 code)

Hi,
With Artemis v1.5.3, to retrieve the list of queues and topics, I was
using this code (inspired from the example)

Queue managementQueue = ActiveMQJMSClient.createQueue("activemq.management");
Session sessionJMS = jmsConnection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
QueueRequestor requestorJMS = new QueueRequestor((QueueSession)
sessionJMS, managementQueue);
Message m = sessionJMS.createMessage();
JMSManagementHelper.putAttribute(m, ResourceNames.JMS_SERVER,
"queueNames"); // "topicNames" for topics
Message r = requestorJMS.request(m);
Object q = JMSManagementHelper.getResult(r);
...

If I run this code from a client with the v1.5.3 jars to a v2.0.0 server I got:
An exception on the server:

Caused by: java.lang.IllegalArgumentException: AMQ119067: Cannot find
resource with name jms.server
        at org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl.getAttribute(ManagementServiceImpl.java:675)
[artemis-server-2.0.0.jar:2.0.0]
        ... 30 more

And an exception on the client:
java.lang.IndexOutOfBoundsException: readerIndex(22) + length(98)
exceeds writerIndex(116): UnpooledDuplicatedByteBuf(ridx: 22, widx:
116, cap: 451, unwrapped: UnpooledUnsafeHeapByteBuf(ridx: 439, widx:
451, cap: 451))
    at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1395)
    at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1389)
    at io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:850)
    at io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:858)
    at io.netty.buffer.WrappedByteBuf.readBytes(WrappedByteBuf.java:649)
    at org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper.readSimpleStringInternal(ChannelBufferWrapper.java:93)
    at org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper.readNullableSimpleString(ChannelBufferWrapper.java:73)
    at org.apache.activemq.artemis.api.core.management.ManagementHelper.getResults(ManagementHelper.java:196)
    at org.apache.activemq.artemis.api.core.management.ManagementHelper.getResult(ManagementHelper.java:224)
    at org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.getResult(JMSManagementHelper.java:149)
    at org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.getResult(JMSManagementHelper.java:139)

I tried to update the client jars to v2.0.0. In v1.5.3, the
"ResourceNames.JMS_SERVER" variable exists with value "jms.server", in
v2.0.0, The ResourceName has benne totally changed and no "JMS_SERVER"
variable anymore (and no "SERVER" lookalike variable..).

So the question are
- how to retrieve the list of Queues and Topics from an Artemis v2.0.0 server?
- is there a migration/upgrade guide to upgrade from 1.5.x to 2.0.x?
- or a least is there a list of "deprecated/removed/changed" features
from v1.5.x to 2.0.x?

Thanks

Denis (Author of JMSToolBox on sourceforge)

Re: Artemis 2.0: How to get the list of Queues and Topics from a server? (Fails in 2.0 with v1.5.3 code)

Posted by Justin Bertram <jb...@apache.org>.
> How about Topics, there is no "getTopicNames()"  method in
> ActiveMQServerControl and logically causes this exception on the
> server...

That's correct.  There is no getTopicNames() method as the broker no longer tracks JMS-specific artifacts like topics.  There are only addresses and queues and their associated routing types.  Semantically, a JMS topic and its subscriptions are analogous to an address with multicast queues.

Currently there's no management operation to get the routing type of a queue.  Once we add that you'll be able to accurately identify the semantics of the various queues you've configured.


Justin 

----- Original Message -----
From: "titou10 titou10" <ti...@gmail.com>
To: users@activemq.apache.org
Sent: Wednesday, March 22, 2017 3:32:04 PM
Subject: Re: Artemis 2.0: How to get the list of Queues and Topics from a server? (Fails in 2.0 with v1.5.3 code)

Thanks again for your help

2017-03-22 16:06 GMT-04:00 Justin Bertram <jb...@apache.org>:
> Did you try modifying your code as I recommended?  If so, what was the result?
>
> I modified the "management" example locally as a proof-of-concept and it worked fine.  Here's the code (comments redacted):
>
>          QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
>          Queue managementQueue = ActiveMQJMSClient.createQueue("activemq.management");
>          QueueRequestor requestor = new QueueRequestor(session, managementQueue);
>          connection.start();
>          Message m = session.createMessage();
>          JMSManagementHelper.putAttribute(m, ResourceNames.BROKER, "queueNames");
>          Message reply = requestor.request(m);
>          Object[] queueNames = (Object[]) JMSManagementHelper.getResult(reply);
>          for (Object queueName : queueNames) {
>             System.out.println("Queue name: " + queueName);
>          }
>
> To be clear, org.apache.activemq.artemis.api.core.management.ResourceNames.BROKER essentially links to org.apache.activemq.artemis.api.core.management.ActiveMQServerControl.  Among others, it has methods getQueueNames() and getAddressNames() which should suffice for your purposes.  The idea of a JMS "server" and even a JMS topic was always a thin facade on top of the core implementation.  From a management and configuration perspective this facade has been removed to allow cleaner support for additional protocols (e.g. AMQP, MQTT, STOMP, etc.).
>

I understand, and this is was I was asking for (what features have
been changed/removed deprecated, in this case the JMS management
facade has been removed...)

Yes I did the same test as you in parallel and the getQueueName() does
not fails but it returns the Queues and the Topics mixed (ie
multicast..)
How about Topics, there is no "getTopicNames()"  method in
ActiveMQServerControl and logically causes this exception on the
server...

Caused by: java.lang.IllegalArgumentException: AMQ119068: no getter
method for topicNames
        at org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl.getAttribute(ManagementServiceImpl.java:687)
[artemis-server-2.0.0.jar:2.0.0]
        ... 30 more

Is there another way to list the Topics destination from a v2.0.x
server and to get a "clean" list of Queues names from a JMS point of
view?

Thanks.

Denis (Author of JMSToolBox on sourceforge)

> Hope that helps.
>
>
> Justin
>
> ----- Original Message -----
> From: "titou10 titou10" <ti...@gmail.com>
> To: users@activemq.apache.org
> Sent: Wednesday, March 22, 2017 2:35:43 PM
> Subject: Re: Artemis 2.0: How to get the list of Queues and Topics from a server? (Fails in 2.0 with v1.5.3 code)
>
> Thanks for your answer
>
>>> how to retrieve the list of Queues and Topics from an Artemis v2.0.0 server?
>>
>> I think you'll be good to just use org.apache.activemq.artemis.api.core.management.ResourceNames.BROKER rather than JMS_SERVER with your existing code.
>
> It will not work...
> Given the v1.5.x doc, JMS_SERVER (="jms.server") is linked to the
> "org.apache.activemq.artemis.api.jms.management.JMSServerControl"
> control class. This class has amongst many other methods, 2 methods
> named "getQueueNames()" and "getTopicNames()"
> This class has been removed from v2.0.0
> I wasn't able to find to what control class the BROKER (="broker")
> value is associated to in v2.0.0...
>
> I was not able to find also if the methods from the JMSServerControl
> that has been removed are available somewhere else in v2.0.x
>
> So the question is still there, how to retrieve the list of topics and
> queues from a v2.0.x Artemis server from a client?
>
> Thanks
>
> Denis (Author of JMSToolBox on sourceforge)

Re: Artemis 2.0: How to get the list of Queues and Topics from a server? (Fails in 2.0 with v1.5.3 code)

Posted by titou10 titou10 <ti...@gmail.com>.
Thanks again for your help

2017-03-22 16:06 GMT-04:00 Justin Bertram <jb...@apache.org>:
> Did you try modifying your code as I recommended?  If so, what was the result?
>
> I modified the "management" example locally as a proof-of-concept and it worked fine.  Here's the code (comments redacted):
>
>          QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
>          Queue managementQueue = ActiveMQJMSClient.createQueue("activemq.management");
>          QueueRequestor requestor = new QueueRequestor(session, managementQueue);
>          connection.start();
>          Message m = session.createMessage();
>          JMSManagementHelper.putAttribute(m, ResourceNames.BROKER, "queueNames");
>          Message reply = requestor.request(m);
>          Object[] queueNames = (Object[]) JMSManagementHelper.getResult(reply);
>          for (Object queueName : queueNames) {
>             System.out.println("Queue name: " + queueName);
>          }
>
> To be clear, org.apache.activemq.artemis.api.core.management.ResourceNames.BROKER essentially links to org.apache.activemq.artemis.api.core.management.ActiveMQServerControl.  Among others, it has methods getQueueNames() and getAddressNames() which should suffice for your purposes.  The idea of a JMS "server" and even a JMS topic was always a thin facade on top of the core implementation.  From a management and configuration perspective this facade has been removed to allow cleaner support for additional protocols (e.g. AMQP, MQTT, STOMP, etc.).
>

I understand, and this is was I was asking for (what features have
been changed/removed deprecated, in this case the JMS management
facade has been removed...)

Yes I did the same test as you in parallel and the getQueueName() does
not fails but it returns the Queues and the Topics mixed (ie
multicast..)
How about Topics, there is no "getTopicNames()"  method in
ActiveMQServerControl and logically causes this exception on the
server...

Caused by: java.lang.IllegalArgumentException: AMQ119068: no getter
method for topicNames
        at org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl.getAttribute(ManagementServiceImpl.java:687)
[artemis-server-2.0.0.jar:2.0.0]
        ... 30 more

Is there another way to list the Topics destination from a v2.0.x
server and to get a "clean" list of Queues names from a JMS point of
view?

Thanks.

Denis (Author of JMSToolBox on sourceforge)

> Hope that helps.
>
>
> Justin
>
> ----- Original Message -----
> From: "titou10 titou10" <ti...@gmail.com>
> To: users@activemq.apache.org
> Sent: Wednesday, March 22, 2017 2:35:43 PM
> Subject: Re: Artemis 2.0: How to get the list of Queues and Topics from a server? (Fails in 2.0 with v1.5.3 code)
>
> Thanks for your answer
>
>>> how to retrieve the list of Queues and Topics from an Artemis v2.0.0 server?
>>
>> I think you'll be good to just use org.apache.activemq.artemis.api.core.management.ResourceNames.BROKER rather than JMS_SERVER with your existing code.
>
> It will not work...
> Given the v1.5.x doc, JMS_SERVER (="jms.server") is linked to the
> "org.apache.activemq.artemis.api.jms.management.JMSServerControl"
> control class. This class has amongst many other methods, 2 methods
> named "getQueueNames()" and "getTopicNames()"
> This class has been removed from v2.0.0
> I wasn't able to find to what control class the BROKER (="broker")
> value is associated to in v2.0.0...
>
> I was not able to find also if the methods from the JMSServerControl
> that has been removed are available somewhere else in v2.0.x
>
> So the question is still there, how to retrieve the list of topics and
> queues from a v2.0.x Artemis server from a client?
>
> Thanks
>
> Denis (Author of JMSToolBox on sourceforge)

Re: Artemis 2.0: How to get the list of Queues and Topics from a server? (Fails in 2.0 with v1.5.3 code)

Posted by Justin Bertram <jb...@apache.org>.
Did you try modifying your code as I recommended?  If so, what was the result?

I modified the "management" example locally as a proof-of-concept and it worked fine.  Here's the code (comments redacted):

         QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
         Queue managementQueue = ActiveMQJMSClient.createQueue("activemq.management");
         QueueRequestor requestor = new QueueRequestor(session, managementQueue);
         connection.start();
         Message m = session.createMessage();
         JMSManagementHelper.putAttribute(m, ResourceNames.BROKER, "queueNames");  
         Message reply = requestor.request(m);
         Object[] queueNames = (Object[]) JMSManagementHelper.getResult(reply);
         for (Object queueName : queueNames) {
            System.out.println("Queue name: " + queueName);
         }

To be clear, org.apache.activemq.artemis.api.core.management.ResourceNames.BROKER essentially links to org.apache.activemq.artemis.api.core.management.ActiveMQServerControl.  Among others, it has methods getQueueNames() and getAddressNames() which should suffice for your purposes.  The idea of a JMS "server" and even a JMS topic was always a thin facade on top of the core implementation.  From a management and configuration perspective this facade has been removed to allow cleaner support for additional protocols (e.g. AMQP, MQTT, STOMP, etc.).

Hope that helps.


Justin

----- Original Message -----
From: "titou10 titou10" <ti...@gmail.com>
To: users@activemq.apache.org
Sent: Wednesday, March 22, 2017 2:35:43 PM
Subject: Re: Artemis 2.0: How to get the list of Queues and Topics from a server? (Fails in 2.0 with v1.5.3 code)

Thanks for your answer

>> how to retrieve the list of Queues and Topics from an Artemis v2.0.0 server?
>
> I think you'll be good to just use org.apache.activemq.artemis.api.core.management.ResourceNames.BROKER rather than JMS_SERVER with your existing code.

It will not work...
Given the v1.5.x doc, JMS_SERVER (="jms.server") is linked to the
"org.apache.activemq.artemis.api.jms.management.JMSServerControl"
control class. This class has amongst many other methods, 2 methods
named "getQueueNames()" and "getTopicNames()"
This class has been removed from v2.0.0
I wasn't able to find to what control class the BROKER (="broker")
value is associated to in v2.0.0...

I was not able to find also if the methods from the JMSServerControl
that has been removed are available somewhere else in v2.0.x

So the question is still there, how to retrieve the list of topics and
queues from a v2.0.x Artemis server from a client?

Thanks

Denis (Author of JMSToolBox on sourceforge)

Re: Artemis 2.0: How to get the list of Queues and Topics from a server? (Fails in 2.0 with v1.5.3 code)

Posted by titou10 titou10 <ti...@gmail.com>.
Thanks for your answer

>> how to retrieve the list of Queues and Topics from an Artemis v2.0.0 server?
>
> I think you'll be good to just use org.apache.activemq.artemis.api.core.management.ResourceNames.BROKER rather than JMS_SERVER with your existing code.

It will not work...
Given the v1.5.x doc, JMS_SERVER (="jms.server") is linked to the
"org.apache.activemq.artemis.api.jms.management.JMSServerControl"
control class. This class has amongst many other methods, 2 methods
named "getQueueNames()" and "getTopicNames()"
This class has been removed from v2.0.0
I wasn't able to find to what control class the BROKER (="broker")
value is associated to in v2.0.0...

I was not able to find also if the methods from the JMSServerControl
that has been removed are available somewhere else in v2.0.x

So the question is still there, how to retrieve the list of topics and
queues from a v2.0.x Artemis server from a client?

Thanks

Denis (Author of JMSToolBox on sourceforge)

Re: Artemis 2.0: How to get the list of Queues and Topics from a server? (Fails in 2.0 with v1.5.3 code)

Posted by Justin Bertram <jb...@apache.org>.
> how to retrieve the list of Queues and Topics from an Artemis v2.0.0 server?

I think you'll be good to just use org.apache.activemq.artemis.api.core.management.ResourceNames.BROKER rather than JMS_SERVER with your existing code.


> is there a migration/upgrade guide to upgrade from 1.5.x to 2.0.x?

There isn't a migration guide for 1.5.x to 2.0.x as such, but the documentation shipped with 2.0 should be up to date (although a few things might have been missed).


> or a least is there a list of "deprecated/removed/changed" features from v1.5.x to 2.0.x?

The release notes [1] is the closest thing you'll find.


Justin

[1] https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12315920&version=12338813

----- Original Message -----
From: "titou10 titou10" <ti...@gmail.com>
To: users@activemq.apache.org
Sent: Wednesday, March 22, 2017 1:01:31 PM
Subject: Artemis 2.0: How to get the list of Queues and Topics from a server? (Fails in 2.0 with v1.5.3 code)

Hi,
With Artemis v1.5.3, to retrieve the list of queues and topics, I was
using this code (inspired from the example)

Queue managementQueue = ActiveMQJMSClient.createQueue("activemq.management");
Session sessionJMS = jmsConnection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
QueueRequestor requestorJMS = new QueueRequestor((QueueSession)
sessionJMS, managementQueue);
Message m = sessionJMS.createMessage();
JMSManagementHelper.putAttribute(m, ResourceNames.JMS_SERVER,
"queueNames"); // "topicNames" for topics
Message r = requestorJMS.request(m);
Object q = JMSManagementHelper.getResult(r);
...

If I run this code from a client with the v1.5.3 jars to a v2.0.0 server I got:
An exception on the server:

Caused by: java.lang.IllegalArgumentException: AMQ119067: Cannot find
resource with name jms.server
        at org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl.getAttribute(ManagementServiceImpl.java:675)
[artemis-server-2.0.0.jar:2.0.0]
        ... 30 more

And an exception on the client:
java.lang.IndexOutOfBoundsException: readerIndex(22) + length(98)
exceeds writerIndex(116): UnpooledDuplicatedByteBuf(ridx: 22, widx:
116, cap: 451, unwrapped: UnpooledUnsafeHeapByteBuf(ridx: 439, widx:
451, cap: 451))
    at io.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1395)
    at io.netty.buffer.AbstractByteBuf.checkReadableBytes(AbstractByteBuf.java:1389)
    at io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:850)
    at io.netty.buffer.AbstractByteBuf.readBytes(AbstractByteBuf.java:858)
    at io.netty.buffer.WrappedByteBuf.readBytes(WrappedByteBuf.java:649)
    at org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper.readSimpleStringInternal(ChannelBufferWrapper.java:93)
    at org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper.readNullableSimpleString(ChannelBufferWrapper.java:73)
    at org.apache.activemq.artemis.api.core.management.ManagementHelper.getResults(ManagementHelper.java:196)
    at org.apache.activemq.artemis.api.core.management.ManagementHelper.getResult(ManagementHelper.java:224)
    at org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.getResult(JMSManagementHelper.java:149)
    at org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.getResult(JMSManagementHelper.java:139)

I tried to update the client jars to v2.0.0. In v1.5.3, the
"ResourceNames.JMS_SERVER" variable exists with value "jms.server", in
v2.0.0, The ResourceName has benne totally changed and no "JMS_SERVER"
variable anymore (and no "SERVER" lookalike variable..).

So the question are
- how to retrieve the list of Queues and Topics from an Artemis v2.0.0 server?
- is there a migration/upgrade guide to upgrade from 1.5.x to 2.0.x?
- or a least is there a list of "deprecated/removed/changed" features
from v1.5.x to 2.0.x?

Thanks

Denis (Author of JMSToolBox on sourceforge)