[EMAIL PROTECTED] wrote:
Hello Ted/Anybody,

Could you please correct me about the schema request (AM1S) which I am sending to broker to get the schema response for particular class?

Could you please let me know what is wrong here. I think schema request is not healthy. Please guide me here. I am not receiving the schema response with this schema request

Here is the code snippet of Schema request and Schema response.
// Code snippet for Schema Request (AM1S)
....

p.opcode="AM1S";
p.sequenceNo=500;
p.packageName="qpid";
p.classname="vhost";

message.clear();
try {
// encode the opcode
message.put(p.opcode.getBytes("UTF-8"));
message.putInt( p.sequenceNo);
// encode the package name
encoder.writeStr8(p.packageName);
message.putShort((byte) p.packageName.length());
message.put(p.packageName.getBytes("UTF-8"));
// encode the class name
encoder.writeStr8(p.classname);
message.putShort((byte) p.classname.length());
message.put(p.classname.getBytes("UTF-8"));
// encode the schema hash
// *** schema has contents which it got from // byte[] schemaHash=decoder.readBin128(); something like [EMAIL PROTECTED] ***

encoder.writeBin128(schemaHash);
message.put((byte) schemaHash.length);
message.put(schemaHash);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
........
........

------

//Start Code snippet Schema Response (AM1s)

String packname = decoder.readStr8();
System.out.println("Package Name: " + packname);
String clasnam = decoder.readStr8();
System.out.println("Class Name: " + clasnam);
// get the decoded schema hash
decoder.readBin128();
// get the decoded properties contents
int propCnt = decoder.readUint16();
System.out.println("Property content:   " + propCnt);
long statCnt = decoder.readUint16();
System.out.println("Statistic content:   " + statCnt);
int methodCnt = decoder.readUint16();
System.out.println("Method content:   " + methodCnt);
int eventCnt = decoder.readUint16();
System.out.println("Event content:   " + eventCnt);
for( int i = 0; i < propCnt; i++ )
{    // decode the MAP
Map<String,Object> map = decoder.readMap();
}
for( int i = 0; i < statCnt; i++ )
{
// decode the MAP
Map<String,Object> map = decoder.readMap();
}
for( int i = 0; i < methodCnt; i++ )
{    // decode the MAP
Map<String,Object> map = decoder.readMap();
}
for( int i = 0; i < eventCnt; i++ )
{    // decode the MAP
Map<String,Object> map = decoder.readMap();
}
                    ---------
End of the Code

Thank you.

Best Regards,
Rahul

Rahul,

There's a problem with the encoding of the bin128 for the hash value. If you look at the AMQP 0-10 specification for the proper encoding for a bin128 value, you will see that it is encoded as 16 octets (no length field). Your code prepends a one-byte length which causes the value to be incorrect/unmatched from the viewpoint of the management broker.

In looking at your code fragment, I am unclear as to what "encoder" is and why you use it. In the following section, you invoke "writeStr8" on "encoder" but then you manually encode the string into "message".

   // encode the package name
   encoder.writeStr8(p.packageName);
   message.putShort((byte) p.packageName.length());
   message.put(p.packageName.getBytes("UTF-8"));

Regards,

-Ted

Reply via email to