Interface Emitter<T>
-
- Type Parameters:
T
- type of payload
- All Superinterfaces:
EmitterBehavior
- All Known Implementing Classes:
EmitterImpl
public interface Emitter<T> extends EmitterBehavior
Interface used to feed a channel from an imperative piece of code.Instances are injected using:
@Inject @Channel("my-channel") Emitter<String> emitter;
You can use an injected emitter to send either payloads or
Messages
.The name of the channel (given in the
Channel annotation
) indicates which channel is fed. It must match the name used in a method using@Incoming
or an outgoing channel configured in the application configuration.The
OnOverflow annotation
can be used to configure what to do if messages are sent using the `Emitter` when a downstream subscriber hasn't requested more messages.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <M extends Message<? extends T>>
voidsend(M msg)
Sends a message to the channel.CompletionStage<Void>
send(T msg)
Sends a payload to the channel.-
Methods inherited from interface io.smallrye.reactive.messaging.EmitterBehavior
complete, error, hasRequests, isCancelled
-
-
-
-
Method Detail
-
send
CompletionStage<Void> send(T msg)
Sends a payload to the channel.A
Message
object will be created to hold the payload and the returnedCompletionStage
will be completed once thisMessage
is acknowledged. If theMessage
is never acknowledged, then theCompletionStage
will never be completed.- Parameters:
msg
- the thing to send, must not benull
- Returns:
- the
CompletionStage
, which will be completed when the message for this payload is acknowledged. - Throws:
IllegalStateException
- if the channel has been cancelled or terminated or if an overflow strategy ofTHROW_EXCEPTION
orBUFFER
is configured and the emitter overflows.
-
send
<M extends Message<? extends T>> void send(M msg)
Sends a message to the channel.- Type Parameters:
M
- the Message type- Parameters:
msg
- the Message to send, must not benull
- Throws:
IllegalStateException
- if the channel has been cancelled or terminated or if an overflow strategy ofTHROW_EXCEPTION
orBUFFER
is configured and the emitter overflows.
-
-