Interface MutinyEmitter<T>
- Type Parameters:
T
- type of payload
- All Superinterfaces:
EmitterType
Instances are injected using:
@Inject @Channel("my-channel") MutinyEmitter<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 `MutinyEmitter` when a downstream subscriber hasn't requested
more messages.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
complete()
Sends the completion event to the channel indicating that no other events will be sent afterward.void
Sends a failure event to the channel.boolean
boolean
send
(M msg) Deprecated.io.smallrye.mutiny.Uni<Void>
Sends a payload to the channel.void
sendAndAwait
(T payload) Sends a payload to the channel.io.smallrye.mutiny.subscription.Cancellable
sendAndForget
(T payload) Sends a payload to the channel without waiting for acknowledgement.sendMessage
(M msg) Sends a message to the channel.sendMessageAndAwait
(M msg) Sends a message to the channel.sendMessageAndForget
(M msg) Sends a message to the channel without waiting for acknowledgement.
-
Method Details
-
send
Sends a payload to the channel.A
Message
object will be created to hold the payload and the returnedUni
can be subscribed to for triggering the send. When subscribed, anull
item will be passed to theUni
when theMessage
is acknowledged. If theMessage
is never acknowledged, then theUni
will never be completed.The
Message
will not be sent to the channel until theUni
has been subscribed to:emitter.send("a").subscribe().with(x -> { });
- Parameters:
payload
- the thing to send, must not benull
- Returns:
- the
Uni
, that requires subscription to send theMessage
. - Throws:
IllegalStateException
- if the channel has been cancelled or terminated or if an overflow strategy ofTHROW_EXCEPTION
orBUFFER
is configured and the emitter overflows.
-
sendAndAwait
Sends a payload to the channel.A
Message
object will be created to hold the payload.Execution will block waiting for the resulting
Message
to be acknowledged before returning.- Parameters:
payload
- the thing 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.
-
sendAndForget
Sends a payload to the channel without waiting for acknowledgement.A
Message
object will be created to hold the payload.- Parameters:
payload
- the thing to send, must not benull
- Returns:
- the
Cancellable
from the subscribedUni
. - 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
Deprecated.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.
-
sendMessage
Sends a message to the channel.- Type Parameters:
M
- the Message type- Parameters:
msg
- the Message to send, must not benull
- Returns:
- the
Uni
, that requires subscription to send theMessage
. - Throws:
IllegalStateException
- if the channel has been cancelled or terminated or if an overflow strategy ofTHROW_EXCEPTION
orBUFFER
is configured and the emitter overflows.
-
sendMessageAndAwait
Sends a message to the channel. Execution will block waiting for the resultingMessage
to be acknowledged before returning.- 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.
-
sendMessageAndForget
<M extends Message<? extends T>> io.smallrye.mutiny.subscription.Cancellable sendMessageAndForget(M msg) Sends a message to the channel without waiting for acknowledgement.- Type Parameters:
M
- the Message type- Parameters:
msg
- the Message to send, must not benull
- Returns:
- the
Cancellable
from the subscribedUni
. - Throws:
IllegalStateException
- if the channel has been cancelled or terminated or if an overflow strategy ofTHROW_EXCEPTION
orBUFFER
is configured and the emitter overflows.
-
complete
void complete()Sends the completion event to the channel indicating that no other events will be sent afterward. -
error
Sends a failure event to the channel. No more events will be sent afterward.- Parameters:
e
- the exception, must not benull
-
isCancelled
boolean isCancelled()- Returns:
true
if the emitter has been terminated or the subscription cancelled.
-
hasRequests
boolean hasRequests()- Returns:
true
if one or more subscribers request messages from the corresponding channel where the emitter connects to, returnfalse
otherwise.
-
sendMessageAndForget(Message)
}