Skip to content

AMQP Queues

theroggio edited this page Nov 27, 2017 · 6 revisions

AQMP Queues

AMQP is for Advanced Message Queuing Protocol, it's the way Main Server comunicates with API Moduls forwarding messages and images to post.

We use the default exchange, because every message received by the Main Server could be uploaded on one or more social media. Every API Modul has its own queue, distincted by routing key.

Main Server reads response message from another queue which links it to all API Moduls; this messages are referred to a specific request to a specific social network and can be a success, an error occured during the upload of the text or an error occured during the upload of the image.

Messages to API Moduls

The format use a flag (0xFF) to separate each information. From now on we'll use the | symbol to indicate the flag.

Format: msg_id | command | parameters ...

The msg_id is the indetifier of the request, so that Main Server, obtained a response, knows which request it's referred to. The command has to be upload_post, other command are used for the authorization phase that's handled by websockets.

Parameters:

  • Token
  • Token Secret
  • Photo Description/Title
  • Photo binary file

Flickr

If there is no photo binary file the upload can't succede because Flickr doesn't support text posts, on the other hand it can be used with photos and no title.

Messages from API Moduls

Main Server receives response messages from all the API Moduls on the same queue, we use the same flag (| as 0xFF) on all comunications.

Format: msg_id | api_id | command | error_code

The msg_id is the identifier of the request. The api_id is the identifier of the social the response is referred to (so that Main Server knows if the same post has been uploaded on each selected social media or not). Command is necessary to know which was the request and how to read following fields. The error code can be one between "exception occured", "image error" or "unknown command".

Links