In this section:
Overview
The Parasoft gRPC Listener Extension adds support for the Google Remote Procedure Call message format so that Virtualize assets can read a single message from a topic and respond with a single message on another topic.
Requirements
- gRPC 1.0.0 or later
- Parasoft Virtualize 2020.2 or later
Installation
This artifact can be installed from the UI or the command line.
UI Installation
- Choose Parasoft > Preferences.
- In the System Properties preferences page, click Add JARs.
- In the file chooser that opens, select com.parasoft.virtualize.listener.grpc-<version>.jar.
- Click Apply and restart Virtualize.
Command Line Installation
Add the com.parasoft.soavirt.listener.grpc-<version>.jar file to the system.properties.classpath property in your settings properties file. For example:
system.properties.classpath=<path to jar>/com.parasoft.soavirt.transport.grpc-1.0.jar
Usage
After installation, the gRPC Listener option will appear in the Virtual Asset Deployment Settings. The gRPC implementation can be used for all responders except SQL Responders.
- Open the virtual asset settings and click the Transport tab.
- Click the Custom tab and configure the listener settings (see Configuration). If your system has more than one custom extension, choose gRPC Lister from the Select Implementation drop-down menu.
Configuration
There are four groups of settings to configure: Connection, Injected Headers, Transport Layer Security, and Logging. Each group is described below.
Connection Settings
Listen Port | Specify the port Virtualize should open for receiving incoming gRPC calls. Virtualize will select an open port automatically when set to If this field is left blank, this virtual asset will not listen for gRPC calls. |
---|---|
Service Name | Specify the gRPC service name that corresponds with this virtual asset. |
Method Names | Specify the gRPC methods for the above service to be handled by this virtual asset. Separate multiple entries with commas. |
Method Types | Specify the method type or types, for example unary or stream . Separate multiple entries with commas. The default is unary . |
Injected Headers Settings
Method Header | Specify the method header. The default is gRPC-Method . |
---|---|
Call ID Header | Specify the call ID header. The default is gRPC-Call-ID . |
Notification Header | Specify the notification header. The default is gRPC-Notification . |
Transport Layer Security Settings
Auth Mechanism | Specify the authorization mechanism you want to use to connect to the gRPC server. Options are SSL and insecure . The default is insecure . |
---|---|
Certificate Chain File | Specify the path to the certificate chain file in PEM format. This field is ignored when the Auth Mechanism is set to |
Private Key File | Specify the path to the private key file in PEM format. This field is ignored when the Auth Mechanism is set to |
Logging Settings
Log Level | Specify how much information you want logged to the console. The default is |
---|
Virtualizing Different gRPC Services
Each virtual asset represents one gRPC service with one or more methods. Deploy multiple virtual assets on the same gRPC port to represent multiple gRPC services on the same gRPC server.
Virtualizing Different gRPC Methods
A gRPC method may operate as one of four types:
- Unary
- Server streaming
- Client streaming
- Bidirectional streaming
Unary Method
Virtualize uses a single message responder to emulate one call to a unary gRPC method. This is the default mode for methods in the gRPC custom listener. The client request is handled by the responder if the correlation criteria matches, then the responder returns the response to the gRPC client. Set a transport header correlation of gRPC-Method
to match the message responder to the gRPC method name.
Streaming Methods
Multiple message responders are needed to emulate the streaming gRPC method types. In each case the client requests and server responses can be decoupled. Set a transport header correlation of gRPC-Notification
to trigger the responder at the appropriate point in the stream. Supported values are: next
, completed
, and error
.
Set the message responder options for Message Exchange Pattern to Notification Only if the responder for this point in the stream should not send any response message back.
In order to send multiple response messages together on the steam, or send an error or completed notification, you will need to chain a messaging client to the request payload output of the message responder and map it to the same Call ID that is being handled by the responder. To do so:
- Right-click the responder and go to Add Output... > Incoming Request > Transport Header, then select Header Data Bank.
- Click Add Header, then select the header that's added and click Modify to add a header extraction for
gRPC-Call-ID
to a custom column. Click OK when you're done. - Right-click the responder again and go to Add Output... > Incoming Request > Payload, then select Messaging Client. Configure the transport of the messaging client to use gRPC with the parameterized CALL_ID in the streaming section.
The chained messaging client will send on the response stream for the virtualized gRPC call back to the client.
Third-party Content
This extension includes items that have been sourced from third parties as outlined below.
- gRPC (Apache License 2.0)
- PerfMark (Apache License 2.0)
- SLF4J (MIT License)
Additional license details are available in this plugin's licenses folder.