You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by re...@inode.serveftp.com on 2011/01/05 08:46:37 UTC
some garbage left in java broker with c# client
hi all
I have the following lines of code , in c#, to send and receive messages
from java broker
The other side is Java client, and there is no problem in request, response
When I use jconsole to monitor qpid, the heap size is increasing and does
not fall
So eventually Qpid Broker will become OutOfMemory
jconsole shows that all the temporarily queues created are removed probably
I wish to ask if these c# codes is the correct way to close a session or not
{
string g = Guid.NewGuid().ToString();
IClientSession s = client.CreateSession(10);
s.QueueDeclare(g, Option.AUTO_DELETE);
s.ExchangeBind(g, ReplyDestination, g, null);
s.ExecutionSync();
s.MessageSubscribe(g);
AsyncRespListener a = new AsyncRespListener();
a.session = s;
s.AttachMessageListener(a, g);
UTF8Encoding enc = new UTF8Encoding();
Message m = new Message();
m.AppendData(....something....);
m.MessageProperties.SetCorrelationId(enc.GetBytes(g));
ReplyTo r = new ReplyTo("", "nothing");
m.MessageProperties.SetReplyTo(r);
client.CreateSession(1000).MessageTransfer("serverchannel",
"generalservice", m);
lock (a.alock)
Monitor.Wait(a.alock, 5000);
s.QueueDelete(g);
return a.result;
}
and listener class
class AsyncRespListener : IMessageListener
{
public IClientSession session { get; set; }
public object alock = new object();
public string result;
private RangeSet rs = new RangeSet();
public void MessageTransfer(IMessage m)
{
BinaryReader reader = new BinaryReader(m.Body, Encoding.UTF8);
byte[] body = new byte[m.Body.Length - m.Body.Position];
reader.Read(body, 0, body.Length);
UTF8Encoding enc = new UTF8Encoding();
result = enc.GetString(body);
rs.Add(m.Id);
session.MessageAccept(rs);
lock (alock)
Monitor.Pulse(alock);
}
}
Regards,
Stephen
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org