#NEWLINE# @ web . authenticated #NEWLINE# def post( self , workername ) : #NEWLINE# #INDENT# '\nStart consuming from a queue\n\n**Example request**:\n\n.. sourcecode:: http\n\n  POST /api/worker/queue/add-consumer/celery@worker2?queue=sample-queue\n  Content-Length: 0\n  Content-Type: application/x-www-form-urlencoded; charset=utf-8\n  Host: localhost:5555\n\n**Example response**:\n\n.. sourcecode:: http\n\n  HTTP/1.1 200 OK\n  Content-Length: 40\n  Content-Type: application/json; charset=UTF-8\n\n  {\n      "message": "add consumer sample-queue"\n  }\n\n:query queue: the name of a new queue\n:reqheader Authorization: optional OAuth token to authenticate\n:statuscode 200: no error\n:statuscode 401: unauthorized request\n:statuscode 403: failed to add consumer\n:statuscode 404: unknown worker\n        ' #NEWLINE# if ( not self . is_worker ( workername ) ) : #NEWLINE# #INDENT# raise web . HTTPError ( 404 , ( "Unknown worker '%s'" % workername ) ) #NEWLINE# #UNINDENT# queue = self . get_argument ( 'queue' ) #NEWLINE# logger . info ( "Adding consumer '%s' to worker '%s'" , queue , workername ) #NEWLINE# response = self . capp . control . broadcast ( 'add_consumer' , arguments = { #NEWLINE# #INDENT# 'queue' : queue , #NEWLINE# #UNINDENT# } , destination = [ workername ] , reply = True ) #NEWLINE# if ( response and ( 'ok' in response [ 0 ] [ workername ] ) ) : #NEWLINE# #INDENT# self . write ( dict ( message = response [ 0 ] [ workername ] [ 'ok' ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# logger . error ( response ) #NEWLINE# self . set_status ( 403 ) #NEWLINE# self . write ( ( "Failed to add '%s' consumer to '%s' worker: %s" % ( queue , workername , self . error_reason ( workername , response ) ) ) )