You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by fadams <fr...@blueyonder.co.uk> on 2011/07/10 13:05:12 UTC

QMF2 protocol query only seems to support OBJECT target

Hello,
I've been writing some code playing with QMF2 in JMS I've happily queried
with the OBJECT target

	public List<QMFConsoleData> getObjects(String className) {
		try {
			MapMessage request = requestResponseSession.createMapMessage();
			request.setJMSReplyTo(responseQueue);
			request.setStringProperty("x-amqp-0-10.app-id", "qmf2");
			request.setStringProperty("qmf.opcode", "_query_request");

			request.setString("_what", "OBJECT");
			request.setObject("_schema_id", new SchemaClassId(null, className, null,
null).mapEncode());

			requestProducer.send(request);
			Message response = responseConsumer.receive(10*1000);

			QueryResult result = new QueryResult(this,
buildMapListFromMessage(response));
			return result.getResults();
		} catch (QMFException e) {
			System.out.println("QMFException: " + e.getMessage());
			return new ArrayList<QMFConsoleData>();
		} catch (JMSException e) {
			return new ArrayList<QMFConsoleData>();
		}
	}

but when I play around with other values in "_what" the result ends up
sending an exception with text that implies unsupported target

I've tried 

QMF_QUERY_TARGET := 'SCHEMA_ID' |
                      'SCHEMA'    |
                      'OBJECT_ID' |
                      'OBJECT'

but everything other than OBJECT fails so it doesn't look like I can query
for schema information.

Is this correct or have I missed something? To be fair the contents of the
_values Map in the Map returned by the OBJECT query will give most of the
schema info, but it would be good to be able to get hold of the method names
for an object as well as the properties.

BTW in case it hasn't escaped your notice from the class names in the code
snippet above I've been getting a bit carried away and what started out as a
bit of a play seems to be turning into an implementation for a good chunk of
the QMF2 API for Java. Has anyone actually implemented this fully? I can't
see it in the download, only the (broken) QMF1 classes, so I'm thinking it's
a worthwhile exercise to write this. I've nearly got a Java port of
qpid-config working - pointless, but fun......


On a related note could anyone let me know how to query for Agents. My basic
Console class currently only talks to the broker Agent via
"qmf.default.direct/broker". I'm guessing querying for agents will be by
sending a message to a topic/subject - could someone suggest the structure
of the message and Address.

Cheers
Fraser









--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/QMF2-protocol-query-only-seems-to-support-OBJECT-target-tp6567622p6567622.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: QMF2 protocol query only seems to support OBJECT target

Posted by Ken Giusti <kg...@redhat.com>.
Hi,

There are a couple of directories related to QMF - here's a quick summary:

qpid/cpp/src/qpid/management - this is the implementation of the QMF agent in the QPID broker itself.  It is used to manage the broker.  This supports QMFv2 format object queries and method calls, but schema data is still exposed in the QMFv1 binary packed format.   You want to look at this code when you're trying to manage the broker.

qpid/cpp/src/qpid/agent - generic QMF agent library for use with non-broker applications.  This is the code you'll use if you are creating an application that will act as an "agent" (that is, a QMF-managed entity).  You embed this code into your application, and can then use QMF to manage it.  This is -not- used to manage the qpid broker (that stuffs in ../management).

qpid/cpp/src/qpid/console - generic code to build a management application to talk QMF to an agent.  

qpid/cpp/include/qmf/ - the include files (api) for console/agent libraries. We also generate wrapper api's for various languages from these headers (python, ruby).  

> On a related note could anyone let me know how to query for Agents. My basic
> Console class currently only talks to the broker Agent via
> "qmf.default.direct/broker". I'm guessing querying for agents will be by
> sending a message to a topic/subject - could someone suggest the structure
> of the message and Address.

Depends on which version agent (QMFv1 or QMFv2) you want.

The broker agent maintains a list of all known v1 agents that are connected to it.  You can query for them like you'd query for any other object on the broker, except you'd need to specify "agent" as the "_class_name" value in the "_schema_id" map.

"_schema_id": {"_class_name": "agent"}

That would return all known v1 agents.

v2 is a bit more difficult, and that's where the library code comes in handy.  Turns out that having the broker maintain the list of all known agents resulted in a scalability bottleneck.  As an alternative, v2 requires consoles to register for "heartbeat" messages from agents, rather than querying the broker.

The library code maintains a database of agents by listening for these heartbeat messages, timing out old heartbeats, etc.

A console can request that all agents identify themselves manually - this is done by sending a "broadcast" "_agent_locate_request" message from the console.  To do this, send a QMFv2 message to "qmf.default.topic/console.request.agent_locate"
 with {'qmf.opcode':'_agent_locate_request'}.

Agent's will reply with a heartbeat message - see agent/ManagementAgentImpl.cpp for the format of a heartbeat message.

A good example of a QMFv2 console - and some code that highlights all of the console logic above - can be seen in the python QMF console: qpid/extras/qmf/src/py/qmf/console.py.

-K

----- Original Message -----
> On 07/17/2011 10:37 AM, fadams wrote:
> > Hi again Gordon,
> > I've taken to looking through the C++ broker code to figure some of
> > this out
> > and I'm afraid it's making my head EXPLODE :-)
> >
> > So I've found ./cpp/src/qpid/management/ManagementAgent.cpp and the
> > method
> > "handleGetQueryLH" does indeed say "Currently we only support OBJECT
> > queries".
> >
> > handleGetQueryLH seems to be dispatched from dispatchAgentCommandLH
> > which in
> > turn is called from dispatchCommand which seems to be called from
> > specialised Direct& Topic Exchanges
> >
> > So far so good, but I also found
> > ./cpp/src/qpid/agent/ManagementAgentImpl.cpp - looking at the
> > headers this
> > *appears* to inherit from ManagementAgent - though I'm not clear
> > what
> > behaviours it inherits..
> >
> > This has a method handleGetQuery which has a lot of similarities
> > with
> > handleGetQueryLH (though this seems to support "SCHEMA_ID" at least
> > partially) this seems to be dispatched from a received method,
> > though I
> > couldn't figure out what calls that.
> >
> >
> > So what's the relationship between ManagementAgent and
> > ManagementAgentImpl?
> > I grepped the code base and ManagementAgentImpl seems to be called
> > by as a
> > Singleton but the getInstance doesn't seem to be called anywhere
> > except some
> > testagent.cpp.
> >
> > Have I missed something or should I just focus on the
> > ./src/qpid/management
> > directory...
> 
> I'm not the expert on the QMF related code, however two points will
> probably help explain the bigger picture a little.
> 
> First, there are two versions of the QMF protocol. Version 1 had a
> custom message encoding scheme and really required that you use it
> through an API. Version 2 was designed to be easier to use as a
> messaging protocol in its own right, with map- and list- encodings for
> messages and simpler interactions.
> 
> The second point is that the QMF work has had a broader goal in mind
> than smply managing the broker. It was designed to be able to be a
> general management infrastructure. Therefore it is possible to
> implement
> arbitrary management agents, each with their own schemas and interact
> with them using QMF layered on AMQP.
> 
> I believe the qpid::agent code is an old API for QMFv1 based
> management
> agents (apart from the broker),but perhaps Ted or Ken can correct me
> on
> this.
> 
> At present I believe that the qpid::management code is essentially the
> brokers own internal management agent. However in the QMFv1 protocol
> the
> broker was a more explicit intermediary in all agent communications so
> the distinction there is a little blurred. The code also has two
> parallel implementations for the two different versions and as you
> noted, the second version seems not yet to support querying of the
> schema.
> 
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project: http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: QMF2 protocol query only seems to support OBJECT target

Posted by Gordon Sim <gs...@redhat.com>.
On 07/17/2011 10:37 AM, fadams wrote:
> Hi again Gordon,
> I've taken to looking through the C++ broker code to figure some of this out
> and I'm afraid it's making my head EXPLODE :-)
>
> So I've found ./cpp/src/qpid/management/ManagementAgent.cpp and the method
> "handleGetQueryLH" does indeed say "Currently we only support OBJECT
> queries".
>
> handleGetQueryLH seems to be dispatched from dispatchAgentCommandLH which in
> turn is called from dispatchCommand which seems to be called from
> specialised Direct&  Topic Exchanges
>
> So far so good, but I also found
> ./cpp/src/qpid/agent/ManagementAgentImpl.cpp - looking at the headers this
> *appears* to inherit from ManagementAgent - though I'm not clear what
> behaviours it inherits..
>
> This has a method handleGetQuery which has a lot of similarities with
> handleGetQueryLH (though this seems to support "SCHEMA_ID" at least
> partially) this seems to be dispatched from a received method, though I
> couldn't figure out what calls that.
>
>
> So what's the relationship between ManagementAgent and ManagementAgentImpl?
> I grepped the code base and ManagementAgentImpl seems to be called by as a
> Singleton but the getInstance doesn't seem to be called anywhere except some
> testagent.cpp.
>
> Have I missed something or should I just focus on the ./src/qpid/management
> directory...

I'm not the expert on the QMF related code, however two points will 
probably help explain the bigger picture a little.

First, there are two versions of the QMF protocol. Version 1 had a 
custom message encoding scheme and really required that you use it 
through an API. Version 2 was designed to be easier to use as a 
messaging protocol in its own right, with map- and list- encodings for 
messages and simpler interactions.

The second point is that the QMF work has had a broader goal in mind 
than smply managing the broker. It was designed to be able to be a 
general management infrastructure. Therefore it is possible to implement 
arbitrary management agents, each with their own schemas and interact 
with them using QMF layered on AMQP.

I believe the qpid::agent code is an old API for QMFv1 based management 
agents (apart from the broker),but perhaps Ted or Ken can correct me on 
this.

At present I believe that the qpid::management code is essentially the 
brokers own internal management agent. However in the QMFv1 protocol the 
broker was a more explicit intermediary in all agent communications so 
the distinction there is a little blurred. The code also has two 
parallel implementations for the two different versions and as you 
noted, the second version seems not yet to support querying of the schema.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: QMF2 protocol query only seems to support OBJECT target

Posted by fadams <fr...@blueyonder.co.uk>.
Hi again Gordon,
I've taken to looking through the C++ broker code to figure some of this out
and I'm afraid it's making my head EXPLODE :-)

So I've found ./cpp/src/qpid/management/ManagementAgent.cpp and the method
"handleGetQueryLH" does indeed say "Currently we only support OBJECT
queries".

handleGetQueryLH seems to be dispatched from dispatchAgentCommandLH which in
turn is called from dispatchCommand which seems to be called from
specialised Direct & Topic Exchanges

So far so good, but I also found
./cpp/src/qpid/agent/ManagementAgentImpl.cpp - looking at the headers this
*appears* to inherit from ManagementAgent - though I'm not clear what
behaviours it inherits..

This has a method handleGetQuery which has a lot of similarities with
handleGetQueryLH (though this seems to support "SCHEMA_ID" at least
partially) this seems to be dispatched from a received method, though I
couldn't figure out what calls that.


So what's the relationship between ManagementAgent and ManagementAgentImpl?
I grepped the code base and ManagementAgentImpl seems to be called by as a
Singleton but the getInstance doesn't seem to be called anywhere except some
testagent.cpp.

Have I missed something or should I just focus on the ./src/qpid/management
directory...

Cheers
Fraser




--
View this message in context: http://apache-qpid-users.2158936.n2.nabble.com/QMF2-protocol-query-only-seems-to-support-OBJECT-target-tp6567622p6591528.html
Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: QMF2 protocol query only seems to support OBJECT target

Posted by Fraser Adams <fr...@blueyonder.co.uk>.
Hi All,
As an update to this I've just raised a Jira to cover this and added a 
patch to support SCHEMA_ID, SCHEMA and OBJECT_ID queries.

https://issues.apache.org/jira/browse/QPID-3696

I've tested it out using my Java QMF2 code.

I hope this is useful.

Regards,
Frase


Gordon Sim wrote:
> On 07/10/2011 12:05 PM, fadams wrote:
>> when I play around with other values in "_what" the result ends up
>> sending an exception with text that implies unsupported target
>>
>> I've tried
>>
>> QMF_QUERY_TARGET := 'SCHEMA_ID' |
>>                        'SCHEMA'    |
>>                        'OBJECT_ID' |
>>                        'OBJECT'
>>
>> but everything other than OBJECT fails so it doesn't look like I can 
>> query
>> for schema information.
>>
>> Is this correct or have I missed something?
>
> Looking at the code on the broker side it does indeed appear that 
> schema requests are only currently implemented for QMFv1.
>
>> To be fair the contents of the
>> _values Map in the Map returned by the OBJECT query will give most of 
>> the
>> schema info, but it would be good to be able to get hold of the 
>> method names
>> for an object as well as the properties.
>
> Yes, seems reasonable.
>
>> BTW in case it hasn't escaped your notice from the class names in the 
>> code
>> snippet above I've been getting a bit carried away and what started 
>> out as a
>> bit of a play seems to be turning into an implementation for a good 
>> chunk of
>> the QMF2 API for Java. Has anyone actually implemented this fully? I 
>> can't
>> see it in the download, only the (broken) QMF1 classes, so I'm 
>> thinking it's
>> a worthwhile exercise to write this. I've nearly got a Java port of
>> qpid-config working - pointless, but fun......
>>
>>
>> On a related note could anyone let me know how to query for Agents. 
>> My basic
>> Console class currently only talks to the broker Agent via
>> "qmf.default.direct/broker". I'm guessing querying for agents will be by
>> sending a message to a topic/subject - could someone suggest the 
>> structure
>> of the message and Address.
>
> I'd have to defer to the experts on that one.
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: QMF2 protocol query only seems to support OBJECT target

Posted by Gordon Sim <gs...@redhat.com>.
On 07/10/2011 12:05 PM, fadams wrote:
> when I play around with other values in "_what" the result ends up
> sending an exception with text that implies unsupported target
>
> I've tried
>
> QMF_QUERY_TARGET := 'SCHEMA_ID' |
>                        'SCHEMA'    |
>                        'OBJECT_ID' |
>                        'OBJECT'
>
> but everything other than OBJECT fails so it doesn't look like I can query
> for schema information.
>
> Is this correct or have I missed something?

Looking at the code on the broker side it does indeed appear that schema 
requests are only currently implemented for QMFv1.

> To be fair the contents of the
> _values Map in the Map returned by the OBJECT query will give most of the
> schema info, but it would be good to be able to get hold of the method names
> for an object as well as the properties.

Yes, seems reasonable.

> BTW in case it hasn't escaped your notice from the class names in the code
> snippet above I've been getting a bit carried away and what started out as a
> bit of a play seems to be turning into an implementation for a good chunk of
> the QMF2 API for Java. Has anyone actually implemented this fully? I can't
> see it in the download, only the (broken) QMF1 classes, so I'm thinking it's
> a worthwhile exercise to write this. I've nearly got a Java port of
> qpid-config working - pointless, but fun......
>
>
> On a related note could anyone let me know how to query for Agents. My basic
> Console class currently only talks to the broker Agent via
> "qmf.default.direct/broker". I'm guessing querying for agents will be by
> sending a message to a topic/subject - could someone suggest the structure
> of the message and Address.

I'd have to defer to the experts on that one.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org