Beispiel #1
0
        /// <summary>
        /// <see cref="IBus.Reply{T}(Action{T})"/>
        /// </summary>
        public void Reply <T>(Action <T> messageConstructor)
        {
            var instance = messageMapper.CreateInstance(messageConstructor);
            var options  = new ReplyOptions(MessageBeingProcessed.ReplyToAddress, GetCorrelationId());

            SendMessage(options, LogicalMessageFactory.Create(instance));
        }
Beispiel #2
0
        /// <summary>
        /// <see cref="IBus.Return{T}"/>
        /// </summary>
        public void Return <T>(T errorCode)
        {
            var tType = errorCode.GetType();

            if (!(tType.IsEnum || tType == typeof(Int32) || tType == typeof(Int16) || tType == typeof(Int64)))
            {
                throw new ArgumentException("The errorCode can only be an enum or an integer.", "errorCode");
            }

            var returnCode = errorCode.ToString();

            if (tType.IsEnum)
            {
                returnCode = Enum.Format(tType, errorCode, "D");
            }

            var returnMessage = LogicalMessageFactory.CreateControl(new Dictionary <string, string>
            {
                { Headers.ReturnMessageErrorCodeHeader, returnCode }
            });

            var options = new ReplyOptions(MessageBeingProcessed.ReplyToAddress, GetCorrelationId());

            InvokeSendPipeline(options, returnMessage);
        }
Beispiel #3
0
        /// <summary>
        /// <see cref="IBus.Reply(object)"/>
        /// </summary>
        public void Reply(object message)
        {
            var options = new ReplyOptions(MessageBeingProcessed.ReplyToAddress, GetCorrelationId());

            SendMessage(options, LogicalMessageFactory.Create(message));
        }