Search in sources :

Example 1 with GrpcMethodHandler

use of org.apache.camel.component.grpc.server.GrpcMethodHandler in project camel-quarkus by apache.

the class QuarkusBindableServiceFactory method createBindableService.

@Override
public BindableService createBindableService(GrpcConsumer consumer) {
    GrpcEndpoint endpoint = (GrpcEndpoint) consumer.getEndpoint();
    CamelContext camelContext = endpoint.getCamelContext();
    Class<?> baseClass = GrpcUtils.constructGrpcImplBaseClass(endpoint.getServicePackage(), endpoint.getServiceName(), camelContext);
    // Find the BindableService implementation that was generated in GrpcProcessor and configure the GrpcMethodHandler
    CamelQuarkusBindableService bindableService = bindableServices.stream().filter(service -> baseClass.isAssignableFrom(service.getClass())).findFirst().orElseThrow(() -> new IllegalStateException("Unable to find generated class for service " + endpoint.getServiceName()));
    GrpcMethodHandler methodHandler = new GrpcMethodHandler(consumer);
    bindableService.setMethodHandler(methodHandler);
    return bindableService;
}
Also used : CamelContext(org.apache.camel.CamelContext) GrpcEndpoint(org.apache.camel.component.grpc.GrpcEndpoint) GrpcMethodHandler(org.apache.camel.component.grpc.server.GrpcMethodHandler)

Aggregations

CamelContext (org.apache.camel.CamelContext)1 GrpcEndpoint (org.apache.camel.component.grpc.GrpcEndpoint)1 GrpcMethodHandler (org.apache.camel.component.grpc.server.GrpcMethodHandler)1