use of com.alibaba.dubbo.demo.DemoService in project dubbo by alibaba.
the class Consumer method main.
public static void main(String[] args) {
// Prevent to get IPV6 address,this way only work in debug mode
// But you can pass use -Djava.net.preferIPv4Stack=true,then it work well whether in debug mode or not
System.setProperty("java.net.preferIPv4Stack", "true");
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "META-INF/spring/dubbo-demo-consumer.xml" });
context.start();
// get remote service proxy
DemoService demoService = (DemoService) context.getBean("demoService");
while (true) {
try {
Thread.sleep(1000);
// call remote method
String hello = demoService.sayHello("world");
// get result
System.out.println(hello);
} catch (Throwable throwable) {
throwable.printStackTrace();
}
}
}
use of com.alibaba.dubbo.demo.DemoService in project dubbo by alibaba.
the class Spring3CompatibilityTest method main.
public static void main(String[] args) {
ConfigurableApplicationContext provider = startupProvider();
ConfigurableApplicationContext consumer = startConsumer();
ConsumerConfiguration consumerConfiguration = consumer.getBean(ConsumerConfiguration.class);
DemoService demoService = consumerConfiguration.getDemoService();
String value = demoService.sayHello("Mercy");
Assert.isTrue("DefaultDemoService - sayHell() : Mercy".equals(value), "Test is failed!");
System.out.println(value);
provider.close();
consumer.close();
}
Aggregations