@@ -71,18 +71,22 @@ func (msg *PersistMessage) Send() {
71
71
if err != nil {
72
72
log .Fatal (4 , "failed to marshal persistMessage to json." )
73
73
}
74
- // This will always return a host. If all hosts are currently marked as dead,
75
- // then all hosts will be reset to alive and we will try them all again. This
76
- // will result in this loop repeating forever until we successfully publish our msg.
77
- hostPoolResponse := hostPool .Get ()
78
- p := producers [hostPoolResponse .Host ()]
79
- err = p .Publish (* topicNotifyPersist , body )
80
- // Hosts that are marked as dead will be retried after 30seconds. If we published
81
- // successfully, then sending a nil error will mark the host as alive again.
82
- hostPoolResponse .Mark (err )
83
- if err != nil {
84
- log .Warn ("publisher marking host %s as faulty due to %s" , hostPoolResponse .Host (), err )
85
- msg .Send ()
74
+ sent := false
75
+ for ! sent {
76
+ // This will always return a host. If all hosts are currently marked as dead,
77
+ // then all hosts will be reset to alive and we will try them all again. This
78
+ // will result in this loop repeating forever until we successfully publish our msg.
79
+ hostPoolResponse := hostPool .Get ()
80
+ p := producers [hostPoolResponse .Host ()]
81
+ err = p .Publish (* topicNotifyPersist , body )
82
+ // Hosts that are marked as dead will be retried after 30seconds. If we published
83
+ // successfully, then sending a nil error will mark the host as alive again.
84
+ hostPoolResponse .Mark (err )
85
+ if err != nil {
86
+ log .Warn ("publisher marking host %s as faulty due to %s" , hostPoolResponse .Host (), err )
87
+ } else {
88
+ sent = true
89
+ }
86
90
}
87
91
88
92
return
0 commit comments