Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #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
  #2 (permalink)  
Old 04-12-2004
mes's Avatar
mes mes is online now
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 971
Welcome!

The problem is that your subscriber's object adapter has no endpoints, therefore the proxy it sends to the topic manager cannot be used to send messages to the subscriber.

One way to fix this is to change your subscriber to call createObjectAdapterWithEndpoints, for example:
Code:
Ice.ObjectAdapter adapter =
  communicator.createObjectAdapterWithEndpoints("MonitorAdapter", "tcp");
Take care,
- Mark
Reply With Quote
  #3 (permalink)  
Old 04-15-2004
lovesunny lovesunny is offline
Registered User
 
 
Join Date: Apr 2004
Posts: 4
Talking Ok

Thanks. Every thing is ok.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -4. The time now is 01:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.