public class PseudoTxnMemoryChannel extends AbstractChannel
A capacity-capped Channel
implementation that supports in-memory
buffering and delivery of events.
This channel is appropriate for
best effort
delivery of events where high throughput is favored over
data durability. To be clear, this channel offers absolutely no guarantee
of event delivery in the face of (any) component failure.
TODO: Discuss guarantees, corner cases re: potential data loss (e.g. consumer begins a tx, takes events, and gets SIGKILL before rollback).
Configuration options
Parameter | Description | Unit / Type | Default |
---|---|---|---|
capacity | The in-memory capacity of this channel. Store up to capacity events before refusing new events. | events / int | 50 |
keep-alive | The amount of time (seconds) to wait for an event before returning
null on take() . |
seconds / int | 3 |
Metrics
TODO
Modifier and Type | Class and Description |
---|---|
static class |
PseudoTxnMemoryChannel.NoOpTransaction
A no-op transaction implementation that does nothing at all.
|
Constructor and Description |
---|
PseudoTxnMemoryChannel() |
Modifier and Type | Method and Description |
---|---|
void |
configure(Context context)
Request the implementing class to (re)configure itself.
|
Transaction |
getTransaction() |
void |
put(Event event)
Puts the given event into the channel.
|
void |
start()
Starts a service or component.
|
void |
stop()
Stops a service or component.
|
Event |
take()
Returns the next event from the channel if available.
|
getLifecycleState, getName, setName, toString
public void configure(Context context)
Configurable
Request the implementing class to (re)configure itself.
When configuration parameters are changed, they must be reflected by the component asap.
There are no thread safety guarantees on when configure might be called.
configure
in interface Configurable
configure
in class AbstractChannel
public void start()
LifecycleAware
Starts a service or component.
Implementations should determine the result of any start logic and effect
the return value of LifecycleAware.getLifecycleState()
accordingly.
start
in interface LifecycleAware
start
in class AbstractChannel
public void stop()
LifecycleAware
Stops a service or component.
Implementations should determine the result of any stop logic and effect
the return value of LifecycleAware.getLifecycleState()
accordingly.
stop
in interface LifecycleAware
stop
in class AbstractChannel
public void put(Event event)
Channel
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.Transaction.begin()
public Event take()
Channel
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.Transaction.begin()
public Transaction getTransaction()
Copyright © 2009–2019 Apache Software Foundation. All rights reserved.