Thread: where
View Single Post
  #1 (permalink)  
Old 04-11-2004
lovesunny lovesunny is offline
Registered User
 
 
Join Date: Apr 2004
Posts: 4
there is nothing in the server console

hi,
I am working through the publisher/subscriber example in chapter 25, not the clock case for C++ but the weather report , and I am having some trouble. I start the storm service following the steps in the readme for the colock case ,then run the server(subscriber) and start the client(publisher) in eclipse. But i can't see any result in the server side's console window.
It should show the information about the weather but i can't see anything.

following is the config_server and config files.

config_server:
IceBox.Service.IceStorm=IceStormService,13:create --Ice.Config=config
IceBox.DBEnvName.IceStorm=db

config:
IceBox.Service.IceStorm=IceStormService,1.0.0:crea te
Monitor.Subscriber.Endpoints=tcp
IceBox.DBEnvName.IceStorm=db
IceStorm.TopicManager.Endpoints=tcp -p 9999
IceStorm.Publish.Endpoints=tcp
IceStorm.TopicManager.Proxy=IceStorm/TopicManager:tcp -p 9999

there is part of my code:
public class MonitorI extends _MonitorDisp
{
public void report(Measurement m,Ice.Current current)
{
System.out.println(
"Measurement report:\n"+
"W Spd: " + m.windSpeed + "\n" +
"W Dir: " + m.windDirection + "\n" +
" Temp: " + m.temperature + "\n");
}
}


public class Server_storm
{
private static int
run(String[] args, Ice.Communicator communicator)
{ Ice.ObjectPrx obj = communicator.stringToProxy(
"IceStorm/TopicManager:tcp -p 9999");
IceStorm.TopicManagerPrx topicManager =
IceStorm.TopicManagerPrxHelper.checkedCast(obj);
ObjectAdapter adapter =
communicator.createObjectAdapter("MonitorAdapter") ;
Monitor monitor = new MonitorI();
Ice.ObjectPrx proxy = adapter.addWithUUID(monitor);
IceStorm.TopicPrx topic = null;
try {
topic = topicManager.retrieve("Weather");
java.util.Map qos = null;
topic.subscribe(qos,proxy);
}
catch (IceStorm.NoSuchTopic ex)
{
ex.printStackTrace();
}
System.out.println(topic);
adapter.activate();
communicator.waitForShutdown();
topic.unsubscribe(proxy); return 0;
}
public static void main(String[] args)
{

System.out.println("ICE_test_storm demo is starting");
int status = 0;
Ice.Communicator communicator = null;
try
{
Ice.Properties properties = Ice.Util.createProperties(args);
properties.load("config");
communicator = Ice.Util.initializeWithProperties(args, properties);
status = run(args, communicator);
}
catch(Ice.LocalException ex)
{
ex.printStackTrace();
status = 1;
} finally {
if(communicator != null)
{
communicator.destroy();
}
}
System.exit(status);

}
}

///////////////////////////////////////////////////////////////////////////
import IceStorm.TopicExists;




public class Client_storm
{
public static void main(String [] args)
{
Ice.Communicator ic = null;
System.out.println("The publisher is starting....");
ic=Ice.Util.initialize(args);
Ice.ObjectPrx obj=ic.stringToProxy("IceStorm/TopicManager:tcp -p 9999");
IceStorm.TopicManagerPrx topicManager =
IceStorm.TopicManagerPrxHelper.checkedCast(obj);
IceStorm.TopicPrx topic=null;
try {
topic = topicManager.retrieve("Weather");
}
catch(IceStorm.NoSuchTopic ex) { try {
topic = topicManager.create("Weather");
} catch (TopicExists e) { e.printStackTrace();
}
}
Ice.ObjectPrx pub=topic.getPublisher();
if(!pub.ice_isDatagram())
pub = pub.ice_oneway(); MonitorPrx monitor = MonitorPrxHelper.uncheckedCast(pub);
int i=0;
while( i<100)
{
Measurement m = getMeasurement();
printor(m);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
monitor.report(m,null);
i++;
}

private static Measurement getMeasurement() {
Measurement temp=new Measurement();
temp.temperature=10+i;
temp.tower="tower"+i+"#";
temp.windSpeed=i;
temp.windDirection=(short) i;
i++;

return temp;
}
private static int i=0;
private static void printor(Measurement m)
{
System.out.println(
"Measurement report:\n"+
"w tower"+m.tower+"\n"+
"W Spd: " + m.windSpeed + "\n" +
"W Dir: " + m.windDirection + "\n" +
" Temp: " + m.temperature + "\n");
}

}

Last edited by lovesunny : 04-11-2004 at 08:17 AM.
Reply With Quote