Interface PullSubscription
- All Superinterfaces:
AutoCloseable, Subscription
receive(), as returned by
MqttSubscriber.subscribe(Subscribe). A subscription with a handler or a hand-off acceptor
is a plain Subscription, which cannot receive.-
Method Summary
Modifier and TypeMethodDescriptionreceive()Waits interruptibly for the next delivery.Likereceive(), but returnsReceiveResult.TimedOutif the wait expires while the subscription remains active.Methods inherited from interface Subscription
close, established, filter, grantedQos, terminated, unsubscribe
-
Method Details
-
receive
Waits interruptibly for the next delivery. Multiple receiving threads share one FIFO; each delivery is handed to one caller only. Concurrent callers can return and finish processing in a different order.
AckMode.ON_RECEIVEpermits acknowledgement at handoff;AckMode.MANUALwaits forMqttDelivery.ack(). PUBACK and PUBREC still follow receive order; seeAckMode. ReturnsReceiveResult.Receivedat handoff, orReceiveResult.EndedafterSubscription.close(), afterSubscription.unsubscribe()once removal is confirmed and every delivery it accepted has been received, or onceMqttClient.close()has been called. Connection termination discards buffered deliveries but leaves this call waiting for delivery after the next connection. This applies to both requested disconnection and connection failure. A refusal ends this subscription and throwsMqttSubscriptionRefusedException; a refusal after local closure or a requested removal only confirms that removal, so this call ends withReceiveResult.Endedas described above. A SUBACK that violates the protocol throwsMqttProtocolException. Rejected registration throws its original exception, includingIllegalStateExceptionfor duplicate or overlapping shared filters andMqttCapacityExceptionfor capacity. An internal failure that closes the client throwsMqttConnectionLostExceptionwith that failure as its cause. The first permanent ending decides every later result; a later close or refusal does not change it. This overload waits without a deadline and never returnsReceiveResult.TimedOut.- Returns:
the outcome of this receive- Throws:
InterruptedException-if interrupted before claiming a deliveryMqttSubscriptionRefusedException-if the subscription was refused before its removal was requestedMqttProtocolException-if a SUBACK for this subscription violated the protocolMqttConnectionLostException-if an internal failure closed the client first
-
receive
Likereceive(), but returnsReceiveResult.TimedOutif the wait expires while the subscription remains active. Zero polls without waiting for a delivery; a negative duration is rejected. A timeout does not end the subscription. A normally ended subscription returnsReceiveResult.Endedimmediately, even for a zero-duration poll. A disconnected subscription can time out while waiting for the next connection. Registration rejection, a refusal, a SUBACK that violates the protocol, and an internal failure that closes the client throw as they do forreceive().- Parameters:
timeout- the longest time to wait for a delivery, or zero to poll- Returns:
the outcome of this receive- Throws:
IllegalArgumentException-if `timeout` is negativeInterruptedException-if interrupted before claiming a deliveryMqttSubscriptionRefusedException-if the subscription was refused before its removal was requestedMqttProtocolException-if a SUBACK for this subscription violated the protocolMqttConnectionLostException-if an internal failure closed the client first
-