RespondMsg allows a convenient way to respond to requests in service based subscriptions that might include headers
(msg *Msg)
| 5727 | |
| 5728 | // RespondMsg allows a convenient way to respond to requests in service based subscriptions that might include headers |
| 5729 | func (m *Msg) RespondMsg(msg *Msg) error { |
| 5730 | if m == nil || m.Sub == nil { |
| 5731 | return ErrMsgNotBound |
| 5732 | } |
| 5733 | if m.Reply == "" { |
| 5734 | return ErrMsgNoReply |
| 5735 | } |
| 5736 | msg.Subject = m.Reply |
| 5737 | m.Sub.mu.Lock() |
| 5738 | nc := m.Sub.conn |
| 5739 | m.Sub.mu.Unlock() |
| 5740 | // No need to check the connection here since the call to publish will do all the checking. |
| 5741 | return nc.PublishMsg(msg) |
| 5742 | } |
| 5743 | |
| 5744 | // FIXME: This is a hack |
| 5745 | // removeFlushEntry is needed when we need to discard queued up responses |