carrot.objects.
BaseMessageSerializer
(message=None)¶A class that defines how to convert a RabbitMQ message into an executable python function from your Django project, and back again
Parameters: | message (Message) – the RabbitMQ message |
---|
body
()¶Returns the content to be added to the RabbitMQ message body
By default, this implementation returns a simple dict in the following format:
{
'args': ('tuple', 'of', 'positional', 'arguments'),
'kwargs': {
'keyword1': 'value',
'keyword2': True
}
}
Return type: | dict |
---|
get_task
(properties, body)¶Identifies the python function to be executed from the content of the RabbitMQ message. By default, Carrot returns the value of the self.type_header header in the properties.
Once this string has been found, carrot uses importlib to return a callable python function.
Parameters: |
|
---|---|
Returns: | a callable python function |
properties
()¶Returns a dict from which a pika.BasicProperties
object can be created
In this implementation, the following is returned: - headers - content type - priority - message id - message type
Return type: | dict |
---|
carrot.objects.
DefaultMessageSerializer
(message=None)¶carrot.objects.
Message
(task, virtual_host=None, queue='default', routing_key=None, exchange='', priority=0, task_args=(), task_kwargs=None)¶A message to publish to RabbitMQ. Takes the following parameters:
Parameters: |
|
---|
Note
Your RabbitMQ queue must support message priority for the priority parameter to have any affect. You need to define the x-max-priority header when creating your RabbitMQ queue to do this. See Priority Queue Support for more details. Carrot applies a maximum priority of 255 by default to all queues it creates automatically.
Warning
You should not attempt to create instances of this object yourself. You should use the
carrot.utilities.create_msg()
function instead
connection_channel
¶Gets or creates the queue, and returns a tuple containing the object’s VirtualHost’s blocking connection, and its channel
publish
(pika_log_level=40)¶Publishes the message to RabbitMQ queue and creates a MessageLog object so the progress of the task can be tracked in the Django project’s database
Parameters: | pika_log_level (logging level) – the pika log level to set. defaults to logging.ERROR |
---|