public unsafe static extern int ReceiveMessage( QueueHandle handle, uint timeout, ReadAction action, MQPROPS properties, NativeOverlapped *overlapped, ReceiveCallback receiveCallback, CursorHandle cursorHandle, ITransaction transaction); //MSMQ internal transaction
public QueueAsyncRequest(Message message, HashSet <QueueAsyncRequest> outstanding, uint timeoutMS, QueueHandle handle, ReadAction action, CursorHandle cursor) { Contract.Requires(cursor != null); this.action = action; this.handle = handle; this.timeoutMS = timeoutMS; Message = message; Props = message.Props.Allocate(); Tcs = new TaskCompletionSource <Message>(); Outstanding = outstanding; this.cursor = cursor; }
internal Task <Message> ReceiveAsync(Properties properties, ReadAction action, TimeSpan?timeout, CursorHandle cursor) { if (IsClosed) { throw new ObjectDisposedException(nameof(Queue)); } uint timeoutMS = TimeoutInMs(timeout); var msg = new Message(); msg.Props.SetForRead(properties); var ar = new QueueAsyncRequest(msg, _outstanding, timeoutMS, _handle, action, cursor); lock (_outstanding) { _outstanding.Add(ar); // hold a reference to prevent objects being collected if (!_boundToThreadPool) { ThreadPool.BindHandle(_handle); // queue can now use IO completion port _boundToThreadPool = true; } } return(ar.ReceiveAsync()); }
internal unsafe Message Receive(Properties properties, ReadAction action, TimeSpan?timeout, QueueTransaction transaction, CursorHandle cursor) { if (IsClosed) { throw new ObjectDisposedException(nameof(Queue)); } uint timeoutMS = TimeoutInMs(timeout); var msg = new Message(); int res; msg.Props.SetForRead(properties); for (;;) // loop because we might need to adjust memory size { var props = msg.Props.Allocate(); try { IntPtr txnHandle; if (transaction.TryGetHandle(out txnHandle)) { res = Native.ReceiveMessage(_handle, timeoutMS, action, props, null, null, cursor, txnHandle); } else { res = Native.ReceiveMessage(_handle, timeoutMS, action, props, null, null, cursor, transaction.InternalTransaction); } } finally { msg.Props.Free(); } if ((ErrorCode)res == ErrorCode.IOTimeout) { return(null); } if (Native.NotEnoughMemory(res)) { msg.Props.IncreaseBufferSize(); continue; // try again } if (Native.IsError(res)) { throw new QueueException(res); } msg.Props.ResizeBody(); return(msg); } }
public static extern int CreateCursor(QueueHandle handle, out CursorHandle cursorHandle);