|
|
|
|||||
|
Async Subscriber
Is there a way to create an Async Subscriber with IceStorm?
Both the clock demo, and the documentation only demonstrate the blocking method communicator()->waitForShutdown(); Thanks, Pete |
|
|||||
|
It seems if I don't call that method it just seems like the subscriber closes right away:
Code:
[ 03/03/08 18:36:15.515 Subscriber: 97ec16db-daba-49ef-943e-18e53d850782: topic publish failed: Network.cpp:664: Ice::ConnectionRefusedException:connection refused: WSAECONNREFUSED ] Code:
public class Subscriber : Ice.Application
{
private IceStorm.TopicPrx topic;
private Ice.ObjectAdapter adapter;
private Ice.ObjectPrx subscriber;
private IceStorm.QoS qos;
public class LimehouseI : LimehouseDisp_
{
public override void sendCommand(string date, Ice.Current current)
{
System.Console.Out.WriteLine(date);
}
}
public override int run(string[] args)
{
IceStorm.TopicManagerPrx manager = IceStorm.TopicManagerPrxHelper.checkedCast(
communicator().propertyToProxy("IceStorm.TopicManager.Proxy"));
if (manager == null)
{
Console.WriteLine("invalid proxy");
return 1;
}
string topicName = "LimehouseCMD";
bool datagram = false;
bool twoway = false;
bool ordered = false;
bool batch = false;
int optsSet = 0;
for (int i = 0; i < args.Length; ++i)
{
if (args[i].Equals("--datagram"))
{
datagram = true;
++optsSet;
}
else if (args[i].Equals("--twoway"))
{
twoway = true;
++optsSet;
}
else if (args[i].Equals("--ordered"))
{
ordered = true;
++optsSet;
}
else if (args[i].Equals("--oneway"))
{
++optsSet;
}
else if (args[i].Equals("--batch"))
{
batch = true;
}
else if (args[i].StartsWith("--"))
{
usage();
return 1;
}
else
{
topicName = args[i];
break;
}
}
if (batch && (twoway || ordered))
{
Console.WriteLine(appName() + ": batch can only be set with oneway or datagram");
return 1;
}
if (optsSet > 1)
{
usage();
return 1;
}
//
// Retrieve the topic.
//
try
{
topic = manager.retrieve(topicName);
}
catch (IceStorm.NoSuchTopic)
{
try
{
topic = manager.create(topicName);
}
catch (IceStorm.TopicExists)
{
Console.WriteLine("temporary error. try again.");
return 1;
}
}
adapter = communicator().createObjectAdapter("Limehouse.Subscriber");
//
// Add a Servant for the Ice Object.
//
subscriber = adapter.addWithUUID(new LimehouseI());
qos = new IceStorm.QoS();
//
// Set up the proxy.
//
if (datagram)
{
subscriber = subscriber.ice_datagram();
}
else if (twoway)
{
// Do nothing to the subscriber proxy. Its already twoway.
}
else if (ordered)
{
// Do nothing to the subscriber proxy. Its already twoway.
qos["reliability"] = "ordered";
}
else // if(oneway)
{
subscriber = subscriber.ice_oneway();
}
if (batch)
{
if (datagram)
{
subscriber = subscriber.ice_batchDatagram();
}
else
{
subscriber = subscriber.ice_batchOneway();
}
}
topic.subscribeAndGetPublisher(qos, subscriber);
adapter.activate();
//shutdownOnInterrupt();
//communicator().waitForShutdown();
//
// Unsubscribe all subscribed objects.
//
//topic.unsubscribe(subscriber);
return 0;
}
public void unsubscribe()
{
topic.unsubscribe(subscriber);
}
public void usage()
{
Console.WriteLine("Usage: " + appName() + " [--batch] [--datagram|--twoway|--ordered|--oneway] [topic]");
}
}
Thanks, Pete Last edited by sly596 : 03-03-2008 at 08:38 PM. |
|
|||||
|
My main thread is running a GUI, so the app is still running when I receive that message. If I was to call that method, my GUI would never get drawn.
Is it correct for the Subscriber to inherit from Ice.Application? This app also contains a Publisher class which also inherits from Ice.Application. Thanks, Pete |
|
||||||
|
Quote:
Quote:
Last edited by matthew : 03-04-2008 at 02:42 AM. |
|
|||||
|
Quote:
Quote:
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Publisher and Subscriber | sly596 | Help Center | 6 | 08-13-2008 05:18 PM |
| Async bidirectional issue | Kruppy | Help Center | 15 | 05-16-2007 11:44 AM |
| about Subscriber and Publisher | terminate | Help Center | 1 | 04-27-2007 01:44 PM |
| Async retry mechanism | garry | Bug Reports | 1 | 08-02-2005 12:31 PM |
| Server-Initiated Async | acbell | Help Center | 7 | 02-28-2005 05:46 PM |