Local call

Local call in Dubbo

Feature description

The local call uses the injvm protocol, which is a pseudo-protocol. It does not open ports, does not initiate remote calls, and is only directly associated in the JVM, but executes Dubbo’s Filter chain.

scenes to be used

When we need to call a remote service, the remote service has not been developed yet, and similar services are implemented locally using the injvm protocol. When calling this service, we can call our local implementation service.

How to use

Define the injvm protocol

<dubbo:protocol name="injvm" />

Set the default protocol

<dubbo:provider protocol="injvm" />

Set service protocol

<dubbo:service protocol="injvm" />

Prioritize the use of injvm

<dubbo:consumer injvm="true" .../>
<dubbo:provider injvm="true" .../>

or

<dubbo:reference injvm="true" .../>
<dubbo:service injvm="true" .../>

Notice:

**Dubbo from 2.2.0, each service will be exposed locally by default, and can be referenced locally without any configuration. If you do not want the service to be exposed remotely, you only need to set the protocol to injvm in the provider. **

Automatic exposure

Starting with 2.2.0, every service is exposed locally by default. When referencing services, local services are preferred by default. If you want to reference remote services, you can use the following configuration to force references to remote services.

<dubbo:reference ... scope="remote" />

Last modified January 2, 2023: Enhance en docs (#1798) (95a9f4f6c1)