Class JSONRPCTransportConfigBuilder


public class JSONRPCTransportConfigBuilder extends ClientTransportConfigBuilder<JSONRPCTransportConfig, JSONRPCTransportConfigBuilder>
Builder for creating JSONRPCTransportConfig instances.

This builder provides a fluent API for configuring the JSON-RPC transport protocol. All configuration options are optional - if not specified, sensible defaults are used:

  • HTTP client: Auto-selected via A2AHttpClientFactory (prefers Vert.x, falls back to JDK)
  • Interceptors: None

Basic usage:

// Minimal configuration (uses all defaults)
JSONRPCTransportConfig config = new JSONRPCTransportConfigBuilder()
    .build();

Client client = Client.builder(agentCard)
    .withTransport(JSONRPCTransport.class, config)
    .build();

Custom HTTP client:

// Configure custom HTTP client for connection pooling, timeouts, etc.
A2AHttpClient httpClient = new ApacheHttpClient()
    .withConnectionTimeout(Duration.ofSeconds(10))
    .withMaxConnections(50);

JSONRPCTransportConfig config = new JSONRPCTransportConfigBuilder()
    .httpClient(httpClient)
    .build();

With interceptors:

JSONRPCTransportConfig config = new JSONRPCTransportConfigBuilder()
    .addInterceptor(new LoggingInterceptor())
    .addInterceptor(new MetricsInterceptor())
    .addInterceptor(new RetryInterceptor(3))
    .build();

Direct usage in ClientBuilder:

// Can pass builder directly to withTransport()
Client client = Client.builder(agentCard)
    .withTransport(JSONRPCTransport.class, new JSONRPCTransportConfigBuilder()
        .httpClient(customClient)
        .addInterceptor(loggingInterceptor))
    .build();
See Also:
  • Constructor Details

    • JSONRPCTransportConfigBuilder

      public JSONRPCTransportConfigBuilder()
  • Method Details

    • httpClient

      public JSONRPCTransportConfigBuilder httpClient(A2AHttpClient httpClient)
      Set the HTTP client to use for JSON-RPC requests.

      Custom HTTP clients can provide:

      • Connection pooling and reuse
      • Custom timeout configuration
      • SSL/TLS configuration
      • Proxy support
      • Custom header handling

      If not specified, a client is auto-selected via A2AHttpClientFactory.

      Example:

      A2AHttpClient client = new CustomHttpClient()
          .withConnectTimeout(Duration.ofSeconds(5))
          .withReadTimeout(Duration.ofSeconds(30))
          .withConnectionPool(10, 50);
      
      builder.httpClient(client);
      
      Parameters:
      httpClient - the HTTP client to use
      Returns:
      this builder for method chaining
    • build

      public JSONRPCTransportConfig build()
      Build the JSON-RPC transport configuration.

      If no HTTP client was configured, one is auto-selected via A2AHttpClientFactory. Any configured interceptors are transferred to the configuration.

      Specified by:
      build in class ClientTransportConfigBuilder<JSONRPCTransportConfig, JSONRPCTransportConfigBuilder>
      Returns:
      the configured JSON-RPC transport configuration