2

when looking at gRPC, SOAP and REST neither of them use a naming service or registry. I was wondering why that is? what are the advantages to using a registry and what alternative do they use?

adams_john
  • 21
  • 1

2 Answers2

0

RMI registry is a way to expose several separate services on the same java (EE) server. This is roughly similar as for example deploying several gRPC services (created by implementing several different stubs from separate proto service definitions) on the same gRPC server.

The difference is that in gRPC for example, the name of the service combined with proto file's package automatically becomes an ID for the given service instance (you cannot for example deploy 2 different implementations of the same gRPC service in 1 server). Similarly in case of REST, resource's path is its IDs within a given virtual server.
In RMI, OTOH, you can assign any name to an object during the deploy time. Hence you need an entity that resolves these names (usually via JNDI) into specific implementation objects.

Put simply, names/IDs of gRPC services or REST resources are implied by their definitions, while in RMI these things are decoupled.
This is useful in situations where you have several service instances implementing the same interface.

FYI: RMI is not the only example of such design: another one is for example CORBA.

morgwai
  • 2,513
  • 4
  • 25
  • 31
0

RMI means remote method invocation. It is an OO-oriented approach and can only call methods on an object. The system doesn't have any way to call a bare function or a "class method" (a.k.a., static method). It is "OO all the way."

But that means you need a way to get the first object reference so that you can start calling methods and get other objects. That is solved by a registry.

gRPC and SOAP are both RPC-style message passing (just data; no objects) which can have something similar to a class method, by just choosing not to pass an object name. REST is functionally much more similar to RPC than something like RMI, and also passes around data.

REST has "references" to "objects" like https://example.com/orders/1234, but you can still call https://example.com/orders to get the list of orders. In an RMI system you'd need to get a reference to an instance of OrderManager and query it for the system's orders.

RMI is like DCOM, CORBA, Android Binder, and D-Bus. You might find my CloudNativeCon 2019 talk on the subject useful. (I start talking about what makes a reference special earlier in the talk with Unix Domain Socket.) It was a goal of the talk to help people understand how dramatically different RMI is from RPC. Modeling objects in the communication system changes the system substantially, introducing interfaces, type checking for casts, and garbage collection. In my mind, the registry is the least important of the changes, although it is the most visible.

Eric Anderson
  • 24,057
  • 5
  • 55
  • 76