I don't know about 'normal', we use the mockproducer with autocomplete set
to false, and use a responseThread to simulate produce behaviour like this:

private final class ResponseThread extends Thread {

    public void run() {
        try {
            Thread.sleep(responseTime);
        } catch (InterruptedException e) {
            LOG.info("error simulating response time of the broker");
        }
        if (errorNow()) {
            ((MockProducer<K, V>) getProducer()).errorNext(new
TimeoutException());
        } else {
            ((MockProducer<K, V>) getProducer()).completeNext();
        }
    }
}

where the errorNow() is a function which depending on a parameter has
a change to give back an error.


On Wed, Jun 8, 2016 at 9:10 AM Steve Crane <steve.cr...@s3group.com> wrote:

> Anyone got any pointers to simple examples of their use?
>
> Through trial and error I have managed to queue a message to a mock
> consumer by:
>
> Initialisation:
>
>         TopicPartition partition = new TopicPartition(topicName, 0);
>         consumer.rebalance(singletonList(partition));
>         consumer.seek(partition, 0);
>
> Queuing a message:
>
> consumer.addRecord(new ConsumerRecord<>(topicName, 0, 0, key, obj));
>
> Is this the recommended way of doing things? Advice welcome!
>
> -----
>
> The information contained in this e-mail and in any attachments is
> confidential and is designated solely for the attention of the intended
> recipient(s). If you are not an intended recipient, you must not use,
> disclose, copy, distribute or retain this e-mail or any part thereof. If
> you have received this e-mail in error, please notify the sender by return
> e-mail and delete all copies of this e-mail from your computer system(s).
> Please direct any additional queries to: communicati...@s3group.com.
> Thank You. Silicon and Software Systems Limited (S3 Group). Registered in
> Ireland no. 378073. Registered Office: South County Business Park,
> Leopardstown, Dublin 18.
>

Reply via email to