Home Help Center

Ice.Communicator.shutdown() not working

DjaunlDjaunl Member Dan GreshOrganization: LLEProject: EP control systems
Hi all,

I'm using an Ice.Communicator (IC) for an IceStorm service. I am subscribing to the topic appropriately, and calling IC.waitForShutdown(). This works fine.

However, I want to unsubscribe to the topic and call IC.shutdown(), then call IC.destroy(). However, when I try to call these three methods, only IC.destroy() seems to work, and I get an Exception:
Ice.CommunicatorDestroyedException
	at IceInternal.Instance.proxyFactory(Instance.java:78)
	at Ice.ObjectPrxHelperBase.__handleException(ObjectPrxHelperBase.java:820)
	at IceStorm.TopicPrxHelper.unsubscribe(TopicPrxHelper.java:257)
	at IceStorm.TopicPrxHelper.unsubscribe(TopicPrxHelper.java:235)
	at imaq.matlab.IMAQObserverClient.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)

This is the way my code to subscribe and wait is set up. Assume everything is set up correctly (which it is); the variable names should be self-explanatory, as I used the same ones from the documentation:
try {
				topic = topicManager.retrieve(topicName);
				Map qos = null;
				topic.subscribe(qos, subscriber);
			} catch (IceStorm.NoSuchTopic e) {
				throw new Exception();
			}

			adapter.activate();
			ic.waitForShutdown();
			topic.unsubscribe(subscriber);

Here is the method I am using to try to call IC.shutdown() and other such things. This is in the same class:
public void stop() {
		System.err.println("DEBUG: attempting to unsubscribe");
		topic.unsubscribe(subscriber);
		System.err.println("DEBUG: attempting to shutdown IC");
		ic.shutdown();
		System.err.println("DEBUG: attempting to destroy IC");
		ic.destroy();
	}

When I call this method, it goes through all the DEBUG statements, and finally destroys the IC, giving the Exception I posted above.

Is there another way I should be doing this? I don't like destroying the IC and getting an Exception. Do I need to provide more information for a reliable answer?

Thank you very much,
Dan

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Hi,

    You're getting this exception because the communicator is already destroyed at the time you call unsubscribe() on the topic. That's because you call destroy() on the communicator right after shutdown().

    Calling ic.destroy() after topic.unsubscribe() should fix your problem.

    Cheers,
    Benoit.
  • DjaunlDjaunl Member Dan GreshOrganization: LLEProject: EP control systems
    Thank you for the helpful reply; this worked perfectly!
Sign In or Register to comment.