+ C.write_bytes_array(txBuffer.payload, datap, txBuffer.len)
+
+ params.status = m.SendBuf(txBuffer, isRts)
+ if params.status == int(C.RMR_OK) {
+ return true
+ }
+ return false
+}
+
+func (m *RMRClient) SendBuf(txBuffer *C.rmr_mbuf_t, isRts bool) int {
+ var (
+ currBuffer *C.rmr_mbuf_t
+ counterName string = "Transmitted"
+ )
+
+ txBuffer.state = 0
+ if isRts {
+ currBuffer = C.rmr_rts_msg(m.context, txBuffer)
+ } else {
+ currBuffer = C.rmr_send_msg(m.context, txBuffer)
+ }
+
+ if currBuffer == nil {
+ m.UpdateStatCounter("TransmitError")
+ return m.LogMBufError("SendBuf failed", txBuffer)
+ }
+
+ // Just quick retry seems to help for K8s issue
+ maxRetryOnFailure := viper.GetInt("rmr.maxRetryOnFailure")
+ if maxRetryOnFailure == 0 {
+ maxRetryOnFailure = 5
+ }
+
+ for j := 0; j < maxRetryOnFailure && currBuffer != nil && currBuffer.state == C.RMR_ERR_RETRY; j++ {
+ if isRts {
+ currBuffer = C.rmr_rts_msg(m.context, currBuffer)
+ } else {
+ currBuffer = C.rmr_send_msg(m.context, currBuffer)
+ }
+ }
+
+ if currBuffer.state != C.RMR_OK {
+ counterName = "TransmitError"
+ m.LogMBufError("SendBuf failed", currBuffer)
+ }
+
+ m.UpdateStatCounter(counterName)
+ defer m.Free(currBuffer)
+
+ return int(currBuffer.state)
+}
+
+func (m *RMRClient) IsRetryError(params *RMRParams) bool {
+ if params.status == int(C.RMR_ERR_RETRY) {
+ return true
+ }
+ return false
+}
+
+func (m *RMRClient) IsNoEndPointError(params *RMRParams) bool {
+ if params.status == int(C.RMR_ERR_NOENDPT) {
+ return true
+ }