Merge branch 'master' into bael-16656

This commit is contained in:
Josh Cummings
2019-10-26 15:37:05 -06:00
committed by GitHub
parent db85c8f275
commit 0be2175c89
20539 changed files with 1643630 additions and 0 deletions
@@ -0,0 +1,57 @@
package com.baeldung.dubbo;
import com.alibaba.dubbo.config.ApplicationConfig;
import com.alibaba.dubbo.config.ReferenceConfig;
import com.alibaba.dubbo.config.RegistryConfig;
import com.alibaba.dubbo.config.ServiceConfig;
import com.baeldung.dubbo.remote.GreetingsService;
import com.baeldung.dubbo.remote.GreetingsServiceImpl;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author aiet
*/
public class APIConfigurationLiveTest {
@Before
public void initProvider() {
ApplicationConfig application = new ApplicationConfig();
application.setName("demo-provider");
application.setVersion("1.0");
RegistryConfig registryConfig = new RegistryConfig();
registryConfig.setAddress("multicast://224.1.1.1:9090");
ServiceConfig<GreetingsService> service = new ServiceConfig<>();
service.setApplication(application);
service.setRegistry(registryConfig);
service.setInterface(GreetingsService.class);
service.setRef(new GreetingsServiceImpl());
service.export();
}
@Test
public void givenProviderConsumer_whenSayHi_thenGotResponse() {
ApplicationConfig application = new ApplicationConfig();
application.setName("demo-consumer");
application.setVersion("1.0");
RegistryConfig registryConfig = new RegistryConfig();
registryConfig.setAddress("multicast://224.1.1.1:9090");
ReferenceConfig<GreetingsService> reference = new ReferenceConfig<>();
reference.setApplication(application);
reference.setRegistry(registryConfig);
reference.setInterface(GreetingsService.class);
GreetingsService greetingsService = reference.get();
String hiMessage = greetingsService.sayHi("baeldung");
assertEquals("hi, baeldung", hiMessage);
}
}
@@ -0,0 +1,70 @@
package com.baeldung.dubbo;
import com.baeldung.dubbo.remote.GreetingsService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.ArrayList;
import java.util.List;
import java.util.OptionalDouble;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author aiet
*/
public class ClusterDynamicLoadBalanceLiveTest {
private ExecutorService executorService;
@Before
public void initRemote() {
executorService = Executors.newFixedThreadPool(2);
executorService.submit(() -> {
ClassPathXmlApplicationContext remoteContext = new ClassPathXmlApplicationContext("cluster/provider-app-default.xml");
remoteContext.start();
});
executorService.submit(() -> {
SECONDS.sleep(2);
ClassPathXmlApplicationContext backupRemoteContext = new ClassPathXmlApplicationContext("cluster/provider-app-special.xml");
backupRemoteContext.start();
return null;
});
}
@Test
public void givenProviderCluster_whenConsumerSaysHi_thenResponseBalanced() throws InterruptedException {
ClassPathXmlApplicationContext localContext = new ClassPathXmlApplicationContext("cluster/consumer-app-lb.xml");
localContext.start();
GreetingsService greetingsService = (GreetingsService) localContext.getBean("greetingsService");
List<Long> elapseList = new ArrayList<>(6);
for (int i = 0; i < 6; i++) {
long current = System.currentTimeMillis();
String hiMessage = greetingsService.sayHi("baeldung");
assertNotNull(hiMessage);
elapseList.add(System.currentTimeMillis() - current);
SECONDS.sleep(1);
}
OptionalDouble avgElapse = elapseList
.stream()
.mapToLong(e -> e)
.average();
assertTrue(avgElapse.isPresent());
assertTrue(avgElapse.getAsDouble() > 1666.0);
}
@After
public void destroy() {
executorService.shutdown();
}
}
@@ -0,0 +1,52 @@
package com.baeldung.dubbo;
import com.baeldung.dubbo.remote.GreetingsService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* @author aiet
*/
public class ClusterFailoverLiveTest {
private ExecutorService executorService;
@Before
public void initRemote() {
executorService = Executors.newFixedThreadPool(2);
executorService.submit(() -> {
ClassPathXmlApplicationContext backupRemoteContext = new ClassPathXmlApplicationContext("cluster/provider-app-special.xml");
backupRemoteContext.start();
});
executorService.submit(() -> {
ClassPathXmlApplicationContext remoteContext = new ClassPathXmlApplicationContext("cluster/provider-app-failover.xml");
remoteContext.start();
});
}
@Test
public void givenProviderCluster_whenConsumerSaysHi_thenGotFailoverResponse() {
ClassPathXmlApplicationContext localContext = new ClassPathXmlApplicationContext("cluster/consumer-app-failtest.xml");
localContext.start();
GreetingsService greetingsService = (GreetingsService) localContext.getBean("greetingsService");
String hiMessage = greetingsService.sayHi("baeldung");
assertNotNull(hiMessage);
assertEquals("hi, failover baeldung", hiMessage);
}
@After
public void destroy() {
executorService.shutdown();
}
}
@@ -0,0 +1,47 @@
package com.baeldung.dubbo;
import com.baeldung.dubbo.remote.GreetingsService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
/**
* @author aiet
*/
public class ClusterFailsafeLiveTest {
private ExecutorService executorService;
@Before
public void initRemote() {
executorService = Executors.newFixedThreadPool(1);
executorService.submit(() -> {
ClassPathXmlApplicationContext remoteContext = new ClassPathXmlApplicationContext("cluster/provider-app-special-failsafe.xml");
remoteContext.start();
});
}
@Test
public void givenProviderCluster_whenConsumerSaysHi_thenGotFailsafeResponse() {
ClassPathXmlApplicationContext localContext = new ClassPathXmlApplicationContext("cluster/consumer-app-failtest.xml");
localContext.start();
GreetingsService greetingsService = (GreetingsService) localContext.getBean("greetingsService");
String hiMessage = greetingsService.sayHi("baeldung");
assertNull(hiMessage);
}
@After
public void destroy() {
executorService.shutdown();
}
}
@@ -0,0 +1,66 @@
package com.baeldung.dubbo;
import com.baeldung.dubbo.remote.GreetingsService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.ArrayList;
import java.util.List;
import java.util.OptionalDouble;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* @author aiet
*/
public class ClusterLoadBalanceLiveTest {
private ExecutorService executorService;
@Before
public void initRemote() {
executorService = Executors.newFixedThreadPool(2);
executorService.submit(() -> {
ClassPathXmlApplicationContext remoteContext = new ClassPathXmlApplicationContext("cluster/provider-app-default.xml");
remoteContext.start();
});
executorService.submit(() -> {
ClassPathXmlApplicationContext backupRemoteContext = new ClassPathXmlApplicationContext("cluster/provider-app-special.xml");
backupRemoteContext.start();
});
}
@Test
public void givenProviderCluster_whenConsumerSaysHi_thenResponseBalanced() {
ClassPathXmlApplicationContext localContext = new ClassPathXmlApplicationContext("cluster/consumer-app-lb.xml");
localContext.start();
GreetingsService greetingsService = (GreetingsService) localContext.getBean("greetingsService");
List<Long> elapseList = new ArrayList<>(6);
for (int i = 0; i < 6; i++) {
long current = System.currentTimeMillis();
String hiMessage = greetingsService.sayHi("baeldung");
assertNotNull(hiMessage);
elapseList.add(System.currentTimeMillis() - current);
}
OptionalDouble avgElapse = elapseList
.stream()
.mapToLong(e -> e)
.average();
assertTrue(avgElapse.isPresent());
System.out.println(avgElapse.getAsDouble());
assertTrue(avgElapse.getAsDouble() > 2500.0);
}
@After
public void destroy() {
executorService.shutdown();
}
}
@@ -0,0 +1,36 @@
package com.baeldung.dubbo;
import com.baeldung.dubbo.remote.GreetingsService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* @author aiet
*/
public class MulticastRegistryLiveTest {
private ClassPathXmlApplicationContext remoteContext;
@Before
public void initRemote() {
remoteContext = new ClassPathXmlApplicationContext("multicast/provider-app.xml");
remoteContext.start();
}
@Test
public void givenProvider_whenConsumerSaysHi_thenGotResponse() {
ClassPathXmlApplicationContext localContext = new ClassPathXmlApplicationContext("multicast/consumer-app.xml");
localContext.start();
GreetingsService greetingsService = (GreetingsService) localContext.getBean("greetingsService");
String hiMessage = greetingsService.sayHi("baeldung");
assertNotNull(hiMessage);
assertEquals("hi, baeldung", hiMessage);
}
}
@@ -0,0 +1,47 @@
package com.baeldung.dubbo;
import com.baeldung.dubbo.remote.GreetingsService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import static org.junit.Assert.*;
/**
* @author aiet
*/
public class ResultCacheLiveTest {
private ClassPathXmlApplicationContext remoteContext;
@Before
public void initRemote() {
remoteContext = new ClassPathXmlApplicationContext("multicast/provider-app-special.xml");
remoteContext.start();
}
@Test
public void givenProvider_whenConsumerSaysHi_thenGotResponse() {
ClassPathXmlApplicationContext localContext = new ClassPathXmlApplicationContext("multicast/consumer-app.xml");
localContext.start();
GreetingsService greetingsService = (GreetingsService) localContext.getBean("greetingsService");
long before = System.currentTimeMillis();
String hiMessage = greetingsService.sayHi("baeldung");
long timeElapsed = System.currentTimeMillis() - before;
assertTrue(timeElapsed > 5000);
assertNotNull(hiMessage);
assertEquals("hi, baeldung", hiMessage);
before = System.currentTimeMillis();
hiMessage = greetingsService.sayHi("baeldung");
timeElapsed = System.currentTimeMillis() - before;
assertTrue(timeElapsed < 1000);
assertNotNull(hiMessage);
assertEquals("hi, baeldung", hiMessage);
}
}
@@ -0,0 +1,39 @@
package com.baeldung.dubbo;
import com.baeldung.dubbo.remote.GreetingsService;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
* @author aiet
*/
public class SimpleRegistryLiveTest {
private ClassPathXmlApplicationContext remoteContext;
private ClassPathXmlApplicationContext registryContext;
@Before
public void initRemote() {
registryContext = new ClassPathXmlApplicationContext("simple/registry.xml");
registryContext.start();
remoteContext = new ClassPathXmlApplicationContext("simple/provider-app.xml");
remoteContext.start();
}
@Test
public void givenProvider_whenConsumerSaysHi_thenGotResponse() {
ClassPathXmlApplicationContext localContext = new ClassPathXmlApplicationContext("simple/consumer-app.xml");
localContext.start();
GreetingsService greetingsService = (GreetingsService) localContext.getBean("greetingsService");
String hiMessage = greetingsService.sayHi("baeldung");
assertNotNull(hiMessage);
assertEquals("hi, baeldung", hiMessage);
}
}
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- provider application meta -->
<dubbo:application name="demo-consumer" version="1.0"/>
<!-- address used to expose provider's service -->
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!-- remote service proxy, acting like a local bean while invoking -->
<dubbo:reference interface="com.baeldung.dubbo.remote.GreetingsService" id="greetingsService" retries="2" timeout="2000" />
</beans>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- provider application meta -->
<dubbo:application name="demo-consumer" version="1.0"/>
<!-- address used to expose provider's service -->
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!-- remote service proxy, acting like a local bean while invoking -->
<dubbo:reference interface="com.baeldung.dubbo.remote.GreetingsService" id="greetingsService" retries="2" timeout="10000" loadbalance="roundrobin" />
</beans>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- provider application meta -->
<dubbo:application name="demo-provider" version="1.0"/>
<!-- address used to expose provider's service -->
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!-- protocol and port used to expose service -->
<dubbo:protocol name="dubbo" port="20880"/>
<!-- the service interface to expose -->
<dubbo:service interface="com.baeldung.dubbo.remote.GreetingsService" ref="greetingsService" cluster="failsafe"/>
<!-- declare the local implementation of exposed service interface -->
<bean id="greetingsService" class="com.baeldung.dubbo.remote.GreetingsServiceImpl"/>
</beans>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- provider application meta -->
<dubbo:application name="demo-provider" version="1.0"/>
<!-- address used to expose provider's service -->
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!-- protocol and port used to expose service -->
<dubbo:protocol name="dubbo" port="20880"/>
<!-- the service interface to expose -->
<dubbo:service interface="com.baeldung.dubbo.remote.GreetingsService" ref="greetingsService" cluster="failover"/>
<!-- declare the local implementation of exposed service interface -->
<bean id="greetingsService" class="com.baeldung.dubbo.remote.GreetingsFailoverServiceImpl"/>
</beans>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- provider application meta -->
<dubbo:application name="demo-provider" version="1.0"/>
<!-- address used to expose provider's service -->
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!-- protocol and port used to expose service -->
<dubbo:protocol name="dubbo" port="20881" />
<!-- the service interface to expose -->
<dubbo:service interface="com.baeldung.dubbo.remote.GreetingsService" ref="greetingsService" cluster="failsafe"/>
<!-- declare the local implementation of exposed service interface -->
<bean id="greetingsService" class="com.baeldung.dubbo.remote.GreetingsServiceSpecialImpl"/>
</beans>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- provider application meta -->
<dubbo:application name="demo-provider" version="1.0"/>
<!-- address used to expose provider's service -->
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<!-- protocol and port used to expose service -->
<dubbo:protocol name="dubbo" port="20881" />
<!-- the service interface to expose -->
<dubbo:service interface="com.baeldung.dubbo.remote.GreetingsService" ref="greetingsService" cluster="failover"/>
<!-- declare the local implementation of exposed service interface -->
<bean id="greetingsService" class="com.baeldung.dubbo.remote.GreetingsServiceSpecialImpl"/>
</beans>
@@ -0,0 +1,6 @@
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- provider application meta -->
<dubbo:application name="demo-consumer" version="1.0"/>
<!-- address used to expose provider's service -->
<dubbo:registry address="multicast://224.1.1.1:9090"/>
<!-- remote service proxy, acting like a local bean while invoking -->
<dubbo:reference interface="com.baeldung.dubbo.remote.GreetingsService" id="greetingsService" cache="lru" />
</beans>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- provider application meta -->
<dubbo:application name="demo-provider" version="1.0"/>
<!-- address used to expose provider's service -->
<dubbo:registry address="multicast://224.1.1.1:9090"/>
<!-- protocol and port used to expose service -->
<dubbo:protocol name="dubbo" port="20881" />
<!-- the service interface to expose -->
<dubbo:service interface="com.baeldung.dubbo.remote.GreetingsService" ref="greetingsService"/>
<!-- declare the local implementation of exposed service interface -->
<bean id="greetingsService" class="com.baeldung.dubbo.remote.GreetingsServiceSpecialImpl"/>
</beans>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- provider application meta -->
<dubbo:application name="demo-provider" version="1.0"/>
<!-- address used to expose provider's service -->
<dubbo:registry address="multicast://224.1.1.1:9090"/>
<!-- protocol and port used to expose service -->
<dubbo:protocol name="dubbo" port="20880"/>
<!-- the service interface to expose -->
<dubbo:service interface="com.baeldung.dubbo.remote.GreetingsService" ref="greetingsService"/>
<!-- declare the local implementation of exposed service interface -->
<bean id="greetingsService" class="com.baeldung.dubbo.remote.GreetingsServiceImpl"/>
</beans>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- provider application meta -->
<dubbo:application name="demo-consumer" version="1.0"/>
<!-- address used to expose provider's service -->
<dubbo:registry address="127.0.0.1:9090"/>
<!-- remote service proxy, acting like a local bean while invoking -->
<dubbo:reference interface="com.baeldung.dubbo.remote.GreetingsService" id="greetingsService" cluster="failover" retries="2"/>
</beans>
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- provider application meta -->
<dubbo:application name="demo-provider" version="1.0"/>
<!-- address used to expose provider's service -->
<dubbo:registry address="127.0.0.1:9090"/>
<!-- protocol and port used to expose service -->
<dubbo:protocol name="dubbo" port="20880"/>
<!-- the service interface to expose -->
<dubbo:service interface="com.baeldung.dubbo.remote.GreetingsService" ref="greetingsService"/>
<!-- declare the local implementation of exposed service interface -->
<bean id="greetingsService" class="com.baeldung.dubbo.remote.GreetingsServiceImpl"/>
</beans>
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<dubbo:application name="simple-registry" />
<dubbo:protocol port="9090" />
<dubbo:service interface="com.alibaba.dubbo.registry.RegistryService" ref="registryService" registry="N/A" ondisconnect="disconnect">
<dubbo:method name="subscribe"><dubbo:argument index="1" callback="true" /></dubbo:method>
<dubbo:method name="unsubscribe"><dubbo:argument index="1" callback="true" /></dubbo:method>
</dubbo:service>
<bean id="registryService" class="com.alibaba.dubbo.registry.simple.SimpleRegistryService" />
</beans>