/// <exception cref="System.Exception"></exception>
 public virtual bool Offer(T e, long timeout, TimeUnit unit)
 {
     var data = ToData(e);
     var request = TransactionalQueueOfferCodec.EncodeRequest(GetName(), GetTransactionId(), GetThreadId(), data,
         unit.ToMillis(timeout));
     return Invoke(request, m => TransactionalQueueOfferCodec.DecodeResponse(m).response);
 }
        public async Task <bool> TryEnqueueAsync(TItem item, TimeSpan timeToWait)
        {
            var itemData = ToSafeData(item);
            var timeToWaitMilliseconds = timeToWait.TimeoutMilliseconds(0);
            var requestMessage         = TransactionalQueueOfferCodec.EncodeRequest(Name, TransactionId, ContextId, itemData, timeToWaitMilliseconds);
            var responseMessage        = await Cluster.Messaging.SendToMemberAsync(requestMessage, TransactionClientConnection).CAF();

            return(TransactionalQueueOfferCodec.DecodeResponse(responseMessage).Response);
        }
        public async Task <bool> OfferAsync(TItem item, TimeSpan timeToWait)
        {
            var itemData = ToSafeData(item);

            // codec wants -1 for infinite, 0 for zero
            var timeToWaitMs = timeToWait.RoundedMilliseconds();

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

            return(TransactionalQueueOfferCodec.DecodeResponse(responseMessage).Response);
        }