Distributed RPC is used to query on and retrieve the result from the Trident topology on the fly. Storm has an in-built distributed RPC server. The distributed RPC server receives the RPC request from the client and passes it to the topology. The topology processes the request and sends the result to the distributed RPC server, which is redirected by the distributed RPC server to the client.
We can configure the distributed RPC server by setting the following properties in the storm.yaml
file:
drpc.servers: - "nimbus-node"
Here, nimbus-node
is the IP address of the distributed RPC server.
Now, run the following command on the nimbus-node
machine to start the distributed RPC server:
bin/storm drpc
Let's consider that we are storing the count aggregation of the sample Trident topology in the database and want to retrieve the count for the given country on the fly. Then, we will need to use the distributed RPC feature to achieve this. The following example code shows how we can...