Settings for the order preparation service.
The incoming AMQP queue settings. It has the following keys:
The outgoing AMQP settings. It has the following keys:
There is a single callback function used for the queue consumption, consumer.consume_order().
The callback to consume an order message from the queue.
This callback will prepare the order and then publish it to the Order DCS queue. Once that is done, it acknowledges the incoming message.
If processing fails, a critical log message is written and the incoming message is not acknowledged.
Parameters:
- body
- The body of the queue message. This will be a single JSON object representing an order.
- message
- The message header of the queue message. This is discarded.
This callback is hooked up to the server using run.connect_consumer() which also uses lib.get_broker_connection().
Return a connection with a consumer attached for the incoming queue.
The settings defined in order_prep.settings.INCOMING_AMQP are used to do this.
Return a BrokerConnection for the given settings.
Parameters:
- amqp_settings
- A dictionary containing the connection settings. The dictionary must have the HOST, PORT, USER, PASSWORD and VHOST keys set. See order_prep.settings.INCOMING_AMQP and order_prep.settings.OUTGOING_AMQP for examples.
run.connect_consumer() is used by run.runloop() to set up a connection from which it consumes events forever.
Set up a connection and repeatedly consume events.
Once an order has been received from the queue and processed in to its representative dictionary, it is passed to prepare_order(). prepare_order() in turn farms it out to normalise_lines() to generate a list of jobs in the order which can then be passed to add_completion_stages().
Returns a prepared order.
Parameters:
- order
- An order dictionary.
A prepared order dictionary.
No attribute but order_lines will have been modified.
Normalises order lines for processing by the rest of the GD stack.
Parameters:
- order
- An order dictionary.
An order dictionary with normalised order lines.
No attribute but order_lines will have been modified.
Adds completion stages to the order lines in an order.
Parameters:
- order
- An order dictionary.
An order dictionary with completion stages set on all order lines.
No attribute but order_lines will have been modified.
Once an order has been prepared for the fulfilment process, it is published to the outgoing queue by prepare_order(). This is done using publish_order() which in turn uses get_producer() to get the producer to publish to.
Publish an order to the outgoing queue defined in settings.
Parameters:
- order
- The order to be published (this will be the body of the outgoing message).
Return a kombu.messaging.Producer for the outgoing server.