Archived

This forum has been archived. Please start a new discussion on GitHub.

Problem running IceStorm subscriber

Hi,
I try to use IceStorm with IceE and when I run my subscriber I have an error in this line (object adapter creation) :
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Hello.Subscriber");

Is someone have an idea ?


Thanks

Comments

  • dwayne
    dwayne St. John's, Newfoundland
    What is the error you are seeing?
  • Hi,

    "Myappli.exe ceased functioning" and it exit.
    thanks
  • xdm
    xdm La Coruña, Spain
    Hi,

    Have you correctly configured adapter enpoints? Attempts to create a named object adapter for which no endpoint or router configuration can be found raise InitializationException. see http://www.zeroc.com/doc/Ice-3.3.1/reference/Ice/Communicator.html#createObjectAdapter

    In your example, you should use Hello.Subscriber.Endpoints property to configure adapter endpoints. Alternatively you can use createObjectAdapterWithEndpoints that receives the enpoinds as is second argument see http://www.zeroc.com/doc/Ice-3.3.1/reference/Ice/Communicator.html#createObjectAdapterWithEndpoints

    Your code should also deal with InitializationException that can be throw from createObjectAdapter.

    Bests,
    José
  • Hi,
    I use the configuration file in IceStorm clock demo with a little modification. I already try use createObjectAdapterWithEndpoints but nothing change. My code is below :
    #include "stdafx.h"
    #include <IceE/IceE.h>
    
    #include <Hello.h>
    #include <IceStorm.h>
    
    using namespace std;
    using namespace Demo;
    
    
    class HelloI : public Hello
    {
    public:
    
        virtual void
        sayHello(const string& texte, const Ice::Current& curr)
        {
        	printf("%s \n",texte.c_str());
    		
        }
    
    };
    
    
    
    int 
    run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
    {
       	
        enum Option { None, Datagram, Twoway, Oneway, Ordered};
        Option option = None;
    	
        string topicName("time") ;
    	
        string id;
        option = Oneway;
    
        IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(
            communicator->propertyToProxy("TopicManager.Proxy"));
        
        if(!manager)
        {
            //cerr << appName() << ": invalid proxy" << endl;
    	printf("invalid proxy !\n");
            return EXIT_FAILURE;
        }
    
        IceStorm::TopicPrx topic;
       try
        {  
            topic = manager->retrieve(topicName);
        }
        catch(const IceStorm::NoSuchTopic&)
        {
            try
            {
                topic = manager->create(topicName);
            }
    		catch(const IceStorm::TopicExists&)
            {
    	    printf("temporary failure. try again.\n");
                return EXIT_FAILURE;
            }
       }
    	
       Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Hello.Subscriber");
    	
    
       Ice::Identity subId;
    
       subId.name = argv[1];
    	
       Ice::ObjectPrx subscriber = adapter->add(new HelloI, subId);
    	
       subscriber = subscriber->ice_oneway();
    	
       IceStorm::QoS qos;
       qos["reliability"] = "";
    		
        try
        {
            topic->subscribeAndGetPublisher(qos, subscriber);
        }
        catch(const IceStorm::AlreadySubscribed&)
        {
            //cout << "reactivating persistent subscriber" << endl;
    	 printf("reactivating persistent subscriber\n");
        }
        adapter->activate();
    	
        topic->unsubscribe(subscriber);
    
        return EXIT_SUCCESS;
    }
    
    
    
    int _tmain(int argc, char** argv)
    {
    	Ice::CommunicatorPtr communicator;
    	try
    	{
    
                  Ice::InitializationData initData;
    		
                  initData.properties = Ice::createProperties();
    		
    	      string config = "config.sub";
    
    	       try
                  {
    		   initData.properties->load(config);
                  }
                  catch(const Ice::FileException&)
                  {
    		exit(0);
                  }
    
    	      communicator = Ice::initialize(argc, argv, initData);
    
    	      run(argc, argv, communicator);
    	}
    
    	catch(const Ice::Exception& ex)
           {
    	   exit(0);
           }
    	return 0;
    }
    
    

    thanks
  • Hi,
    the problem is resolved.
    Thanks