Exemplo n.º 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);
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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);
                }
            }
Exemplo n.º 4
0
        /// <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);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
     }
 }