Exemplo n.º 1
0
        public MsgSendInfo[] SendMessage(SkyWebMessage msg)
        {
            if (msg == null)
            {
                throw new WebMessagingException(StringConsts.ARGUMENT_ERROR + "{0}.SendMessage(null)".Args(GetType().Name));
            }

            var deliveryList = new List <MsgSendInfo>();

            var idx        = -1;
            var matchedAll = true;

            foreach (var adr in msg.AddressToBuilder.All)
            {
                idx++;
                var channel = m_Channels[adr.ChannelName];
                if (channel == null)
                {
                    matchedAll = false;
                    deliveryList.Add(new MsgSendInfo(MsgChannelWriteResult.Gateway, null, idx));
                    continue;
                }

                try
                {
                    var result = channel.Write(deliveryList, idx, adr.ChannelAddress, msg);
                    if (result < 0)
                    {
                        deliveryList.Add(new MsgSendInfo(result, null, idx));
                    }

                    // TODO: instrumentation by result, etc.
                }
                catch (Exception error)
                {
                    log(Azos.Log.MessageType.Critical, "sndmsg.chn.wrt", "Channel '{0}' leaked:".Args(channel.Name, error.ToMessageWithType()), error);
                    deliveryList.Add(new MsgSendInfo(MsgChannelWriteResult.ChannelError, null, idx));
                }
            }

            //route to gateway
            if (!matchedAll)
            {
                m_Gateway.SendMsg(msg);
            }

            return(deliveryList.ToArray());
        }
Exemplo n.º 2
0
 public MsgSendInfo[] SendMessage(SkyWebMessage msg)
 => Service.SendMessage(msg);
Exemplo n.º 3
0
 /// <summary>
 /// Writes msg into mailbox identified by the particular address.
 /// Reliability: this method must not leak errors, but should handle them depending on particular
 /// channel implementation and message importance (i.e. we may create ToDo that will try to redeliver)
 /// </summary>
 public abstract MsgChannelWriteResult Write(List <MsgSendInfo> deliveryList, int idx, string address, SkyWebMessage msg);