Hi Arnaud/Ted/Carl/Rafael/Rajith,
I have some questions on "Schema Response" message. (I am trying to fetch
the management schema for classes broker knows).
First, how do we decode the "Schema-hash" field from the AM1s
("Schema-Response" method).
Rafael mentioned last night that AbastractDecoder does not know it so we
added another method i.e. readBin128() in AbstractDecoder.java (under
org.apache.qpidity.transport.codec) for decoding 16 bytes of opaque binary
data. It produced some unknown characters (e.g. output: Schema hash is:
�\�W�p�`؞??V�?) as schema hash is
an md5 digest and md5 hashes are binary data so in this case I was
converting to a string like this System.out.println("Schema hash is " + new
String(decoder.readBin128()));
So I converted this non printable characters to hex (with Rafael's advice
just to get rid off these some unknown character) by using
org.apache.qpidity.transport.util.Functions.str(decoder.readBin128())
method. so the schema hash printed as (Schema is:
"\x85\x5c\xea\x96W\xe3p\xcc`\xd8\x9e\x1a\x08V\xa4\x0e")...
1) I want to see the Schema hash in the correct way ? How would I print it?
-----
As i was ignoring what i was getting for "schema hash" field (hax value)
and moving on to next field... i.e. propCnt (properties content), i am
doing this
int propCnt = decoder.readUint16();
System.out.println("Property content: " + propCnt);
for( int i = 0; i < propCnt; i++ )
{
Map<String,Object> map = decoder.readMap();
printMap(map);
}
public void printMap(Map mapnew)
{
Set s=mapnew.entrySet();
Iterator it=s.iterator();
for (Iterator iterator = s.iterator(); iterator.hasNext();) {
Object object = (Object) iterator.next();
System.out.println(object.toString());
}
BUT, getting an exception here
A
M
1
s
15
Package Name: qpid
Class Name: vhost
Schema is: "\x85\x5c\xea\x96W\xe3p\xcc`\xd8\x9e\x1a\x08V\xa4\x0e"
Property content: 2
code is : 6
Error reading messagejava.lang.IllegalArgumentException: unknown code: 6
at
org.apache.qpidity.transport.codec.AbstractDecoder.getType(AbstractDecoder.java:302)
at
org.apache.qpidity.transport.codec.AbstractDecoder.readMap(AbstractDecoder.java:253)
at apache.qpid.client.ListenerReply.onMessage(ListenerReply.java:109)
at
org.apache.qpidity.nclient.util.MessagePartListenerAdapter.messageReceived(MessagePartListenerAdapter.java:56)
at
org.apache.qpidity.nclient.impl.ClientSessionDelegate.data(ClientSessionDelegate.java:41)
at
org.apache.qpidity.transport.SessionDelegate.data(SessionDelegate.java:1)
at org.apache.qpidity.transport.Data.delegate(Data.java:78)
at org.apache.qpidity.transport.Channel.data(Channel.java:114)
at org.apache.qpidity.transport.Channel.data(Channel.java:1)
at org.apache.qpidity.transport.Data.delegate(Data.java:78)
at org.apache.qpidity.transport.Channel.received(Channel.java:75)
at org.apache.qpidity.transport.Connection.received(Connection.java:84)
at org.apache.qpidity.transport.Connection.received(Connection.java:1)
at
org.apache.qpidity.transport.network.Assembler.emit(Assembler.java:92)
at
org.apache.qpidity.transport.network.Assembler.emit(Assembler.java:97)
at
org.apache.qpidity.transport.network.Assembler.frame(Assembler.java:125)
at org.apache.qpidity.transport.network.Frame.delegate(Frame.java:145)
at
org.apache.qpidity.transport.network.Assembler.received(Assembler.java:102)
at
org.apache.qpidity.transport.network.Assembler.received(Assembler.java:1)
at
org.apache.qpidity.transport.network.InputHandler.frame(InputHandler.java:103)
at
org.apache.qpidity.transport.network.InputHandler.next(InputHandler.java:204)
at
org.apache.qpidity.transport.network.InputHandler.received(InputHandler.java:116)
at
org.apache.qpidity.transport.network.InputHandler.received(InputHandler.java:1)
at
org.apache.qpidity.transport.network.mina.MinaHandler.messageReceived(MinaHandler.java:87)
at
org.apache.mina.common.support.AbstractIoFilterChain$TailFilter.messageReceived(AbstractIoFilterChain.java:703)
at
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:362)
at
org.apache.mina.common.support.AbstractIoFilterChain.access$1200(AbstractIoFilterChain.java:54)
at
org.apache.mina.common.support.AbstractIoFilterChain$EntryImpl$1.messageReceived(AbstractIoFilterChain.java:800)
at
org.apache.mina.common.support.AbstractIoFilterChain$HeadFilter.messageReceived(AbstractIoFilterChain.java:617)
at
org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageReceived(AbstractIoFilterChain.java:362)
at
org.apache.mina.common.support.AbstractIoFilterChain.fireMessageReceived(AbstractIoFilterChain.java:353)
at
org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.java:281)
at
org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcessor.java:241)
at
org.apache.mina.transport.socket.nio.SocketIoProcessor.access$500(SocketIoProcessor.java:44)
at
org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProcessor.java:559)
at
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:43)
at java.lang.Thread.run(Thread.java:619)
I have just an idea why it is raising but how to mitigate it I dont know.
2) How to fix it? Can anyone help me?
I am attaching my TEST code (two java programs) here for your consideration:
SendMessage.java sends the "Class Query" and "Schema Request" to the broker
ListenerReply.java listens messages on "reply" queue * Please note: Before
these two programs, I created two Queues (management and reply) and bound
them on qpid.exchange and amq.direct exchanges respectively. I am using the
Qpid C++ broker.
Look forward to hearing from you.
Thank you,
BR,
Rahul
On Jun 23 2008, Ted Ross wrote:
[EMAIL PROTECTED] wrote:
> Hi Arnaud,
>
> Thanks for your help. Your sample codes are really very useful to get
> an idea. At this moment, I can fetch the following information
> (decoded) from the broker by "management" queue bound on
> "qpid.management" exchange.
>
>
> A
> M
> 1
> c
> 0
> Package Name: qpid
> Class Name: broker
> -6506066772830834859
> 3980601858483200060
> Current Sample: Wed Jul 06 22:54:31 CEST 38476878
> Object Created: Sat Jul 24 16:10:25 CEST 38476877
> Object Deleted: Thu Jan 01 01:00:00 CET 1970
> 16777218
> --------
> A
> M
> 1
> c
> 0
> Package Name: qpid
> Class Name: vhost
> -8836930437367238452
> 6978501457256817678
> Current Sample: Wed Jul 06 22:55:54 CEST 38476878
> Object Created: Sat Jul 24 16:10:31 CEST 38476877
> Object Deleted: Thu Jan 01 01:00:00 CET 1970
> 16777219
> -------------
>
> A
> M
> 1
> c
> 0
> Package Name: qpid
> Class Name: exchange
> -5418781513850411724
> -4895665811244006470
> Current Sample: Wed Jul 06 22:57:02 CEST 38476878
> Object Created: Sat Jul 24 16:11:00 CEST 38476877
> Object Deleted: Thu Jan 01 01:00:00 CET 1970
> 33554433
> ------------
> A
> M
> 1
> c
> 0
> Package Name: qpid
> Class Name: client
> 2274936829591414069
> 7716666671830073968
> Current Sample: Wed Jul 06 23:10:41 CEST 38476878
> Object Created: Thu Oct 14 02:14:24 CEST 38476877
> Object Deleted: Thu Jan 01 01:00:00 CET 1970
> 19421773476921347
> ---------------
> A
> M
> 1
> c
> 0
> Package Name: qpid
> Class Name: session
> 7627530833415044037
> 7647849998445955049
> Current Sample: Wed Jul 06 23:12:52 CEST 38476878
> Object Created: Fri Oct 15 13:01:40 CEST 38476877
> Object Deleted: Thu Jan 01 01:00:00 CET 1970
> 19421773476921348
> --------------
> A
> M
> 1
> i
> 0
> Package Name: qpid
> Class Name: queue
> 1347274480851610151
> 7548280486574577882
> Current Sample: Wed Jul 06 23:16:10 CEST 38476878
> Object Created: Fri Oct 15 13:03:14 CEST 38476877
> Object Deleted: Thu Jan 01 01:00:00 CET 1970
> 19421773476921349
> ------------
> A
> M
> 1
> h
> 0
> Sun Dec 13 05:38:09 CET 38476882
> -------------------------------------
>
> I am wondering if you can give me a sample example to send message to
> broker so that I can get the schema from broker. I have another queue
> called "reply" bound on "amq.direct" with the routing key "reply" but
> dont know how to get the management schema in it (cannt find the
> example for sending the message to broker to fetch the management
> information). I have read the qpid management notes and now know how
> to fetch the schema (in theory) but it will be nice to see the sample.
>
> It will also be nice if you can explain a little about management
> interface you mentioned.
>
> Also, if you can let me know where I can put my work?
> Just to update you, I started working on a ppt file and on
> documentation for this project.
>
>
> Thanks in advance.
>
>
> Best Regards,
> Rahul
>
Rahul,
To get the schema from the broker, there are three protocol exchanges
you need to execute:
1) Request the list of schema packages.
2) For each package (or the package of interest), request the list of
classes.
3) For each class (or the class of interest), request the schema details.
To send protocol messages to the management broker, create the message
with AMQP types via the Java encoder/decoder, then send them to the
"qpid.management" exchange using "agent" as the routing key.
Replies will be transmitted according the the key in the replyTo field
of the message. Make sure the replyTo attribute is set on the message
(setJMSReplyTo) to amq.direct/reply.
Here are the protocol references (see
http://cwiki.apache.org/confluence/display/qpid/Management+Design+notes
for protocol details):
1) Request packages by sending a "Package Query" message. You will
receive a "Package Indication" message on your reply queue for each
package known to the broker. The "qpid" package contains classes for
the broker itself.
2) Request classes-per-package by sending a "Class Query" message. You
will receive a "Class Indication" message for each class in the
package. Note that a class is identified by the following tuple:
(package-name, class-name, class-hash). The hash is included because
there may be more than one version of the schema for a particular class.
3) To request the schema details for a class, send a "Schema Request"
message to the broker. A "Schema Response" message will be sent in
reply which contains the details of the class schema.
If you have further questions, don't hesitate to ask.
Regards,
-Ted
?