To run in development mode, follow these steps:
- Duplicate the
.env.examplefile to.env - Run
docker-compose up -d - Access the RabbitMQ management interface and create an exchange of type
fannout. This will be aDead Letter Exchangeto receive messages that were not processed. - Create a
Dead Letter Queueand bind it to theDead Letter Exchangeyou just created. There is no need for arouting_key. - In the
.envfile, specify the name of theDead Letter Exchangein the parameter:RABBITMQ_DLX - Create a service account in GCP with permission to write to Google Cloud Storage. Download the JSON file with the credentials and save it in the project root with the exact name:
bucket-credential.json
To run the encoder, execute the make server command directly in the container. Example:
docker exec encoder-new2_app_1 make serverWhere microsservico-enconder_app_1 is the name of the container generated by docker-compose.
For a message to be parsed by the encoder system, it must be in the following JSON format:
{
"resource_id": "my-resource-id-can-be-a-uuid-type",
"file_path": "convite.mp4"
}resource_id: Represents the ID of the video you want to convert. It is a string.file_path: The full path of the mp4 video within the bucket.
For each processed video, the encoder will send the processing result to an exchange (to be configured in .env).
If the processing was successful, the JSON response format will be:
{
"id":"bbbdd123-ad05-4dc8-a74c-d63a0a2423d5",
"output_bucket_path":"codeeducationtest",
"status":"COMPLETED",
"video":{
"encoded_video_folder":"b3f2d41e-2c0a-4830-bd65-68227e97764f",
"resource_id":"aadc5ff9-0b0d-13ab-4a40-a11b2eaa148c",
"file_path":"convite.mp4"
},
"Error":"",
"created_at":"2020-05-27T19:43:34.850479-04:00",
"updated_at":"2020-05-27T19:43:38.081754-04:00"
}Where encoded_video_folder is the folder containing the converted video.
If there was an error during processing, the JSON response format will be:
{
"message": {
"resource_id": "aadc5ff9-010d-a3ab-4a40-a11b2eaa148c",
"file_path": "convite.mp4"
},
"error":"Reason for the error"
}Additionally, the encoder will send the original message that encountered a problem during processing to a dead letter exchange. Simply configure the desired DLX in the .env file under the parameter: RABBITMQ_DLX.