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