/** * Makes the Subscriber subscribe to data that is published in the Partitions that match the * supplied expression. Remember that the Partitions must have been created within the Participant * of this Subscriber prior to calling this function. * * @param expression The partition expression to apply. * @throws CMException Thrown when Subscriber has already been freed or when publish failed. */ public void subscribe(String expression) throws CMException { if (this.isFreed()) { throw new CMException("Subscriber already freed."); } try { CMFactory.getCommunicator().subscriberSubscribe(this, expression); } catch (CommunicationException e) { throw new CMException("subscribe failed for: " + expression); } }
public void setQoS(QoS qos) throws CMException { if (freed) { throw new CMException("Supplied entity is not available (anymore)."); } else if (qos instanceof SubscriberQoS) { try { CMFactory.getCommunicator().entitySetQoS(this, qos); } catch (CommunicationException ce) { throw new CMException(ce.getMessage()); } } else { throw new CMException("Supplied entity requires a SubscriberQoS."); } }
/** * Creates a new Subscriber from the supplied arguments. The Subscriber is owned by the caller of * this constructor. * * @param participant The Participant to create the Subscriber in. * @param name The name of the Subscriber. * @param qos The quality of service to apply to the Subscriber. * @throws CMException Thrown when Subscriber could not be created. */ public SubscriberImpl(ParticipantImpl participant, String name, SubscriberQoS qos) throws CMException { super(0, 0, "", ""); owner = true; SubscriberImpl s; try { s = (SubscriberImpl) CMFactory.getCommunicator().subscriberNew(participant, name, qos); } catch (CommunicationException e) { throw new CMException(e.getMessage()); } if (s == null) { throw new CMException("Subscriber could not be created."); } this.index = s.index; this.serial = s.serial; this.name = s.name; this.pointer = s.pointer; this.enabled = s.enabled; s.freed = true; }