@Documented @Retention(value=RUNTIME) @Target(value={FIELD,METHOD,ANNOTATION_TYPE}) public @interface DubboReference
It is recommended to use @DubboReference on the @Bean method in the Java-config class, but not on the fields or setter methods to be injected.
Step 1: Register ReferenceBean in Java-config class:
@Configuration
public class ReferenceConfiguration {
@Bean
@DubboReference(group = "demo")
public ReferenceBean<HelloService> helloService() {
return new ReferenceBean();
}
@Bean
@DubboReference(group = "demo", interfaceClass = HelloService.class)
public ReferenceBean<GenericService> genericHelloService() {
return new ReferenceBean();
}
}
Step 2: Inject ReferenceBean by @Autowired
public class FooController {
@Autowired
private HelloService helloService;
@Autowired
private GenericService genericHelloService;
}
org.apache.dubbo.config.spring.reference.ReferenceBeanBuilder,
org.apache.dubbo.config.spring.ReferenceBean| Modifier and Type | Optional Element and Description |
|---|---|
int |
actives
Maximum active requests allowed, default value is 0
|
String |
application
Deprecated.
This attribute was deprecated, use bind application/module of spring ApplicationContext
|
boolean |
async
Whether to enable async invocation, default value is false
|
String |
cache
Specify cache implementation for service invocation, legal values include: lru, threadlocal, jcache
|
int |
callbacks
The callback instance limit peer connection
|
boolean |
check
Check if service provider is available during boot up, default value is true
|
String |
client
Client transport type, default value is "netty"
|
String |
cluster
Cluster strategy, legal values include: failover, failfast, failsafe, failback, forking
you can use
ClusterRules.FAIL_FAST …… |
int |
connections
Maximum connections service provider can accept, default value is 0 - connection is shared
|
String |
consumer
Consumer associated name
|
String[] |
filter
Filters for service invocation
|
boolean |
generic
Deprecated.
Do not need specify generic value, judge by injection type and interface class
|
String |
group
Service group, default value is empty string
|
String |
id
The id
NOTE: The id attribute is ignored when using @DubboReference on @Bean method
|
boolean |
init
Whether eager initialize the reference bean when all properties are set, default value is true ( null as true)
|
boolean |
injvm
Deprecated.
using scope="local" or scope="remote" instead
|
Class<?> |
interfaceClass
Interface class, default value is void.class
|
String |
interfaceName
Interface class name, default value is empty string
|
String |
layer
Service layer, default value is empty string
|
boolean |
lazy
Whether to make connection when the client is created, the default value is false
|
String[] |
listener
Listeners for service exporting and unexporting
|
String |
loadbalance
Load balance strategy, legal values include: random, roundrobin, leastactive
you can use
LoadbalanceRules.RANDOM …… |
String |
merger
Service merger
|
Method[] |
methods
methods support
|
String |
mock
Service mock name, use interface name + Mock if not set
|
String |
module
Module associated name
|
String |
monitor
Monitor associated name
|
String |
onconnect
Callback method name when connected, default value is empty string
|
String |
ondisconnect
Callback method name when disconnected, default value is empty string
|
String |
owner
Service owner, default value is empty string
|
String[] |
parameters
Customized parameter key-value pair, for example: {key1, value1, key2, value2} or {"key1=value1", "key2=value2"}
|
String |
protocol
The communication protocol of Dubbo Service
|
String[] |
providedBy
declares which app or service this interface belongs to
|
String |
providerNamespace
assign the namespace that provider belong to
|
int |
providerPort
The service port of the provider
|
String |
proxy
How the proxy is generated, legal values include: jdk, javassist
|
String |
reconnect
Whether to reconnect if connection is lost, if not specify, reconnect is enabled by default, and the interval
for retry connecting is 2000 ms
|
boolean |
referAsync
Weather the reference is refer asynchronously
|
String[] |
registry
Registry associated name
|
int |
retries
Service invocation retry times
|
String |
scope
the scope for referring/exporting a service, if it's local, it means searching in current JVM only.
|
boolean |
sent
Whether the async request has already been sent, the default value is false
|
String[] |
services
Deprecated.
using
providedBy() |
boolean |
sticky
Whether to stick to the same node in the cluster, the default value is false
|
String |
stub
Service stub name, use interface name + Stub if not set
|
boolean |
stubevent
Export an stub service for event dispatch, default value is false.
|
String |
tag
Service tag name
|
int |
timeout
Timeout value for service invocation, default value is 0
|
boolean |
unloadClusterRelated
unload Cluster related in mesh mode
|
String |
url
Service target URL for direct invocation, if this is specified, then registry center takes no effect.
|
String |
validation
Whether to use JSR303 validation, legal values are: true, false
|
String |
version
Service version, default value is empty string
|
public abstract Class<?> interfaceClass
public abstract String interfaceName
public abstract String version
public abstract String group
public abstract String url
public abstract String client
@Deprecated public abstract boolean generic
@Deprecated public abstract boolean injvm
public abstract boolean check
public abstract boolean init
ReferenceConfigBase.shouldInit()public abstract boolean lazy
public abstract boolean stubevent
see org.apache.dubbo.rpc.Constants#STUB_EVENT_METHODS_KEY
public abstract String reconnect
see org.apache.dubbo.remoting.Constants#DEFAULT_RECONNECT_PERIOD
public abstract boolean sticky
see Constants#DEFAULT_CLUSTER_STICKY
public abstract String proxy
public abstract String stub
public abstract String cluster
ClusterRules.FAIL_FAST ……public abstract int connections
public abstract int callbacks
see org.apache.dubbo.rpc.Constants#DEFAULT_CALLBACK_INSTANCES
public abstract String onconnect
public abstract String ondisconnect
public abstract String owner
public abstract String layer
public abstract int retries
see Constants#DEFAULT_RETRIES
public abstract String loadbalance
LoadbalanceRules.RANDOM ……public abstract boolean async
public abstract boolean sent
public abstract String mock
public abstract String validation
public abstract int timeout
public abstract String cache
public abstract String[] filter
see Filter
public abstract String[] listener
see ExporterListener
public abstract String[] parameters
@Deprecated public abstract String application
public abstract String module
public abstract String consumer
public abstract String monitor
public abstract String[] registry
public abstract String protocol
public abstract String tag
public abstract String merger
public abstract Method[] methods
public abstract String id
@Deprecated public abstract String[] services
providedBy()RegistryConstants.SUBSCRIBED_SERVICE_NAMES_KEYpublic abstract String[] providedBy
RegistryConstants.PROVIDED_BYpublic abstract int providerPort
AbstractReferenceConfig.providerPortpublic abstract String providerNamespace
AbstractReferenceConfig.providerNamespacepublic abstract String scope
org.apache.dubbo.rpc.Constants#SCOPE_LOCAL,
org.apache.dubbo.rpc.Constants#SCOPE_REMOTEpublic abstract boolean referAsync
public abstract boolean unloadClusterRelated
ReferenceConfigBase.unloadClusterRelatedCopyright © 2011–2020 The Apache Software Foundation. All rights reserved.