@InterfaceAudience.Public @InterfaceStability.Stable public interface Channel extends LifecycleAware, NamedComponent
A channel connects a Source
to a Sink
. The source
acts as producer while the sink acts as a consumer of events. The channel
itself is the buffer between the two.
A channel exposes a Transaction
interface that can be used by
its clients to ensure atomic put and
take semantics.
This is necessary to guarantee single hop reliability between agents.
For instance, a source will successfully produce an event
if and only if that event can be committed to the source's associated
channel. Similarly, a sink will consume an event if and
only if its respective endpoint can accept the event. The
extent of transaction support varies for different channel implementations
ranging from strong to best-effort semantics.
Channels are associated with unique names that can be used for separating configuration and working namespaces.
Channels must be thread safe, protecting any internal invariants as no guarantees are given as to when and by how many sources/sinks they may be simultaneously accessed by.
Source
,
Sink
,
Transaction
Modifier and Type | Method and Description |
---|---|
Transaction |
getTransaction() |
void |
put(Event event)
Puts the given event into the channel.
|
Event |
take()
Returns the next event from the channel if available.
|
getLifecycleState, start, stop
getName, setName
void put(Event event) throws ChannelException
Puts the given event into the channel.
Note: This method must be invoked within an active
Transaction
boundary. Failure to do so can lead to unpredictable
results.
event
- the event to transport.ChannelException
- in case this operation fails.Transaction.begin()
Event take() throws ChannelException
Returns the next event from the channel if available. If the channel
does not have any events available, this method must return null
.
Note: This method must be invoked within an active
Transaction
boundary. Failure to do so can lead to unpredictable
results.
null
if no events are
available.ChannelException
- in case this operation fails.Transaction.begin()
Transaction getTransaction()
Copyright © 2009–2019 Apache Software Foundation. All rights reserved.