Example #1
0
 public bool SendWithNotRetry(byte[] messageBodyBytes, string routingKey, bool isMessageDurable = true)
 {
     try
     {
         IBasicProperties basicProperties = CommonLibrary.CreateBasicProperties(this.Channel, new BasicPropertiesConfigInfo()
         {
             Durable = isMessageDurable
         });
         this.Channel.BasicPublish(this.producerConfigInfo.ExchangeName, routingKey, basicProperties, messageBodyBytes);
         return(true);
     }
     catch (Exception ex)
     {
         //   RecordLog.WriteLog("ExchangeName:" + this.producerConfigInfo.ExchangeName + ",RoutingKey:" + routingKey + ",发送失败", this.producerConfigInfo.ExchangeName, routingKey, "", ex);
         this.Dispose();
         return(false);
     }
 }
Example #2
0
        public bool Send(
            string message,
            string routingKey,
            BasicPropertiesConfigInfo basicPropertiesConfigInfo)
        {
            IBasicProperties basicProperties = basicPropertiesConfigInfo == null ? (IBasicProperties)null : CommonLibrary.CreateBasicProperties(this.Channel, basicPropertiesConfigInfo);

            byte[] body = CommonLibrary.BinarySerialize(message);
            //try
            //{
            this.Channel.BasicPublish(this.producerConfigInfo.ExchangeName, routingKey, basicProperties, body);
            this.RepairException();
            return(true);
            //}
            //catch (Exception ex)
            //{
            //    //RecordLog.WriteLog("ExchangeName:" + this.producerConfigInfo.ExchangeName + ",RoutingKey:" + routingKey + ",发送失败:本次消息已记录到本地临时文件", this.producerConfigInfo.ExchangeName, routingKey, "", ex);
            //    this.SaveException(message, routingKey, this.producerConfigInfo, basicPropertiesConfigInfo);
            //    this.Dispose();
            //    return false;
            //}
        }