/// <summary> /// Dequeue messages from a persistent message queue file at server side in batch /// </summary> /// <param name="key">An ASCII string for identifying a queue at server side</param> /// <param name="d">A callback for tracking data like remaining message count within a server queue file, queue file size in bytes, message dequeued within this batch and bytes dequeued within this batch</param> /// <param name="timeout">A time-out number in milliseconds</param> /// <returns>true for sending the request successfully, and false for failure</returns> public bool Dequeue(byte[] key, DDequeue d, uint timeout) { DAsyncResultHandler rh = null; if (key == null) key = new byte[0]; lock (m_csQ) { m_keyDequeue = key; if (d != null) { rh = (ar) => { ulong messageCount, fileSize, ret; ar.Load(out messageCount).Load(out fileSize).Load(out ret); uint messages = (uint)ret; uint bytes = (uint)(ret >> 32); d(messageCount, fileSize, messages, bytes); }; m_dDequeue = d; } else { m_dDequeue = null; } } using (CScopeUQueue sb = new CScopeUQueue()) { sb.Save(key).Save(timeout); return SendRequest(idDequeue, sb, rh); } }
/// <summary> /// Dequeue messages from a persistent message queue file at server side in batch /// </summary> /// <param name="key">An ASCII string for identifying a queue at server side</param> /// <param name="d">A callback for tracking data like remaining message count within a server queue file, queue file size in bytes, message dequeued within this batch and bytes dequeued within this batch</param> /// <param name="timeout">A time-out number in milliseconds</param> /// <param name="discarded">a callback for tracking cancel or socket closed event</param> /// <returns>true for sending the request successfully, and false for failure</returns> public virtual bool Dequeue(byte[] key, DDequeue d, uint timeout, DDiscarded discarded) { DAsyncResultHandler rh = null; lock (m_csQ) { m_keyDequeue = key; if (d != null) { rh = (ar) => { ulong messageCount, fileSize, ret; ar.UQueue.Load(out messageCount).Load(out fileSize).Load(out ret); uint messages = (uint)ret; uint bytes = (uint)(ret >> 32); d((CAsyncQueue)ar.AsyncServiceHandler, messageCount, fileSize, messages, bytes); }; m_dDequeue = d; } else { m_dDequeue = null; } } using (CScopeUQueue sb = new CScopeUQueue()) { CUQueue q = sb.UQueue; q.Save(key).Save(timeout); return(SendRequest(idDequeue, q, rh, discarded, (DOnExceptionFromServer)null)); } }
/// <summary> /// Dequeue messages from a persistent message queue file at server side in batch without waiting /// </summary> /// <param name="key">An ASCII string for identifying a queue at server side</param> /// <param name="d">A callback for tracking data like remaining message count within a server queue file, queue file size in bytes, message dequeued within this batch and bytes dequeued within this batch</param> /// <returns>true for sending the request successfully, and false for failure</returns> public bool Dequeue(byte[] key, DDequeue d) { return Dequeue(key, d, 0); }
/// <summary> /// Dequeue messages from a persistent message queue file at server side in batch /// </summary> /// <param name="key">An ASCII string for identifying a queue at server side</param> /// <param name="d">A callback for tracking data like remaining message count within a server queue file, queue file size in bytes, message dequeued within this batch and bytes dequeued within this batch</param> /// <param name="timeout">A time-out number in milliseconds</param> /// <returns>true for sending the request successfully, and false for failure</returns> public bool Dequeue(byte[] key, DDequeue d, uint timeout) { return(Dequeue(key, d, timeout, null)); }
/// <summary> /// Dequeue messages from a persistent message queue file at server side in batch without waiting /// </summary> /// <param name="key">An ASCII string for identifying a queue at server side</param> /// <param name="d">A callback for tracking data like remaining message count within a server queue file, queue file size in bytes, message dequeued within this batch and bytes dequeued within this batch</param> /// <returns>true for sending the request successfully, and false for failure</returns> public bool Dequeue(byte[] key, DDequeue d) { return(Dequeue(key, d, 0, null)); }