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
On Jun 19 2008, Arnaud Simon wrote:
Hi Rahul,
The format that is used is the AMQP one as described here:
http://cwiki.apache.org/qpid/management-design-notes.html
I would suggest you reuse the existing java Encoder/Decoder. You can do
something like:
==== code sample ======
public class ManagementDecoder extends AbstractDecoder
{
private final ByteBuffer _buf;
public ManagementDecoder(ByteBuffer buf)
{
_buf = buf;
}
....
==== end of code sample ======
Then when receiving a message you need to decode it based on its type.
For example:
==== code sample ======
ManagementDecoder decoder = new ManagementDecoder(buf);
.....
pn = decoder.readStr8();
cn = decoder.readStr8();
...
int propCnt = decoder.readUint16();
for( int i = 0; i < propCnt; i++ )
{
Map<String,Object> map = decoder.readMap();
.....
==== end of code sample ======
I would also suggest we define a management interface (you can look at
the python one --- qpid/python/qpid/management.py) that we can use to
access to the managed packages/classes/objects...
Arnaud
On Thu, 2008-06-19 at 12:02 +0100, [EMAIL PROTECTED] wrote:
> Hi,
>
> I did again with Maven and this time it builds all the classes... So
> after creating and binding both the queues "reply" and "management". I
> am trying to fetch the management information (all what broker knows)
> from management queue and getting some encoded messages (i believe).
> for instance,
>
> --------------
> Message: AM1h
> Message: AM1c
> Message: AM1c
>
> Message: AM1c
> Message: AM1c
> �ú�h�XW*��h�_�
> amq.directdirect
> Message: AM1i
> �ú�h�XXCq�h�_�
> Message: AM1i
> �ú�h�XYIY�h�_�xR
> Message: AM1i
> �ú�h�XZH��h�_�xR
> Message: AM1i
> �ú�h�X[Q��h�_ì�
> amq.fanoutfanout
> Message: AM1i
> �ú�h�X\O�h�_ì�
> Message: AM1i
> �ú�h�X]P��h�_���
> Message: AM1i
> �ú�h�X^N��h�_���
> Message: AM1c
> �ú�h�X_OP�h�_Ãâ¢V
> Message: AM1i
> �ú�h�X`Ke�h�_Ãâ¢V
> Message: AM1c
> �ú�h�XaK��h�_�v
> Message: AM1i
> �ú�h�XbF��h�_�v
> ....
> ...
>
> java program which is retrieving this above mentioned encoded
> management information from management queue is :
>
> package apache.qpid.client;
>
> import java.nio.ByteBuffer;
> import org.apache.qpidity.api.Message;
> import org.apache.qpidity.nclient.Client;
> import org.apache.qpidity.nclient.Connection;
> import org.apache.qpidity.nclient.Session;
> import org.apache.qpidity.nclient.util.MessageListener;
> import org.apache.qpidity.nclient.util.MessagePartListenerAdapter;
> import org.apache.qpidity.transport.MessageCreditUnit;
>
> /**
> * This listens messages from management queue
> */
> // TODO: decode these messages
>
> public class Listener implements MessageListener
> {
> // implementation of onMessage
> public void onMessage(Message m)
> {
> String data = null;
>
> try
> {
> ByteBuffer buf = m.readData();
> byte[] b = new byte[buf.remaining()];
> buf.get(b);
> data = new String(b);
> }
> catch(Exception e)
> {
> System.out.print("Error reading message");
> e.printStackTrace();
> }
> System.out.println("Message: " + data);
> }
> public static void main(String[] args)
> {
> // Create connection
> Connection con = Client.createConnection();
> try
> {
> con.connect("localhost", 5672, "test", "guest", "guest");
> }
> catch(Exception e)
> {
> System.out.print("Error connecting to broker");
> e.printStackTrace();
> }
> // Create session
> Session session = con.createSession(0);
> // Create an instance of the listener
> Listener listener = new Listener();
> // create a subscription
> session.messageSubscribe("management",
> "listener_management",
>
> Session.TRANSFER_CONFIRM_MODE_NOT_REQUIRED,
>
> Session.TRANSFER_ACQUIRE_MODE_PRE_ACQUIRE,
> new
> MessagePartListenerAdapter(listener), null);
> // issue credits
> session.messageFlow("listener_management",
> MessageCreditUnit.BYTE, Session.MESSAGE_FLOW_MAX_BYTES);
> session.messageFlow("listener_management",
> MessageCreditUnit.MESSAGE, 25);
> // confirm completion
> session.sync();
> session.messageCancel("listener_management");
> //cleanup
> session.sessionDetach(session.getName());
> try
> {
> con.close();
> }
> catch(Exception e)
> {
> System.out.print("Error closing broker connection");
> e.printStackTrace();
> }
> }
> }
>
> My question is how can I decode these messages?
>
> Thank you.
>
> Regards,
> Rahul
>
>
> On Jun 16 2008, Aidan Skinner wrote:
>
> > On Mon, Jun 16, 2008 at 9:56 AM, <[EMAIL PROTECTED]> wrote:
> >
> > > Thanks for your help. I am still with my previous problem (i.e.
> > > missing some APIs)
> >
> > > Client.java (under org.apache.qpidity.nclient) is missing some
> > > apis. eg.
> > >
> > > org.apache.qpidity.transport.ConnectionClose;
> >
> > > due to these I can not compile/run the code.
> >
> > It looks like you haven't run the generator, try doing an ant build
> > and it should create those classes for you.
> >
> > - Aidan
> >