WSRPConsumer consumer = getConsumer(id);
if (consumer == null)
{
throw new ConsumerException(CONSUMER_WITH_ID + id + "' doesn't exist!");
}
try
{
if (register)
{
consumer.getProducerInfo().register();
}
else
{
consumer.getProducerInfo().deregister();
}
}
catch (Exception e)
{
// unexpected exception: deactivate the consumer
deactivateConsumer(consumer);
Throwable cause = e.getCause();
throw new ConsumerException("Couldn't " + (register ? "register" : "deregister") + CONSUMER_WITH_ID + id + "'",
cause != null ? cause : e);
}
}