func (b *broker) unsubscribe(l event.Link) { if l.IsSender() { q := b.queues[l.RemoteSource().Address()] if q != nil { q.unsubscribe(l) if q.empty() { debug.Printf("Delete queue %s", q.name) delete(b.queues, q.name) } } } }
func (q *queue) popTo(context *event.Pump, link event.Link) bool { if q.messages.Len() != 0 && link.Credit() > 0 { message := q.messages.Remove(q.messages.Front()).(proton.Message) debug.Printf("link %s <- queue %s: %s", logLink(link), q.name, formatMessage{message}) // The first return parameter is an event.Delivery. // The Deliver can be used to track message status, e.g. so we can re-delver on failure. // This demo broker doesn't do that. linkPump := link.Session().Connection().Pump() if context == linkPump { if context == nil { log.Fatal("pop in nil context") } link.Send(message) // link is in the current pump, safe to call Send() direct } else { linkPump.Inject <- func() { // Inject to link's pump link.Send(message) // FIXME aconway 2015-05-04: error handlig } } return true } return false }