3.13.2.1.2. TCP

The TCP remote commit provider has several options that are defined as host specifications containing a host name or IP address and an optional port separated by a colon. For example, the host specification saturn.bea.com:1234 represents an InetAddress retrieved by invoking InetAddress.getByName("saturn.bea.com") and a port of 1234.

The TCP provider can be configured by setting the openjpa.RemoteCommitProvider plugin property to contain the appropriate configuration settings. The TCP provider understands the following properties:

  • Port: The TCP port that the provider should listen on for commit notifications. Defaults to 5636.

  • BindAddress: IP address provider should bind for commit notifications. Defaults to 0.0.0.0 (all available addresses).

  • Addresses: A semicolon-separated list of IP addresses to which notifications should be sent. No default value.

  • NumBroadcastThreads: The number of threads to create for the purpose of transmitting events to peers. You should increase this value as the number of concurrent transactions increases. The maximum number of concurrent transactions is a function of the size of the connection pool. See the MaxTotal property of openjpa.ConnectionFactoryProperties in Using the OpenJPA DataSource. Setting a value of 0 will result in behavior where the thread invoking commit will perform the broadcast directly. Defaults to 2.

  • RecoveryTimeMillis: Amount of time to wait in milliseconds before attempting to reconnect to a peer of the cluster when connectivity to the peer is lost. Defaults to 15000.

  • MaxIdle: The number of TCP sockets (channels) to keep open to each peer in the cluster for the transmission of events. Defaults to 2.

  • MaxTotal: Total allowed number of TCP sockets (channels) to open simultaneously between each peer in the cluster. Defaults to 2.

  • RestrictToPeers: Whether incoming connections are only accepted from the hosts listed in Addresses and from this host itself. Connections from any other host are closed and logged as a warning. Set it to false to accept connections from any host, for example when peers connect through network address translation. Defaults to true, except for org.apache.openjpa.event.kubernetes.KubernetesTCPRemoteCommitProvider: it only knows the pods that are ready as peers, but pods that are not ready yet can already send events, so it defaults to false.

  • MaxReceiveConnections: The maximum number of incoming TCP connections from peers that are received simultaneously. Further connections are closed and logged as a warning until a receiving connection ends. Each peer opens up to MaxTotal connections, so this value should be at least the number of peers multiplied by their MaxTotal. A value of 0 or less means no limit. Defaults to 100. Receiving connections use TCP keep-alive, so the connection of a peer that went away without closing it, for example because its host crashed, is only released once the keep-alive of the operating system detects it (on Linux after about two hours by default, see net.ipv4.tcp_keepalive_time).

When several persistence units in the same JVM listen on the same Port, they share one listener: a connection is accepted if any of them accepts it, and the highest MaxReceiveConnections applies.

To configure a factory to use the TCP provider, your properties might look like the following:

Example 164. TCP Remote Commit Provider Configuration
<property name="openjpa.RemoteCommitProvider"
    value="tcp(Addresses=10.0.1.10;10.0.1.11;10.0.1.12;10.0.1.13)"/>