def callback(message): messages.append(message) if len(messages) < 3: raise exceptions.Nack()
def callback(message): """Nack the message, then halt.""" nacked_messages.append(message) if len(nacked_messages) == 2: raise exceptions.HaltConsumer() raise exceptions.Nack()