Search code examples
wso2wso2-esbwso2-api-managerwso2-enterprise-integratorwso2-micro-integrator

How to make gRPC request in WSO2 micro-integrator via Postman?


I'm trying to make requests in WSO2 micro-integrator via Postman.

I'm using this endpoint (this part of code) to make gRPC request https://github.com/wso2/micro-integrator/tree/master/components/mediation/inbound-endpoints/org.wso2.micro.integrator.inbound.endpoint/src/main/java/org/wso2/carbon/inbound/endpoint/protocol/grpc

My steps to initialize the endpoint:

  1. I create the inbound endpoint manually as an XML file and save it in directory. Then I run the Application

grpcInboundEndpoint.xml:

<?xml version="1.0" encoding="UTF-8"?>
<inboundEndpoint xmlns="http://ws.apache.org/ns/synapse" name="GrpcInboundEndpoint" sequence="inSeq" onError="fault" protocol="grpc" suspend="false">
    <parameters>
        <parameter name="inbound.grpc.port">8888</parameter>
    </parameters>
</inboundEndpoint>

Directory: <MI_Home>/repository/deployment/server/synapse-configs/default/inbound-endpoints

  1. I make a request via Postman. To make the request I use this Protobuf file (which i could find): https://github.com/slahirucd7/siddhi_with_grpc/blob/927eb13e7d3eaa21ea3eba9007e34593eadfdcd7/src/main/proto/EventService.proto

For make request to the EventService.process method I use this sample message:

{
    "headers": {},
    "payload": "test"
}
  1. As a result of request I see the NullPointerException in a shell:
[2024-03-29 14:15:48,233] ERROR {io.grpc.internal.SerializingExecutor} -  - Exception while executing runnable io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed@547800d3 java.lang.NullPointerException
    at java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011)
    at java.util.concurrent.ConcurrentHashMap.putIfAbsent(ConcurrentHashMap.java:1535)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectInbound(Axis2SynapseEnvironment.java:423)
    at org.wso2.carbon.inbound.endpoint.protocol.grpc.GRPCInjectHandler.initiateSequenceAndInjectPayload(GRPCInjectHandler.java:138)
    at org.wso2.carbon.inbound.endpoint.protocol.grpc.GRPCInjectHandler.invokeProcess(GRPCInjectHandler.java:84)
    at org.wso2.carbon.inbound.endpoint.protocol.grpc.InboundGRPCListener$1.process(InboundGRPCListener.java:84)
    at org.wso2.carbon.inbound.endpoint.protocol.grpc.util.EventServiceGrpc$MethodHandlers.invoke(EventServiceGrpc.java:290)
    at io.grpc.stub.ServerCalls$UnaryServerCallHandler$UnaryServerCallListener.onHalfClose(ServerCalls.java:182)
    at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.halfClosed(ServerCallImpl.java:351)
    at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed.runInContext(ServerImpl.java:861)
    at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
    at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)

Status code: 2 UNKNOWN Time: 28 ms

It seems, the EventService.proto file has not enough info to make working requests or I'm not finally understand how to make gRPC request in WSO2 micro-integrator.


Solution

  • Answer to my question is - if you need to request the gRPC service, you have to send request with these data (or similar):

    {
        "headers": {"Content-Type":"json"},
        "payload": "{\"test\":\"yes\"}"
    }
    

    and you will see response like this:

    {
        "headers": {},
        "payload": "{\"test\":\"yes\"}"
    }