IceDemos:Ice registry
来源:互联网 发布:高仿耐克衣服淘宝店铺 编辑:程序博客网 时间:2024/06/05 09:56
为Registry写配置文件:registry.cfg
#registry config for icegrid#客户端通过Endpoints访问注册表IceGrid.Registry.Client.Endpoints=tcp -p 4061IceGrid.Registry.Server.Endpoints=tcpIceGrid.Registry.Internal.Endpoints=tcpIceGrid.Registry.AdminPermissionsVerifier=IceGrid/NullPermissionsVerifier#Registry的持久化文件存放目录,需要手工创建目录IceGrid.Registry.Data=./registry#是否允许动态注册,一般在开发阶段允许,而生产部署则关闭IceGrid.Registry.DynamicRegistration=1
在实验目录E:\var\iceDemos下创建registry的工作目录:
E:\Var\icegrid>mkdir registry
通过命令行工具icegridregistry启动registry服务:
E:\Var\icegrid>icegridregistry --Ice.Config=registry.cfg
在IceBox的配置文件中增加registry服务,将OnlineBook和HelloIce添加到registry上去,修改后的IceBox配置文件:config.properties
#server propertiesIceBox.InstanceName=MyAppIceBox 1IceBox.InheritProperties=1IceBox.PrintServicesReady=MyAppIceBox 1IceBox.ServiceManager.Endpoints=tcp -p 9999 -h localhost#performance propertiesIce.ThreadPool.Server.Size=4Ice.ThreadPool.Server.SizeMax=100Ice.ThreadPool.Server.SizeWarn=40Ice.ThreadPool.Client.Size=4Ice.ThreadPool.Client.SizeMax=100Ice.ThreadPool.Client.SizeWarn=40#for system strongerIce.ACM.Client=300Ice.ACM.Server=300#log and trace#Ice.LogFile=iceserv.logIce.PrintStackTraces=1Ice.Trace.Retry=2Ice.Trace.Network=2Ice.Trace.ThreadPool=1Ice.Trace.Locator=2Ice.Warn.Connections=1Ice.Warn.Dispatch=1Ice.Warn.Endpoints=1#service define beginIceBox.Service.HelloIce=com.myjava.ice.demo.impl.HelloIceImpl prop1=1 prop2=2 prop3=3HelloIce.Endpoints=tcp -p 10000 -h localhostIceBox.Service.OnlineBook=com.myjava.ice.demo.impl.OnlineBookImpl prop1=1 prop2=2 prop3=3OnlineBook.Endpoints=tcp -p 10001 -h localhost#使用ice registry增加以下配置###########Ice.Default.Locator=IceGrid/Locator:tcp -h localhost -p 4061HelloIce.AdapterId=HelloIceAdapterOnlineBook.AdapterId=OnlineBookAdapter################################service define end#service load orderIceBox.LoadOrder=HelloIce,OnlineBook#service share communicatorIceBox.UseSharedCommunicator.HelloIce=1IceBox.UseSharedCommunicator.OnlineBook=1
修改客户端的代码,现在可以不用在客户端内指定服务的端口和地址了。
OnlineBookClient.java
package com.myjava.ice.demo.impl;import com.myjava.ice.demo.Message;import com.myjava.ice.demo.OnlineBookPrx;import com.myjava.ice.demo.OnlineBookPrxHelper;public class OnlineBookClient { public static void main(String[] args){ Ice.Communicator ic = null; //初始化参数指定registry的地址 String[] initParams = new String[] {"--Ice.Default.Locator=IceGrid/Locator:tcp -h localhost -p 4061"}; ic = Ice.Util.initialize(initParams); //获取OnlineBook服务时不需要指定端口和地址 Ice.ObjectPrx base = ic.stringToProxy("OnlineBook@OnlineBookAdapter"); OnlineBookPrx proxy = OnlineBookPrxHelper.checkedCast(base); if(proxy == null) throw new Error("Invalid proxy."); Message msg = new Message(); msg.name = "Mr. wang"; msg.type = 3; msg.price = 99.9; msg.valid =true; msg.content = "OnlineBook Ice."; Message ret = proxy.bookTick(msg); System.out.println(ret.content); if(ic != null) ic.destroy(); }}
Reference:
1. ZeroCIce权威指南 / Leader-us著. –北京:电子工业出版社,2015.6
0 0
- IceDemos:Ice registry
- Ice系列--Ice Registry(1)
- ZeroC Ice Ice Registry实现负载均衡
- ZeroC Ice Ice Registry实现负载均衡
- Ice 主从注册中心registry配置
- IceDemos : IceGrid
- Java读取注册表总结之com.ice.jni.registry
- IceDemos:使用IceBox
- IceDemos:IceGrid Node
- 详细教你如何部署ICE服务(三)---IceBox框架 & Ice Registry服务注册中心的联合使用
- Registry
- Registry
- Registry
- Registry
- IceDemos:环境搭建和HelloWorld
- ice
- ICE
- ICE
- 【Linux开发】CCS远程调试ARM,AM4378
- android启动中遇到的2个问题
- java基础 day01 基础知识环境搭建以及注释
- Window下Meven的安装与环境变量配置
- 109.Triangle-数字三角形(容易题)
- IceDemos:Ice registry
- Android 的Intent开发详解
- Leetcode 392. Is Subsequence 判断子序列 解题报告
- Quartz.net使用入门(一)
- ubuntu 安装jenkins
- OpenCV3——core组件进阶
- 工厂模式
- 波兰式
- Android文件读取的方式