Example:
import messaging.generator as generator;
# create the generator
mg = generator.Generator(
body_content = "binary",
body_size = 1024,
)
# use it to generate 10 messages
for i in range(10):
msg = mg.message()
... do something with it ...
This module provides a versatile message generator that can be useful for stress testing or benchmarking messaging brokers or libraries.
Copyright (C) 2012 CERN
A message generator tool.
Returns a newly generated Message object
Options
When creating a message generator, the following options can be given:
body-content
- string: specifying the body content type; depending on this value, the body will be made of:
- base64: only Base64 characters
- binary: anything
- index: the message index number, starting at 1, optionally adjusted to match the C<body-size> (this is the default)
- text: only printable 7-bit ASCII characters
Note: all integer options can be either positive (meaning exactly this value) or negative (meaning randomly distributed around the value).
For instance:
mg = Generator(
header_count = 10,
header_value_size = -20,
)
It will generate messages with exactly 10 random header fields, each field value having a random size between 0 and 40 and normally distributed around 20.
Set Generator option to value provided.
Maybe randomize int.
Returns a random text string of the given size (Base64 characters).
Returns a random binary string of the given size.
Returns a random integer between 0 and 2*size with a normal distribution.
See Irwin-Hall in http://en.wikipedia.org/wiki/Normal_distribution
Returns a random text string of the given size (all printable characters).