public object GetLookups(LookupAction actionOption, params object[] param) { string result = string.Empty; string paramValues = string.Empty; try { if (param != null) { paramValues = String.Join("/", param); } var uri = new Uri(String.Format(Config.BASE_SERVICE_URL + actionOption.Url + paramValues, string.Empty)); httpClient.Timeout = new TimeSpan(0, 20, 20); response = httpClient.GetAsync(uri).Result; if (response.IsSuccessStatusCode) { JsonSerializerSettings serSettings = new JsonSerializerSettings(); serSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); result = response.Content.ReadAsStringAsync().Result; } return(result); } catch { //handler.HandleServiceResults(null, false, ex.Message); return(null); } }
public unsafe static extern int ReceiveMessageByLookupId( QueueHandle handle, long lookupId, LookupAction action, MQPROPS properties, NativeOverlapped *overlapped, ReceiveCallback receiveCallback, ITransaction transaction); //MSMQ internal transaction
/// <summary>Tries to peek (or receive) a message using the queue-specific <paramref name="lookupId"/></summary> /// <remarks>Within a transaction you cannot receive a message that you moved to a subqueue within the same transaction</remarks> /// <param name="properties">The properties to read</param> /// <param name="lookupId">The <see cref="Message.LookupId"/> of the message to read</param> /// <param name="action">Receive or peek a message?</param> /// <param name="timeout">The time allowed, defaults to infinite. Use <see cref="TimeSpan.Zero"/> to return without waiting</param> /// <param name="transaction">can be NULL for no transaction, a <see cref="QueueTransaction"/>, <see cref="QueueTransaction.Single"/>, or <see cref="QueueTransaction.Dtc"/>.</param> /// <returns>The message, or NULL if the message was not found or the receive times out</returns> public unsafe Message Lookup(Properties properties, long lookupId, LookupAction action = LookupAction.ReceiveCurrent, TimeSpan?timeout = null, QueueTransaction transaction = null) { 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.ReceiveMessageByLookupId(_handle, lookupId, action, props, null, null, txnHandle); } else { res = Native.ReceiveMessageByLookupId(_handle, lookupId, action, props, null, null, transaction.InternalTransaction); } } finally { msg.Props.Free(); } if ((ErrorCode)res == ErrorCode.IOTimeout || (ErrorCode)res == ErrorCode.MessageNotFound) { 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); } }
protected void RouteBatchCore(List <Tracking> sent, QueueTransaction txn) { long lookupId = 0; LookupAction action = LookupAction.PeekFirst; for (int i = 0; i < MaxBatchSize; i++) { // peek for the next message var msg = _input.Lookup(Properties.All, lookupId, action, TimeSpan.Zero); if (msg == null) { break; } action = LookupAction.PeekNext; lookupId = msg.LookupId; // move to the batch subqueue so we know what we sent Queues.MoveMessage(_input, _batchQueue, msg.LookupId, txn); // route to message to the destination var dest = GetRoute(msg); sent.Add(Sender.RequestDelivery(msg, dest, txn)); } }
public Message Lookup(Properties properties, long lookupId, QueueTransaction transaction, LookupAction action = LookupAction.ReceiveCurrent, TimeSpan?timeout = null) { Contract.Requires(transaction != null); return(_high.Lookup(properties, lookupId, action, timeout, transaction) ?? _low.Lookup(properties, lookupId, action, timeout, transaction)); }