Return value from ExecutorService

Let’s imagine that we have a task: And the code for its execution: And we need to get the return value after completing the task. For this, Runnable must be replaced with Callable: And when sending a task to an ExecutorService, you need to use submit method instead of execute, and capture a Future<Object> object:

READ MORE

Determine versions of dependencies of library Maven

Imagine you need to determine the version of Apache commons-lang dependency in ZooKeeper 3.6.2. The easiest way to do this is to find the artifact page in the mvn repository. For ZooKeeper 3.6.2: https://mvnrepository.com/artifact/org.apache.zookeeper/zookeeper/3.6.2.  On the page, you need to find the Compile Dependencies section, and find the required dependency there. In our case, the commons-lang 2.6 dependency […]

READ MORE

Share data between interceptor and service gRPC

Let’s imagine that we need to pass data between the interceptor and the service (or we need to sharedata between the interceptor and the service, or we need to exchange data between the interceptor and the service). We have a service: We have the code for starting the gRPC server: In your Interceptor class, in […]

READ MORE

Get client IP address from request gRPC

Let’s imagine that we need to get the client’s ip address from the request.  We have a service:  And the code for starting the gRPC server:  Let’s create a new class:  And register a new interceptor in the gRPC server launch code:  Done. If you need to pass the ip address from the interceptor to the […]

READ MORE

Failed to deploy artifacts: Could not find artifact Maven

When you try to execute the mvn deploy command, you may encounter the error: The error could actually means (thanks to randomsimon):  That is, maven cannot find the repository at the specified url. Check, that the url of the repository is correct, and in general it exists and specified.  A repository url can be specified via […]

READ MORE

ZooKeeper x509 certificates ACL

The documentation states that setting an ACL via the ZooKeeper CLI usually works like this: In the case of the x509 scheme, the Authenticated ID for the user is the DN string of their certificate. In confirmation of this, when a user connects via a certificate, there is a line in the server log: Now, […]

READ MORE