ECF 3.14.12 was just released
Highlights of this Release
New OSGi Remote Services Distribution provider based upon gRPC/Protocol Buffers. Along with a grpc-osgi-generator project...which allows the generation of a service API from a proto3 service declaration...this provider allows gRPC-based services to be exported and imported as OSGi Remote Services. This now includes support for unary, server-streaming, and client-streaming gRPC calls.
Enhanced Support for Bndtools-based development of OSGi Remote Services. The ECF Bndtools Workspace now includes the latest version of ECF Remote Services, along with the gRPC distribution provider, a Hazelcast-based discovery and distribution provider, and project and bndrun templates for creating, running, testing, and debugging OSGi Remote Services in Eclipse+Bndtools 5.
Showing posts with label remoteserviceadmn. Show all posts
Showing posts with label remoteserviceadmn. Show all posts
Tuesday, July 14, 2020
Tuesday, May 05, 2020
Using Google's grpc-java for OSGi Remote Services
A cool thing about Google's grpc is that a service creator can declare a service via a protocol buffers file (.proto file), and then the protoc compiler (along with grpc-java compiler plugin) generates many of the Java classes for both implementing and using that service.
OSGi Remote Services require a service interface to represent the service contract, and this service interface is usually created directly by the programmer. Through a additional plugin, protoc can now generate a OSGi service interface along with all grpc classes... from the .proto file service declaration.
For example, consider the following protocol buffers input file:
syntax = "proto3";
package grpc.health.v1;
option java_multiple_files = true;
option java_outer_classname = "HealthProto";
option java_package = "io.grpc.health.v1";
message HealthCheckRequest {
string message = 1;
}
message HealthCheckResponse {
enum ServingStatus {
UNKNOWN = 0;
SERVING = 1;
NOT_SERVING = 2;
SERVICE_UNKNOWN = 3; // Used only by the Watch method.
}
ServingStatus status = 1;
}
service HealthCheck {
// Unary method
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
// Streaming method
rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse);
}
Running protoc+grpc-java+grpc-osgi-generator on this file results in generation of a HealthCheckService class along with all message classes (e.g. HealthCheckRequest, HealthCheckResponse, HealthProto, etc). All of the Java classes in this example directory were created simply by running protoc+grpc-java+grpc-osgi-generator on the above proto file.
The generated Java classes can then be used to implement an OSGi Remote Service, with HealthCheckService as the service interface. Tt runtime, the HealthCheckServiceImpl can be exported (via the Grpc Provider) which uses grpc to provide the comm and json serialization for the HealthCheckService method calls.
The net effect is that remote service programmers can easily and quickly go from abstract service declaration (in proto file) to a running/functioning OSGi remote service:
- Declare a service in proto file -- example proto file
- Run protoc+grpc-java+grpc-osgi-generator to generate the Java code for the declared service - example Java generated code
- Implement the service API - example service implementation
- Use Declarative Services to export using ECF Remote Services + Grpc Distribution Provider - example (see @Component annotation for OSGi Remote Services-required service properties to trigger export)
The remote service programmer writes no communication nor serialization code (both are provided by the Grpc distribution provider). See here for the complete generated healthcheck api plugin, here for the impl plugin, and here for a simple remote service consumer.
Subscribe to:
Posts (Atom)