public class Topic<Message>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
sendClosed |
| Constructor and Description |
|---|
Topic() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the channel so that no more messages could be sent to it.
|
void |
close(java.lang.Throwable t)
Closes the channel so that no more messages could be sent to it, and signifies an exception occurred in the producer.
|
protected java.util.Collection<SendPort<? super Message>> |
getSubscribers()
Provides read-only access to subscribers for extentions.
|
void |
send(Message message)
Sends a message to the channel, possibly blocking until there's room available in the channel.
|
boolean |
send(Message message,
long timeout,
java.util.concurrent.TimeUnit unit)
Sends a message to the channel, possibly blocking until there's room available in the channel, but never longer than the
specified timeout.
|
boolean |
send(Message message,
Timeout timeout)
Sends a message to the channel, possibly blocking until there's room available in the channel, but never longer than the
specified timeout.
|
<T extends SendPort<? super Message>> |
subscribe(T sub)
Subscribe a channel to receive messages sent to this topic.
|
boolean |
trySend(Message message)
Sends a message to the channel if the channel has room available.
|
void |
unsubscribe(SendPort<? super Message> sub)
Unsubscribe a channel from this topic.
|
void |
unsubscribeAll() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisClosedprotected java.util.Collection<SendPort<? super Message>> getSubscribers()
public <T extends SendPort<? super Message>> T subscribe(T sub)
sub - the channel to subscribepublic void unsubscribe(SendPort<? super Message> sub)
sub - the channel to subscribepublic void unsubscribeAll()
public void send(Message message) throws SuspendExecution, java.lang.InterruptedException
SendPortOverflowPolicy, set at construction time.java.lang.InterruptedExceptionSuspendExecutionpublic boolean send(Message message, long timeout, java.util.concurrent.TimeUnit unit) throws SuspendExecution, java.lang.InterruptedException
SendPortOverflowPolicy, set at construction time.timeout - the maximum duration this method is allowed to wait.unit - the timeout's time unittrue if the message has been sent successfully; false if the timeout has expired.SuspendExecutionjava.lang.InterruptedExceptionpublic boolean send(Message message, Timeout timeout) throws SuspendExecution, java.lang.InterruptedException
SendPortOverflowPolicy, set at construction time.timeout - the method will not block for longer than the amount remaining in the Timeouttrue if the message has been sent successfully; false if the timeout has expired.SuspendExecutionjava.lang.InterruptedExceptionpublic boolean trySend(Message message)
SendPorttrue if the message has been sent; false otherwise.public void close()
PortAutoCloseablepublic void close(java.lang.Throwable t)
SendPortReceivePort's receive or tryReceive,
wrapped by a ProducerException.
Messages already sent to the channel prior to calling this method will still be received.