To run in development mode, follow these steps:
- Duplicate the file
.env.example
to.env
- Run the
docker-compose up -d
command - Access the RabbitMQ administration and create an exchange of type
fanout
. It will serve as aDead Letter Exchange
to receive messages that are not processed. - Create a
Dead Letter Queue
and bind it to theDead Letter Exchange
that was just created. There is no need for a routing_key. - In the
.env
file, specify the name of theDead Letter Exchange
in the parameter:RABBITMQ_DLX
- Create a service account on GCP that has permission to write to Google Cloud Storage. Download the JSON file with the credentials and save it in the project's root exactly with the name:
bucket-credential.json
To execute the encoder, run the make server
command directly in the container. Example:
docker exec encoder-new2_app_1 make server
Where encoder-new2_app_1
is the name of the container generated by docker-compose.
For a message to be parsed by the encoder system, it must arrive 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 of string type.file_path
: Is 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 has been completed successfully, the JSON return pattern 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":"invite.mp4"
},
"Error":"",
"created_at":"2020-05-27T19:43:34.850479-04:00",
"updated_at":"2020-05-27T19:43:38.081754-04:00"
}
Being that encoded_video_folder
is the folder that contains the converted video.
If the processing has encountered any error, the JSON return pattern will be:
{
"message": {
"resource_id": "aadc5ff9-010d-a3ab-4a40-a11b2eaa148c",
"file_path": "invite.mp4"
},
"error":"Reason for the error"
}
In addition, the encoder will send the original message that had a problem during processing to a dead letter exchange.
Just configure the desired DLX in the .env file in the parameter: RABBITMQ_DLX