How to consume gRPC services with SAP Process Orchestration

Introduction


When consuming grpc services, SAP Process Orchestration acts like gRPC a client application calling methods on a server application on a different machine. The server application can be an internal developed microservice or a cloud service like Google Pub/Sub.
With gRPC, a service is defined with methods that can be called remotely with their parameters and return types. The gRPC server implements the interface and processes client calls. On the client side, in this case, SAP PO, the client has a stub (referred to as just a client in some languages) that provides the same methods as the service on the gRPC server.
Most gRPC services use protocol buffers, Google’s mature open source mechanism for serializing structured data.
gRPC leverages HTTP/2 underneath and as such benefits from many of the efficiencies of HTTP/2.

 

Scenario: Pull/Publish messages to GCP PubSub using the gRPC API.
We describe below a use case of consuming Google Cloud Pub/Sub service using the gRPC api. We show how to use the Advantco gRPC adapter to pull data out of a Pub/Sub topic and how to publish data to a Pub/Sub topic.

gRPC services with SAP Process Orchestration_Pic1

 

Prepare the proto files


Get the pubsub.proto file at
https://github.com/googleapis/googleapis/tree/master/google/pubsub/v1
Make sure you download also the other proto definitions used by the pubsub.proto file.
The services and methods available are defined in the pubsub.proto file.
gRPC services with SAP Process Orchestration_Pic2

gRPC services with SAP Process Orchestration_Pic3 

 

Sender channel configuration
To pull a message from a GCP topic, we have to use the Subscriber service. In the Input Parameters, we specify the project and subscription.

gRPC services with SAP Process Orchestration_Pic4 

 

Receiver channel configuration
Here we configure the receiver channel to publish a message to a GCP Pub/Sub topic.

gRPC services with SAP Process Orchestration_Pic5


Payload structure to publish message to a Pub/Sub topic using gRPC.
This message structure is specific for GCP Pub/Sub service.

<PublishRequest>
                    <topic>projects/usdemo-198922/topics/US_GRPC</topic>
                    <messages>
                                         <data>Message sent using Advantco gRPC Adapter</data>
                                         <attributes>
                                                             <Entry>
                                                                                 <key>attribute_1</key>
                                                                                 <value>value_of_attribute_1</value>
                                                             </Entry>
                                                             <Entry>
                                                                                 <key>attribute_2</key>
                                                                                 <value>value_of_attribute_2</value>
                                                             </Entry>
                                         </attributes>
                                         <message_id>02102019</message_id>
                    </messages>
</PublishRequest>

 

Conclusion
Consuming gRPC services with SAP PO is now possible with the Advantco gRPC adapter, this open new possibilities to integration with microservices thru the gRPC protocols.

 

Sources
This is the main site for all gRPC information: 
https://www.grpc.io/
protocol buffer: 
https://developers.google.com/protocol-buffers/docs/proto3#importing-definitions
GCP Pub/Sub API: 
https://cloud.google.com/pubsub/docs/reference/rpc/
Advantco: 
https://advantco.com/products/sap-pi-po-adapters