/// <exception cref="System.Exception"></exception>
 public virtual T Poll(long timeout, TimeUnit unit)
 {
     var request = TransactionalQueuePollCodec.EncodeRequest(GetName(), GetTransactionId(), GetThreadId(),
         unit.ToMillis(timeout));
     var result = Invoke(request, m => TransactionalQueuePollCodec.DecodeResponse(m).response);
     return ToObject<T>(result);
 }
        public async Task <TItem> TryDequeueAsync(TimeSpan timeToWait)
        {
            var timeToWaitMilliseconds = timeToWait.TimeoutMilliseconds(0);
            var requestMessage         = TransactionalQueuePollCodec.EncodeRequest(Name, TransactionId, ContextId, timeToWaitMilliseconds);
            var responseMessage        = await Cluster.Messaging.SendToMemberAsync(requestMessage, TransactionClientConnection).CAF();

            var response = TransactionalQueuePollCodec.DecodeResponse(responseMessage).Response;

            return(ToObject <TItem>(response));
        }
        public async Task <TItem> PollAsync(TimeSpan timeToWait = default)
        {
            // codec wants -1 for infinite, 0 for zero
            var timeToWaitMs = timeToWait.RoundedMilliseconds();

            var requestMessage  = TransactionalQueuePollCodec.EncodeRequest(Name, TransactionId, ContextId, timeToWaitMs);
            var responseMessage = await Cluster.Messaging.SendToMemberAsync(requestMessage, TransactionClientConnection).CfAwait();

            var response = TransactionalQueuePollCodec.DecodeResponse(responseMessage).Response;

            return(ToObject <TItem>(response));
        }