A Netty server accepts HTTP requests on port 8080
. This server receives an HTTP POST
request, parses its JSON payload, makes sure the user is authenticated, uploads media file(s) (if any) to a media server & injects the returned URL(s) into the JSON payload, stamps the payload with a UUID & forwards it to a RabbitMQ queue using the requests_mapping.properties
file, then it waits for a response with the same UUID and returns to the user when it gets a response with a matching UUID.
Each service consists of an RMQ consumer, RMQ producer & an ExecutorService
. Each service also has its own unique request & response queue.
- RMQ Consumer: Receives messages from the service's request queue
- RMQ Producer: Sends messages to the service's response queue
- ExecutorService: Initializes a thread pool & makes sure every incoming message gets allocated a thread from the thread pool
- Clone the repo & open in IntelliJ
- Change directory to repository folder
cd <path/to/repo>
- Run
docker-compose up
- Open Maven Projects tab, expand
Lifecycle
& clickcompile
- Open Maven Projects tab, expand
Plugins
, expandactivejdbc-instrumentation
& clickactivejdbc-instrumentation:instrument
- Navigate to
persistence
package, expandsql/users
, click & runMigrations.java
. This file creates the SQL tables. - Navigate to
persistence
package, expandnosql
, click & runArangoInterfaceMethods.java
. This file creates the NoSQL tables & graphs.
- Run
src/main/java/http_server/Server.java
, this makes sure that the server is running on port 8080 & ready to accept HTTP requests - Run
src/main/java/services/users/Server.java
, this file initializes an RMQ consumer for the users service that will be later used to authenticate requests - Run
src/main/java/services/activities/Server.java
, this file initializes an RMQ consumer for activities that will be later used by other services - Run
src/main/java/services/<your-service>/Server.java
, this also initializes an RMQ consumer for the specified service
- Open Postman
- In the URL field, write
http://localhost:8080/
- Choose the type of the request to be
POST
request - Underneath the URL field, click on
Body
, chooseraw
from the presented options - Send a Sign up or Sign in request to obtain a token that will be used for authenticating other requests
{
"method" : "signup",
"params": {
"username" : "john_doe",
"email" : "[email protected]",
"password" : "123456",
"isPrivate": false,
"fullName" : "John Doe",
"gender" : "male"
}
}
- Using the returned token, go ahead and create a new tab in Postman, choose the same options mentioned eariler. Before sending the request, go to
Headers
tab and addx-access-token
with the obtained token (obviously, we don't add any headers in the case of sending signup or login requests)