It seems to work well for me. I'll run a full build and will create a PR. 2017-05-19 8:03 GMT+02:00 Guillaume Nodet <gno...@apache.org>:
> I'm enhancing a layer in OSGi to support Artemis, and I'd like to avoid > adding package dependencies. > That's why I'm using the connection's classloader to load the needed > class, as it's not available from the class which defines this code. > > To refine my question further: could the reply be typed as a text message > rather than not typed ? This would allow retrieving the json body as a > string. > Basically, I'm proposing the following patch: > > *--- > a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java* > > *+++ > b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java* > > @@ -370,6 +370,7 @@ public class ManagementServiceImpl implements > ManagementService { > > message = message.toCore(); > > // a reply message is sent with the result stored in the message > body. > > CoreMessage reply = new CoreMessage(storageManager.generateID(), > 512); > > + reply.setType(Message.TEXT_TYPE); > > reply.setReplyTo(message.getReplyTo()); > > > > String resourceName = message.getStringProperty( > ManagementHelper.HDR_RESOURCE_NAME); > > > 2017-05-19 3:10 GMT+02:00 Clebert Suconic <clebert.suco...@gmail.com>: > >> @Tim Bain: yes.. Artemis from what I see on the class Names (I also >> spoke to him gnodet on the IRC channel earlier today). >> >> @gnodet: I am not understanding why you would need to use reflection. >> You can just simply use JMSManagementHelper directly. they are all >> static methods... >> >> >> This example here, part of distribution under >> examples/features/standard/management shows how it was intended to be >> used: >> >> >> https://github.com/apache/activemq-artemis/blob/master/examp >> les/features/standard/management/src/main/java/org/apache/ac >> tivemq/artemis/jms/example/ManagementExample.java >> >> >> >> Maybe I"m misunderstanding your question? >> >> On Thu, May 18, 2017 at 6:23 PM, Guillaume Nodet <gno...@apache.org> >> wrote: >> > I'm trying do perform management operation with pure JMS api. >> > To retrieve the list of queues, I'm currently using the following code: >> > >> > QueueSession session = ((QueueConnection) >> > connection).createQueueSession(false, Session.AUTO_ACKNOWLEDGE); >> > Queue managementQueue = session.createQueue("activemq.management"); >> > QueueRequestor requestor = new QueueRequestor(session, managementQueue); >> > connection.start(); >> > TextMessage m = session.createTextMessage(); >> > m.setStringProperty("_AMQ_ResourceName", "broker"); >> > m.setStringProperty("_AMQ_OperationName", "getQueueNames"); >> > m.setText("[\"" + routing + "\"]"); >> > Message reply = requestor.request(m); >> > Class<?> mgmtHelperClass = >> > connection.getClass().getClassLoader().loadClass("org.apache >> .activemq.artemis.api.jms.management.JMSManagementHelper"); >> > Method getResultsMethod = mgmtHelperClass.getMethod("getResults", >> > Message.class); >> > Object[] results = (Object[]) getResultsMethod.invoke(null, reply); >> > List<String> names = new ArrayList<>(); >> > for (Object o : (Object[]) (results[0])) { >> > names.add(o.toString()); >> > } >> > return names; >> > >> > >> > It works, but I think I should not have to use reflection to access the >> > result message, hence the use of reflection to access the >> > JMSManagementHelper methods. >> > It seems to me the reply should be of type TextMessage, but it's >> currently >> > untyped, so I can't use TextMessage#getText to retrieve the json result, >> > and I can't find a way to retrieve it another way. >> > Do I miss anything ? >> > >> > -- >> > ------------------------ >> > Guillaume Nodet >> >> >> >> -- >> Clebert Suconic >> > > > > -- > ------------------------ > Guillaume Nodet > > -- ------------------------ Guillaume Nodet