On Jul 8 2008, Ted Ross wrote:
[EMAIL PROTECTED] wrote:
> Hello Ted,
>
> encoder is an instance of AbstractEncoder class under
> org.apache.qpidity.transport.codec.Encoder. And thanks for pointing
> the duplication.
>
> Yes, you are correct i checked the spec. and it (bin128) is encoded as
> 16 octets. I added the following method for encoding the 128 bin
> schema hash with help of Rafael. so you mean this will not help to
> encode the schema... /* public void writeBin128(byte[] s) { if (s ==
> null) { s = new byte[16]; } else if (s.length != 16) { throw new
> IllegalArgumentException("" + s); }
>
> put(s);
> }
> */
>
> could you please let me know which method can encode this schema or is
> there any method in AbstractEncoder which can do this OR How can i
> encode this.
>
> Thanks in advance.
>
> BR,
> Rahul
>
Rahul,
I think your writeBin128 should work correctly. This encoding method
should be used to encode the schema hash in the schema request message.
Let me know how it works.
-Ted
Thank you Ted for your reply. I will let you know but one more question
before this.
can we send multiple request (AM1B, AM1P, AM1Q, AM1S etc...) to broker to
fetch the management information on the SAME SESSION ?
I am trying to request multiple request on the same session ang getting an
exception "IllegalMonitorStateException" on session.endData(); statement in
the following code snippet.
When while loop goes first time then everything is okay. but for the second
request when it reaches "session.endData();" then java throws this above
mentioned exception.
Code Snippet
-----
class ...{
...
public void main(String a[])..... {
....
....
Connection con = Client.createConnection();
ByteBuffer message= ByteBuffer.allocate(500);
ManagementEncoder encoder=new ManagementEncoder(message);
try
{ // connect to local host on default port 5672
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);
.......
......
// transfer message to "qpid.management" exchange
session.messageTransfer("qpid.management",
MessageAcceptMode.EXPLICIT,MessageAcquireMode.PRE_ACQUIRED);
session.header(deliveryProps,messageProps);
......
......
boolean flag=true;
while(flag)
{
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
int choice=0;
choice = Integer.parseInt(br.readLine().trim());
switch (choice)
{
// send broker request
case 1:
p.opcode="AM1B";
message.clear();
try {
message.put(p.opcode.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
break;
case 2:
// send package request
p.opcode="AM1P";
message.clear();
try {
message.put(p.opcode.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
break;
case 3:
// send class request
p.opcode="AM1Q";
p.sequenceNo=600;
p.packageName="qpid";
message.clear();
...
...
break;
case 4:
// send schema request
p.opcode="AM1S";
.....
.... .
break;
// switch closed
}
message.flip();
// send message
session.data(message);
// *********GETTING EXCEPTION HERE IllegalMonitorStateException*********
session.endData();
// confirm completion
session.sync();
// while closed
}
session.sessionDetach(session.getName());
try
{ // close connection
con.close();
}
catch(Exception e)
{
System.out.print("Error closing broker connection");
e.printStackTrace();
// main close }
}
// class closed
}
--------
End of the code snippet
can i use the same session for sending the multiple request?
Thank you so much.
BR,
/rahul