Archived
This forum has been archived. Please start a new discussion on GitHub.
IceStorm Subscriber callback
I am tring to allow the IceStrorn subscriber to make calls back to the publisher. Here is the code from the subscrber side. Can a call be made back to the publisher this way or is there a better way.
Thanks
Mike
Ice::Identity subId;
subId.name = id;
if (subId.name.empty())
{
subId.name = IceUtil::generateUUID();
}
m_pDatanodeManagerAdapter = new DatanodeManagerAdapter(m_pParent);
Ice::ObjectPrx AdapterPrx = g_pObjectAdapter->add(m_pDatanodeManagerAdapter, subId);
AdapterPrx = AdapterPrx->ice_twoway();
try
{
TopicPrx->subscribeAndGetPublisher(qos, AdapterPrx);
}
catch(const IceStorm::AlreadySubscribed&)
{
if (id.empty())
{
throw;
}
}
if (g_pObjectAdapter->isDeactivated())
{
g_pObjectAdapter->activate();
}
m_CallbackProxy = IBtDatanodeManagerPrx::checkedCast(AdapterPrx);
RequestListType RequestList;
RequestList.push_back("Telemetry");
m_CallbackProxy->requestInterval(1.0);
Thanks
Mike
Ice::Identity subId;
subId.name = id;
if (subId.name.empty())
{
subId.name = IceUtil::generateUUID();
}
m_pDatanodeManagerAdapter = new DatanodeManagerAdapter(m_pParent);
Ice::ObjectPrx AdapterPrx = g_pObjectAdapter->add(m_pDatanodeManagerAdapter, subId);
AdapterPrx = AdapterPrx->ice_twoway();
try
{
TopicPrx->subscribeAndGetPublisher(qos, AdapterPrx);
}
catch(const IceStorm::AlreadySubscribed&)
{
if (id.empty())
{
throw;
}
}
if (g_pObjectAdapter->isDeactivated())
{
g_pObjectAdapter->activate();
}
m_CallbackProxy = IBtDatanodeManagerPrx::checkedCast(AdapterPrx);
RequestListType RequestList;
RequestList.push_back("Telemetry");
m_CallbackProxy->requestInterval(1.0);
0
Comments
-
Hi Michael,
I am not quite following the code you posted, but I'll try to answer your question .
A "publisher" is an application that sends messages to subscribers through IceStorm. In Ice terms, such a publisher is an Ice client, so you can't call on a pure Ice client (you can only call objects, and objects reside in servers).
The solution here is to include a callback object in your publisher application (which them becomes an Ice server) and pass a proxy to this object in your messages.
For example:module Demo { // // Implemented in Publisher application // interface Callback { void fromSubscriber(string data); }; // // The "topic" interface implemented by the Subscribers // interface MyTopic { void message(Callback* cb); }; };
Best regards,
Bernard0 -
Thnak you.
I went to the IceStorm counter example after posting. and implement it that way. That looks like what you are talking about correct?0 -
Hi Michael,
The "counter" is actually quite different: the subscribers implement the CounterObserver interface and the Counter is the publisher. The messages sent by the publisher (init and inc) don't include a callback proxy to an object in the publisher.
Best regards,
Bernard0 -
So what I am trying to develop is a data system that does the following.
The Publisher/Subscriber seems to be working out well.
The server clients are also working but is there another example of IceStorm that I could look at the implement the callback?
Data source 1 -> subcriber1 (IceStorm Publisher/Subscriber, like IceStorm clock example)
Like IceStorm clock
Process1 Subscriber
Process2 Publisher
Data source 1 -> Data source 2
Publish2 -> subcriber2 (IceStorm Publisher/Subscriber, like IceStorm clock example)
Process2 Subscriber
Process3 Publisher
Data source 2 -> Data source 3
Publish3-> subcriber3 (IceStorm Publisher/Subscriber, like IceStorm clock example)
Process3 Subscriber
Data source 3 -> Data source 4
Server -> multiple clients (like IceStorm counter example)
Data source 4 server
Clients can
Request data sets
Request update intervals
Set Data source 4 value
Receive periodic updates pushed by the server.0 -
Hi Michael,
There is no IceStorm demo that demonstrates callbacks to the "publisher". Maybe you could have a look at the Ice/callback demo to get a better idea of how callbacks work.Server -> multiple clients (like IceStorm counter example)
Note that in Ice terms, the caller is a client, and the target is the server (more precisely, the target is an object, itself incarnated by a servant hosted by an object adapter, and this object adapter is in a server).
With an IceStorm-based publish/subscribe setup, the publishers are Ice clients (they send requests to objects hosted by the IceStorm service) and the subscribers are Ice servers (called by IceStorm).
Best regards,
Bernard0