예제 #1
0
 static void OnSendComplete(Message m, Outcome o, object state)
 {
     PerfTests thisPtr = (PerfTests)state;
     int sentCount = Interlocked.Increment(ref thisPtr.completedCount);
     if (sentCount >= thisPtr.totalCount)
     {
         thisPtr.done.Set();
     }
     else if (sentCount % thisPtr.batchCount == 0)
     {
         thisPtr.SendMessages(thisPtr.batchCount);
     }
 }
예제 #2
0
 static void OnOutcome(Message message, Outcome outcome, object state)
 {
     var tcs = (TaskCompletionSource<byte[]>)state;
     if (outcome.Descriptor.Code == Codec.Declared.Code)
     {
         tcs.SetResult(((Declared)outcome).TxnId);
     }
     else if (outcome.Descriptor.Code == Codec.Rejected.Code)
     {
         tcs.SetException(new AmqpException(((Rejected)outcome).Error));
     }
     else
     {
         tcs.SetCanceled();
     }
 }
예제 #3
0
            static void OnSendComplete(Message message, Outcome outcome, object state)
            {
                var tuple = (Tuple<Sender, SenderLink>)state;
                Sender thisPtr = tuple.Item1;
                SenderLink sender = tuple.Item2;
                if (thisPtr.bufferManager != null)
                {
                    var buffer = message.GetBody<ByteBuffer>();
                    buffer.Reset();
                    thisPtr.bufferManager.ReturnBuffer(new ArraySegment<byte>(buffer.Buffer, buffer.Offset, buffer.Capacity));
                }

                if (thisPtr.OnComplete())
                {
                    Message msg = thisPtr.CreateMessage();
                    sender.Send(msg, onOutcome, state);
                }
            }
예제 #4
0
파일: Program.cs 프로젝트: leestott/Beats
        /// <summary>
        /// Callback function used to report on AMQP message send 
        /// </summary>
        /// <param name="message"></param>
        /// <param name="outcome"></param>
        /// <param name="state"></param>
        public static void SendOutcome(Message message, Outcome outcome, object state)
        {
            if (outcome is Accepted)
            {
//#if DEBUG
                logger.Info("Sent message from {0} at {1}", AppEdgeGateway, message.ApplicationProperties["time"]);
//#endif
#if LOG_MESSAGE_RATE
                g_messageCount++;
#endif
            }
            else
            {
                logger.Error("Error sending message {0} - {1}, outcome {2}", message.ApplicationProperties["time"], message.Properties.Subject, outcome);
                logger.Error("Error sending to {0} at {1}", AppEHTarget, AppAMQPAddress);
            }
        }
예제 #5
0
        void DisposeMessage(Message message, Outcome outcome)
        {
            Delivery delivery = message.Delivery;
            if (delivery == null || delivery.Settled)
            {
                return;
            }

            DeliveryState state = outcome;
            bool settled = true;
#if NETFX || NETFX40
            var txnState = Amqp.Transactions.ResourceManager.GetTransactionalStateAsync(this).Result;
            if (txnState != null)
            {
                txnState.Outcome = outcome;
                state = txnState;
                settled = false;
            }
#endif
            this.Session.DisposeDelivery(true, delivery, state, settled);
        }
예제 #6
0
 static void OnSendComplete(Message message, Outcome outcome, object state)
 {
     var thisPtr = (Sender)state;
     if (thisPtr.OnComplete())
     {
         Message msg = new Message(new string('D', thisPtr.bodySize));
         msg.Properties = new Properties() { MessageId = "msg" };
         thisPtr.sender.Send(msg, onOutcome, state);
     }
 }