Using ICE from Zeroc, how do I configure Icebox in .NET to host two separate services?

1k views Asked by At

Using ICE I can start a single server using the following command:

iceboxnet.exe --Ice.Config=config.icebox

(download the ICE v3.4.1 demo source and look at directory "Ice-3.4.1-demos\democs\IceGrid\simple")

Question: How do I start two servers within the same icebox, with each server contained in a separate .dll file?

2

There are 2 answers

0
Contango On BEST ANSWER
0
Contango On

The key is in the user manual under: "43.3.4: Configuring a Service":

The name component of the property is the service name (IceStorm, in this example). This name is passed to the service's start operation, and must be unique among all services configured in the same Icebox server.

So - you need to have different interface names for each service (which makes a lot of sense: it needs a unique name for each service). We need to make a copy of interface "hello", and name it "hello2".

Add an extra line to config.icebox:

 # The hello service (2 identical copies)
 IceBox.Service.Hello=helloservice.dll:HelloServiceI --Ice.Config=config.service
 IceBox.Service.Hello2=helloservice2.dll:Hello2ServiceI --Ice.Config=config2.service

Create a copy of config.service, name it config2.service, and change the name and the port:

Hello.Endpoints=tcp -p 10000:udp -p 10000:ssl -p 10001

... edits to:

Hello2.Endpoints=tcp -p 20000:udp -p 20000:ssl -p 20001

Now, we need to compile a new version of "helloservice.dll" which uses "hello2" as the interface. Go through the C# project, and rename all "hello" to "hello2", rename the output of the compile to "helloservice2.dll" from "helloservice.dll".

Now, both services will start up under the same icebox, and if you turn logging on by altering the .config file:

 C:\Program Files (x86)\ZeroC\Ice-3.4.1\Ice-3.4.1-demos\democs\IceBox\hello>iceboxnet.exe --Ice.Config=config.icebox
 -- 3/2/2011 15:10:32:316 iceboxnet.exe-Hello: Network: attempting to bind to tcp socket 0.0.0.0:10000
 -- 3/2/2011 15:10:32:373 iceboxnet.exe-Hello: Network: accepting tcp connections at 0.0.0.0:10000
    local interfaces: 192.168.1.10, 127.0.0.1
 -- 3/2/2011 15:10:32:382 iceboxnet.exe-Hello: Network: attempting to bind to udp socket 0.0.0.0:10000
 -- 3/2/2011 15:10:32:429 iceboxnet.exe-Hello: Network: starting to receive udp packets
    local address = 0.0.0.0:10000
    local interfaces: 192.168.1.10, 127.0.0.1
 -- 3/2/2011 15:10:32:457 iceboxnet.exe-Hello: Network: attempting to bind to ssl socket 0.0.0.0:10001
 -- 3/2/2011 15:10:32:507 iceboxnet.exe-Hello: Network: accepting ssl connections at 0.0.0.0:10001
    local interfaces: 192.168.1.10, 127.0.0.1
 -- 3/2/2011 15:10:32:649 iceboxnet.exe-Hello: Network: published endpoints for object adapter `Hello':
    tcp -h 192.168.1.10 -p 10000:udp -h 192.168.1.10 -p 10000:ssl -h 192.168.1.10 -p 10001
 -- 3/2/2011 15:10:32:745 iceboxnet.exe-Hello2: Network: attempting to bind to tcp socket 0.0.0.0:20000
 -- 3/2/2011 15:10:32:794 iceboxnet.exe-Hello2: Network: accepting tcp connections at 0.0.0.0:20000
    local interfaces: 192.168.1.10, 127.0.0.1
 -- 3/2/2011 15:10:32:795 iceboxnet.exe-Hello2: Network: attempting to bind to udp socket 0.0.0.0:20000
 -- 3/2/2011 15:10:32:839 iceboxnet.exe-Hello2: Network: starting to receive udp packets
    local address = 0.0.0.0:20000
    local interfaces: 192.168.1.10, 127.0.0.1
 -- 3/2/2011 15:10:32:840 iceboxnet.exe-Hello2: Network: attempting to bind to ssl socket 0.0.0.0:20001
 -- 3/2/2011 15:10:32:885 iceboxnet.exe-Hello2: Network: accepting ssl connections at 0.0.0.0:20001
    local interfaces: 192.168.1.10, 127.0.0.1
 -- 3/2/2011 15:10:33:021 iceboxnet.exe-Hello2: Network: published endpoints for object adapter `Hello2':
    tcp -h 192.168.1.10 -p 20000:udp -h 192.168.1.10 -p 20000:ssl -h 192.168.1.10 -p 20001
 -- 3/2/2011 15:10:33:027 iceboxnet.exe: Network: attempting to bind to tcp socket 127.0.0.1:9996
 -- 3/2/2011 15:10:33:027 iceboxnet.exe: Network: accepting tcp connections at 127.0.0.1:9996
 -- 3/2/2011 15:10:33:034 iceboxnet.exe: Network: published endpoints for object adapter `Ice.Admin':
    tcp -h 127.0.0.1 -p 9996

Update

Groan. All the code above is not strictly necessary (unless you're creating two services). All I needed to do was rename the appropriate interfaces, see the ZeroC forums and How do I run two services in a single icebox?