Class MessageQueue
- All Implemented Interfaces:
AutoCloseable
,Flow.Processor<Message,
,Message> Flow.Publisher<Message>
,Flow.Subscriber<Message>
- Direct Known Subclasses:
TwitchSession
public abstract class MessageQueue
extends SubmissionPublisher<Message>
implements Flow.Processor<Message,Message>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final String
protected boolean
protected Instant
protected static final long
protected Flow.Subscription
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Method that says if we are allowed to send messages.void
kill()
Method that kills this instance.void
void
onSubscribe
(Flow.Subscription subscription) void
Attempts to enqueue a message, timing out after 5 seconds.void
Attempts to enqueue a message until success.void
setAllowSendMessages
(boolean isAllowedToSend) Method that sets if we are allowed to send messages.Methods inherited from class java.util.concurrent.SubmissionPublisher
close, closeExceptionally, consume, estimateMaximumLag, estimateMinimumDemand, getClosedException, getExecutor, getMaxBufferCapacity, getNumberOfSubscribers, getSubscribers, hasSubscribers, isClosed, isSubscribed, offer, offer, submit, subscribe
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.concurrent.Flow.Publisher
subscribe
Methods inherited from interface java.util.concurrent.Flow.Subscriber
onComplete, onNext
-
Field Details
-
channelName
-
isAllowedToSend
protected boolean isAllowedToSend -
nextReminder
-
REMINDER_INTERVAL
protected static final long REMINDER_INTERVAL- See Also:
-
subscription
-
-
Constructor Details
-
MessageQueue
Class constructor.- Parameters:
channelName
-
-
-
Method Details
-
setAllowSendMessages
public void setAllowSendMessages(boolean isAllowedToSend) Method that sets if we are allowed to send messages.- Parameters:
isAllowedToSend
-
-
isAllowedToSendMessages
public boolean isAllowedToSendMessages()Method that says if we are allowed to send messages.- Returns:
- isAllowedToSend
-
say
Attempts to enqueue a message, timing out after 5 seconds.- Parameters:
message
-
-
sayNow
Attempts to enqueue a message until success.- Parameters:
message
-
-
kill
public void kill()Method that kills this instance. -
onSubscribe
- Specified by:
onSubscribe
in interfaceFlow.Subscriber<Message>
-
onError
- Specified by:
onError
in interfaceFlow.Subscriber<Message>
-