Beispiel #1
0
        public IBytesMessage CreateBytesMessage(byte[] body)
        {
            BytesMessage answer = new BytesMessage();

            answer.Content = body;
            return(answer);
        }
        protected virtual Message CreateAmqpMessage(IMessage message)
        {
            if (message is TextMessage)
            {
                TextMessage textMessage = message as TextMessage;
                Message     result      = new Message(textMessage.Text);
                return(result);
            }
            else if (message is BytesMessage)
            {
                BytesMessage bytesMessage = message as BytesMessage;
                Message      result       = new Message(bytesMessage.Content, 0, bytesMessage.Content.Length);
                return(result);
            }
            else if (message is ObjectMessage)
            {
                ObjectMessage       objectMessage = message as ObjectMessage;
                Collection <object> objs          = new Collection <object>();
                objs = ConvertObjectToAmqpList(objectMessage.Body);

                Message result = new Message(objs);
                return(result);
            }
            else if (message is MapMessage)
            {
                MapMessage   mapMessage          = message as MapMessage;
                PrimitiveMap mapBody             = mapMessage.Body as PrimitiveMap;
                Dictionary <string, object> dict = FromNmsPrimitiveMap(mapBody);

                Message result = new Message(dict);
                return(result);
            }
            else if (message is StreamMessage)
            {
                StreamMessage streamMessage = message as StreamMessage;
                Message       result        = new Message(streamMessage.Content, 0, streamMessage.Content.Length);
                return(result);
            }
            else if (message is BaseMessage)
            {
                Message result = new Message();
                return(result);
            }
            else
            {
                throw new Exception("unhandled message type");
            }
        }
Beispiel #3
0
 public IBytesMessage CreateBytesMessage(byte[] body)
 {
     BytesMessage answer = new BytesMessage();
     answer.Content = body;
     return answer;
 }