message.writeBytes(payload);
final int modulo = 10000;
TokenBucketLimiter tbl = perfParams.getThrottleRate() != -1 ? new TokenBucketLimiterImpl(perfParams.getThrottleRate(),
false)
: null;
boolean transacted = perfParams.isSessionTransacted();
int txBatchSize = perfParams.getBatchSize();
boolean display = true;
long start = System.currentTimeMillis();
long moduleStart = start;
AtomicLong count = new AtomicLong(0);
while (true)
{
try
{
producer.send(message);
count.incrementAndGet();
if (transacted)
{
if (count.longValue() % txBatchSize == 0)
{
session.commit();
}
}
long totalDuration = System.currentTimeMillis() - start;
if (display && count.longValue() % modulo == 0)
{
double duration = (1.0 * System.currentTimeMillis() - moduleStart) / 1000;
moduleStart = System.currentTimeMillis();
SoakSender.log.info(String.format("sent %s messages in %2.2fs (time: %.0fs)",
modulo,
duration,
totalDuration / 1000.0));
}
if (tbl != null)
{
tbl.limit();
}
if (!runInfinitely && totalDuration > perfParams.getDurationInMinutes() * SoakBase.TO_MILLIS)
{
break;