public OutgoingConnection(
     INetMqConfig netMqConfig,
     IEnvelopFactory <TPayloadType, TBody> envelopFactory,
     IMessageSetting messageSetting,
     IEncoder <TPayloadType, TBody> encoder)
 {
     this.connectionString = netMqConfig.OutgoingConnection;
     this.envelopFactory   = envelopFactory;
     this.maxFrameSize     = messageSetting.MaxFrameSize;
     this.encoder          = encoder;
 }
 public void Send(
     PushSocket pushSocket,
     IEnvelopFactory <TPayloadType, TBody> envelopFactory,
     IEncoder <TPayloadType, TBody> encoder,
     Msg msg,
     int maxFrameSize)
 {
     envelopFactory.CreateEnvelops(
         this.message,
         (envelope) =>
     {
         var array = msg.Data;
         encoder.Encode(envelope, ref array);
         if (!pushSocket.TrySend(ref msg, timeOut, false))
         {
             log.Error($"Failed to send a message.");
         }
         msg.InitPool(maxFrameSize);
     });
 }