github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/engine/function/activemq.go (about) 1 package funcs 2 3 import ( 4 // "context" 5 6 "fmt" 7 "time" 8 ) 9 10 type SendMessagebyActiveMQ struct { 11 } 12 13 func (w *SendMessagebyActiveMQ) Execute(f *Funcs) { 14 startTime := time.Now() 15 defer func() { 16 elapsed := time.Since(startTime) 17 f.iLog.PerformanceWithDuration("engine.funcs.SendMessagebyActiveMQ.Execute", elapsed) 18 }() 19 defer func() { 20 if err := recover(); err != nil { 21 f.iLog.Error(fmt.Sprintf("There is error to engine.funcs.SendMessagebyActiveMQ.Execute with error: %s", err)) 22 f.CancelExecution(fmt.Sprintf("There is error to engine.funcs.SendMessagebyActiveMQ.Execute with error: %s", err)) 23 f.ErrorMessage = fmt.Sprintf("There is error to engine.funcs.SendMessagebyActiveMQ.Execute with error: %s", err) 24 return 25 } 26 }() 27 28 f.iLog.Debug(fmt.Sprintf("SendMessagebyActiveMQ Execute: %v", f)) 29 30 namelist, valuelist, _ := f.SetInputs() 31 f.iLog.Debug(fmt.Sprintf("SendMessagebyActiveMQ Execute: %v, %v", namelist, valuelist)) 32 activeMQCfg := "" 33 Topic := "" 34 data := make(map[string]interface{}) 35 for i, name := range namelist { 36 if name == "Topic" { 37 Topic = valuelist[i] 38 39 continue 40 } else if name == "ActiveMQ" { 41 activeMQCfg = valuelist[i] 42 } 43 data[name] = valuelist[i] 44 } 45 46 if Topic == "" { 47 f.iLog.Error(fmt.Sprintf("SendMessagebyActiveMQ validate wrong: %v", "Topic is empty")) 48 return 49 } 50 51 if activeMQCfg == "" { 52 f.iLog.Error(fmt.Sprintf("SendMessagebyActiveMQ validate wrong: %v", "ActiveMQ is empty")) 53 return 54 } 55 56 // get activeMQ connection 57 58 // product the data 59 60 // send the data to activeMQ 61 62 }