public static AMQFrame CreateAMQFrame(ushort channelId, ContentBody body)
        {
            AMQFrame frame = new AMQFrame();

            frame.Channel   = channelId;
            frame.BodyFrame = body;
            return(frame);
        }
 public void ReceiveBody(ContentBody body)
 {
     Bodies.Add(body);
     if (body.Payload != null)
     {
         _bytesReceived += (uint)body.Payload.Remaining;
     }
 }
Beispiel #3
0
 public static AMQFrame CreateAMQFrame(ushort channelId, ContentBody body)
 {
     AMQFrame frame = new AMQFrame();
     frame.Channel = channelId;
     frame.BodyFrame = body;
     return frame;
 }
 public void MessageContentBodyReceived(ushort channelId, ContentBody contentBody)
 {
     UnprocessedMessage msg = (UnprocessedMessage) _channelId2UnprocessedMsgMap[channelId];
     if (msg == null)
     {
         throw new AMQException("Error: received content body without having received a BasicDeliver frame first");
     }
     if (msg.ContentHeader == null)
     {
         _channelId2UnprocessedMsgMap.Remove(channelId);
         throw new AMQException("Error: received content body without having received a ContentHeader frame first");
     }
     try
     {
         msg.ReceiveBody(contentBody);
     }
     catch (UnexpectedBodyReceivedException e)
     {
         _channelId2UnprocessedMsgMap.Remove(channelId);
         throw e;
     }
     if (msg.IsAllBodyDataReceived())
     {
         DeliverMessageToAMQSession(channelId,  msg);
     }
 }
 /// <summary>
 /// Create content bodies. This will split a large message into numerous bodies depending on the negotiated
 /// maximum frame size.
 /// </summary>
 /// <param name="payload"></param>
 /// <returns>return the array of content bodies</returns>
 private ContentBody[] CreateContentBodies(ByteBuffer payload)
 {
    if ( payload == null )
    {
       return null;
    } else if ( payload.Remaining == 0 )
    {
       return new ContentBody[0];
    }
    // we substract one from the total frame maximum size to account for the end of frame marker in a body frame
    // (0xCE byte).
    int framePayloadMax = (int)(_channel.Connection.MaximumFrameSize - 1);
    int frameCount = CalculateContentBodyFrames(payload);
    ContentBody[] bodies = new ContentBody[frameCount];
    for ( int i = 0; i < frameCount; i++ )
    {
       int length = (payload.Remaining >= framePayloadMax)
          ? framePayloadMax : payload.Remaining;
       bodies[i] = new ContentBody(payload, (uint)length);
    }
    return bodies;
 }