public bool SendWithNotRetry(string message, string routingKey, bool isMessageDurable = true) { try { IBasicProperties basicProperties = CommonLibrary.CreateBasicProperties(this.Channel, new BasicPropertiesConfigInfo() { Durable = isMessageDurable }); byte[] body = CommonLibrary.BinarySerialize(message); this.Channel.BasicPublish(this.producerConfigInfo.ExchangeName, routingKey, basicProperties, body); return(true); } catch (Exception ex) { // RecordLog.WriteLog("ExchangeName:" + this.producerConfigInfo.ExchangeName + ",RoutingKey:" + routingKey + ",发送失败", this.producerConfigInfo.ExchangeName, routingKey, "", ex); this.Dispose(); return(false); } }
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; //} }