title: celery worker refusing to deserialise untrusted content type of application/json
body: <p>I have a distributed setup where i am using RabbitMQ as the message broker and celery as the distributed task queue. 
  A RabbitMQ java client pushes json data into the message broker
  ex: </p>
  
  <blockquote>
    <p>{"id":"95a67132-0a47-4d44-80bd-7a8725528254","args":[],"task":"app.task.add","kwargs":[]}</p>
  </blockquote>
  
  <p>with content-type: application/json, content-encoding: utf-8 (set using a custom MessagePostProcessor implementation)</p>
  
  <p>on Celery side i have tasks.py like:</p>
  
  <pre><code>from celery import Celery
  app = Celery('tasks', broker='amqp://&lt;broker credentials&gt;@&lt;ip&gt;//')
  app.config_from_object('celeryconfig')
  @app.task
  def add():
      print "done"
  @app.task
  def addX(x):
      print "done addx"
  </code></pre>
  
  <p>and a celeryconfig.py like:</p>
  
  <pre><code>from kombu import Exchange, Queue
  from kombu.serialization import registry
  
  CELERY_IGNORE_RESULT = False
  BROKER_HOST = &lt;ip address of broker&gt; #IP address of the server running RabbitMQ and Celery
  BROKER_URL='amqp://&lt;broker credentials&gt;@&lt;ip&gt;'
  CELERY_RESULT_BACKEND = 'amqp://'
  CELERY_IMPORTS=("tasks",)
  CELERY_DEFAULT_QUEUE = &lt;queue name&gt;
  CELERY_TASK_SERIALIZER = 'json'
  CELERY_RESULT_SERIALIZER = 'json'
  CELERY_ACCEPT_CONTENT = ['application/json']
  CELERY_QUEUES = (
     Queue('default', Exchange('exchange'), routing_key='default'),
  )
  registry.enable('application/json')
  </code></pre>
  
  <p>but when the celery worker tries to decode the json object pushed into message broker its giving me this error:</p>
  
  <pre><code>[2016-01-12 17:47:56,602: CRITICAL/MainProcess] Can't decode message body: ContentDisallowed('Refusing to deserialize untrusted content of type application/json; charset=utf-8 (application/json; charset=utf-8)',) [type:u'application/json; charset=utf-8' encoding:u'utf-8' headers:{}]
  
  body: u'{"id":"78094130-9e45-4b0e-9418-e249219e8e65","args":[],"task":"app.task.add","kwargs":[]}' (89b)
  Traceback (most recent call last):
   File "/Users/tech/messaging/venv/lib/python2.7/site-packages/kombu/messaging.py", line 592, in _receive_callback
     decoded = None if on_m else message.decode()
   File "/Users/tech/messaging/venv/lib/python2.7/site-packages/kombu/message.py", line 142, in decode
     self.content_encoding, accept=self.accept)
   File "/Users/tech/messaging/venv/lib/python2.7/site-packages/kombu/serialization.py", line 174, in loads
     raise self._for_untrusted_content(content_type, 'untrusted')
  ContentDisallowed: Refusing to deserialize untrusted content of type application/json; charset=utf-8 (application/json; charset=utf-8)
  </code></pre>
  
  <p>can someone help me out as where i am making mistake?</p>
  
  <p>EDIT:
  on suggestion from scytale</p>
  
  <p>I tried putting 'application/data' and 'application/text' and the error changed from 'Refusing to deserialize' to this:</p>
  
  <pre><code>[2016-01-12 20:59:34,903: WARNING/MainProcess] Received and deleted unknown message. Wrong destination?!?
  
  The full contents of the message body was: body: u'{"id":"03339160-3c43-4327-99ce-a733e58b16b2","args":[],"task":"app.task.add","kwargs":[]}' (89b)
  {content_type:u'application/data' content_encoding:u'utf-8'
   delivery_info:{'consumer_tag': u'None5', 'redelivered': False, 'routing_key': u'exportToExcelQueue', 'delivery_tag': 1, 'exchange': u'exchange'} headers={}}
  </code></pre>
  
  <p>i peeked into the code of celery.worker.consumer.py and found out that its looking for 'task' in message header and when not found throwing an 'UNKNOWN_FORMAT' exception. I then set the header of message like this on java client side:</p>
  
  <blockquote>
    <p>message.getMessageProperties().setHeader("task", "app.task.add");</p>
  </blockquote>
  
  <p>Still the same error</p>