Class ProducerNode
- All Implemented Interfaces:
Node
Several of them is the point. "Two services publishing to the same exchange, one of them ten times louder" is a shape a single publisher block cannot describe, and it is the shape that produces the failures people are actually trying to reproduce.
Say the rate, not the threads. rate(long) is the number that means
something — messages a second, offered on a schedule. How many threads it takes to offer that is
arithmetic, and threads(int) is there for when the arithmetic is wrong.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanconfirms()confirms(boolean confirms) enabled(boolean enabled) exchange()What this producer is asked to prove.booleanbooleanintmaxInFlight(int inFlight) longmaxMessages(long max) intmessageSize(int bytes) name()payload()What the messages are made of.longrate()rate(long messagesPerSecond) routingKeys(String... keys) Publishes across several keys, one after another.intHow many threads this producer actually needs.threads(int threads) toString()As fast as it can, with no schedule.
-
Method Details
-
to
- Parameters:
exchange- where it publishes, empty for the default exchangeroutingKey- the key it publishes under- Returns:
- this producer
-
routingKeys
Publishes across several keys, one after another.What makes a topic exchange behave like a topic exchange. A producer on a single key measures one binding however many bindings the exchange has.
- Parameters:
keys- the keys, used in turn- Returns:
- this producer
-
rate
- Parameters:
messagesPerSecond- the offered rate, on a schedule- Returns:
- this producer
-
unthrottled
As fast as it can, with no schedule.Finds the ceiling, and makes the latency meaningless while doing it: an unthrottled generator stalls when the broker stalls, so it stops offering load exactly when the load was the interesting part.
- Returns:
- this producer
-
threads
- Parameters:
threads- how many threads offer this producer's rate, or 0 to work it out- Returns:
- this producer
-
messageSize
- Parameters:
bytes- how big each message body is- Returns:
- this producer
-
confirms
- Parameters:
confirms- whether to wait for the broker to confirm- Returns:
- this producer
-
maxMessages
- Parameters:
max- stop after this many messages, whatever the clock says- Returns:
- this producer
-
maxInFlight
- Parameters:
inFlight- how many publishes may be outstanding before it waits- Returns:
- this producer
-
enabled
- Parameters:
enabled- whether it publishes at all- Returns:
- this producer
-
expect
What this producer is asked to prove.- Parameters:
objectives- what to require of it- Returns:
- this producer
-
expectations
- Returns:
- what this producer is asked to prove, empty when nothing was asked
-
name
-
exchange
-
routingKeys
- Returns:
- the keys it publishes under, never empty: an unset key is the empty one
-
routingKey
- Returns:
- the first key, which is the only one for a producer that named one
-
rate
public long rate() -
isUnthrottled
public boolean isUnthrottled() -
threadCount
public int threadCount()How many threads this producer actually needs.Worked out from the rate when nobody said: a thread can offer a few tens of thousands a second before the schedule starts slipping, and a run whose generator could not keep up is a run that measured the generator. Somebody who knows better says
threads(int).- Returns:
- the thread count to use
-
messageSize
public int messageSize() -
payload
What the messages are made of.The size is enough for nearly everything, and this is for the case where it is not:
Payload.ofRandomBytes(int)gives every message a different body, which is what to use when a broker, a filesystem or a link between them might be compressing or deduplicating identical bodies and flattering the result.- Parameters:
payload- the payload, or null for the plain one ofmessageSize(int)bytes- Returns:
- this producer
-
payload
- Returns:
- what the messages are made of
-
confirms
public boolean confirms() -
maxMessages
public long maxMessages() -
maxInFlight
public int maxInFlight() -
isEnabled
public boolean isEnabled() -
toString
-