|
@@ -3,7 +3,6 @@ package mq
|
|
import (
|
|
import (
|
|
"errors"
|
|
"errors"
|
|
"fmt"
|
|
"fmt"
|
|
- "runtime"
|
|
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
@@ -74,23 +73,16 @@ func encryptMsg(host *models.Host, msg []byte) ([]byte, error) {
|
|
}
|
|
}
|
|
|
|
|
|
func publish(host *models.Host, dest string, msg []byte) error {
|
|
func publish(host *models.Host, dest string, msg []byte) error {
|
|
- if len(msg) == 0 {
|
|
|
|
- fmt.Println("-----> $$$$$$ ZERO MSG_-------> ", string(msg))
|
|
|
|
- pc, _, _, ok := runtime.Caller(1)
|
|
|
|
- details := runtime.FuncForPC(pc)
|
|
|
|
- if ok && details != nil {
|
|
|
|
- fmt.Printf("\n------> ####$$$ Called from %s\n", details.Name())
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ encrypted, encryptErr := encryptMsg(host, msg)
|
|
|
|
+ if encryptErr != nil {
|
|
|
|
+ return encryptErr
|
|
}
|
|
}
|
|
- // encrypted, encryptErr := encryptMsg(host, msg)
|
|
|
|
- // if encryptErr != nil {
|
|
|
|
- // return encryptErr
|
|
|
|
- // }
|
|
|
|
if mqclient == nil {
|
|
if mqclient == nil {
|
|
return errors.New("cannot publish ... mqclient not connected")
|
|
return errors.New("cannot publish ... mqclient not connected")
|
|
}
|
|
}
|
|
|
|
|
|
- if token := mqclient.Publish(dest, 0, true, msg); !token.WaitTimeout(MQ_TIMEOUT*time.Second) || token.Error() != nil {
|
|
|
|
|
|
+ if token := mqclient.Publish(dest, 0, true, encrypted); !token.WaitTimeout(MQ_TIMEOUT*time.Second) || token.Error() != nil {
|
|
var err error
|
|
var err error
|
|
if token.Error() == nil {
|
|
if token.Error() == nil {
|
|
err = errors.New("connection timeout")
|
|
err = errors.New("connection timeout")
|