blob: 8c0645cbd34a3b337070eee22e124531ce2d74ec [file] [log] [blame]
<!DOCTYPE HTML>
<html lang="en">
<head>
<!-- Generated by javadoc (17) -->
<title>KafkaConsumer (kafka 3.6.1 API)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="declaration: package: org.apache.kafka.clients.consumer, class: KafkaConsumer">
<meta name="generator" content="javadoc/ClassWriterImpl">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../script-dir/jquery-ui.min.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../../jquery-ui.overrides.css" title="Style">
<script type="text/javascript" src="../../../../../script.js"></script>
<script type="text/javascript" src="../../../../../script-dir/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="../../../../../script-dir/jquery-ui.min.js"></script>
</head>
<body class="class-declaration-page">
<script type="text/javascript">var evenRowColor = "even-row-color";
var oddRowColor = "odd-row-color";
var tableTab = "table-tab";
var activeTableTab = "active-table-tab";
var pathtoroot = "../../../../../";
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="flex-box">
<header role="banner" class="flex-header">
<nav role="navigation">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="top-nav" id="navbar-top">
<div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div>
<ul id="navbar-top-firstrow" class="nav-list" title="Navigation">
<li><a href="../../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="nav-bar-cell1-rev">Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html#class">Help</a></li>
</ul>
</div>
<div class="sub-nav">
<div>
<ul class="sub-nav-list">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor-summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method-summary">Method</a></li>
</ul>
<ul class="sub-nav-list">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor-detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method-detail">Method</a></li>
</ul>
</div>
<div class="nav-list-search"><label for="search-input">SEARCH:</label>
<input type="text" id="search-input" value="search" disabled="disabled">
<input type="reset" id="reset-button" value="reset" disabled="disabled">
</div>
</div>
<!-- ========= END OF TOP NAVBAR ========= -->
<span class="skip-nav" id="skip-navbar-top"></span></nav>
</header>
<div class="flex-content">
<main role="main">
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="sub-title"><span class="package-label-in-type">Package</span>&nbsp;<a href="package-summary.html">org.apache.kafka.clients.consumer</a></div>
<h1 title="Class KafkaConsumer" class="title">Class KafkaConsumer&lt;K,<wbr>V&gt;</h1>
</div>
<div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">java.lang.Object</a>
<div class="inheritance">org.apache.kafka.clients.consumer.KafkaConsumer&lt;K,<wbr>V&gt;</div>
</div>
<section class="class-description" id="class-description">
<dl class="notes">
<dt>All Implemented Interfaces:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Closeable.html" title="class or interface in java.io" class="external-link">Closeable</a></code>, <code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/AutoCloseable.html" title="class or interface in java.lang" class="external-link">AutoCloseable</a></code>, <code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;K,<wbr>V&gt;</code></dd>
</dl>
<hr>
<div class="type-signature"><span class="modifiers">public class </span><span class="element-name type-name-label">KafkaConsumer&lt;K,<wbr>V&gt;</span>
<span class="extends-implements">extends <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a>
implements <a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;K,<wbr>V&gt;</span></div>
<div class="block">A client that consumes records from a Kafka cluster.
<p>
This client transparently handles the failure of Kafka brokers, and transparently adapts as topic partitions
it fetches migrate within the cluster. This client also interacts with the broker to allow groups of
consumers to load balance consumption using <a href="#consumergroups">consumer groups</a>.
<p>
The consumer maintains TCP connections to the necessary brokers to fetch data.
Failure to close the consumer after use will leak these connections.
The consumer is not thread-safe. See <a href="#multithreaded">Multi-threaded Processing</a> for more details.
<h3>Cross-Version Compatibility</h3>
This client can communicate with brokers that are version 0.10.0 or newer. Older or newer brokers may not support
certain features. For example, 0.10.0 brokers do not support offsetsForTimes, because this feature was added
in version 0.10.1. You will receive an <a href="../../common/errors/UnsupportedVersionException.html" title="class in org.apache.kafka.common.errors"><code>UnsupportedVersionException</code></a>
when invoking an API that is not available on the running broker version.
<p>
<h3>Offsets and Consumer Position</h3>
Kafka maintains a numerical offset for each record in a partition. This offset acts as a unique identifier of
a record within that partition, and also denotes the position of the consumer in the partition. For example, a consumer
which is at position 5 has consumed records with offsets 0 through 4 and will next receive the record with offset 5. There
are actually two notions of position relevant to the user of the consumer:
<p>
The <a href="#position(org.apache.kafka.common.TopicPartition)"><code>position</code></a> of the consumer gives the offset of the next record that will be given
out. It will be one larger than the highest offset the consumer has seen in that partition. It automatically advances
every time the consumer receives messages in a call to <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a>.
<p>
The <a href="#commitSync()"><code>committed position</code></a> is the last offset that has been stored securely. Should the
process fail and restart, this is the offset that the consumer will recover to. The consumer can either automatically commit
offsets periodically; or it can choose to control this committed position manually by calling one of the commit APIs
(e.g. <a href="#commitSync()"><code>commitSync</code></a> and <a href="#commitAsync(org.apache.kafka.clients.consumer.OffsetCommitCallback)"><code>commitAsync</code></a>).
<p>
This distinction gives the consumer control over when a record is considered consumed. It is discussed in further
detail below.
<h3><a name="consumergroups">Consumer Groups and Topic Subscriptions</a></h3>
Kafka uses the concept of <i>consumer groups</i> to allow a pool of processes to divide the work of consuming and
processing records. These processes can either be running on the same machine or they can be
distributed over many machines to provide scalability and fault tolerance for processing. All consumer instances
sharing the same <code>group.id</code> will be part of the same consumer group.
<p>
Each consumer in a group can dynamically set the list of topics it wants to subscribe to through one of the
<a href="#subscribe(java.util.Collection,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribe</code></a> APIs. Kafka will deliver each message in the
subscribed topics to one process in each consumer group. This is achieved by balancing the partitions between all
members in the consumer group so that each partition is assigned to exactly one consumer in the group. So if there
is a topic with four partitions, and a consumer group with two processes, each process would consume from two partitions.
<p>
Membership in a consumer group is maintained dynamically: if a process fails, the partitions assigned to it will
be reassigned to other consumers in the same group. Similarly, if a new consumer joins the group, partitions will be moved
from existing consumers to the new one. This is known as <i>rebalancing</i> the group and is discussed in more
detail <a href="#failuredetection">below</a>. Group rebalancing is also used when new partitions are added
to one of the subscribed topics or when a new topic matching a <a href="#subscribe(java.util.regex.Pattern,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribed regex</code></a>
is created. The group will automatically detect the new partitions through periodic metadata refreshes and
assign them to members of the group.
<p>
Conceptually you can think of a consumer group as being a single logical subscriber that happens to be made up of
multiple processes. As a multi-subscriber system, Kafka naturally supports having any number of consumer groups for a
given topic without duplicating data (additional consumers are actually quite cheap).
<p>
This is a slight generalization of the functionality that is common in messaging systems. To get semantics similar to
a queue in a traditional messaging system all processes would be part of a single consumer group and hence record
delivery would be balanced over the group like with a queue. Unlike a traditional messaging system, though, you can
have multiple such groups. To get semantics similar to pub-sub in a traditional messaging system each process would
have its own consumer group, so each process would subscribe to all the records published to the topic.
<p>
In addition, when group reassignment happens automatically, consumers can be notified through a <a href="ConsumerRebalanceListener.html" title="interface in org.apache.kafka.clients.consumer"><code>ConsumerRebalanceListener</code></a>,
which allows them to finish necessary application-level logic such as state cleanup, manual offset
commits, etc. See <a href="#rebalancecallback">Storing Offsets Outside Kafka</a> for more details.
<p>
It is also possible for the consumer to <a href="#manualassignment">manually assign</a> specific partitions
(similar to the older "simple" consumer) using <a href="#assign(java.util.Collection)"><code>assign(Collection)</code></a>. In this case, dynamic partition
assignment and consumer group coordination will be disabled.
<h3><a name="failuredetection">Detecting Consumer Failures</a></h3>
After subscribing to a set of topics, the consumer will automatically join the group when <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> is
invoked. The poll API is designed to ensure consumer liveness. As long as you continue to call poll, the consumer
will stay in the group and continue to receive messages from the partitions it was assigned. Underneath the covers,
the consumer sends periodic heartbeats to the server. If the consumer crashes or is unable to send heartbeats for
a duration of <code>session.timeout.ms</code>, then the consumer will be considered dead and its partitions will
be reassigned.
<p>
It is also possible that the consumer could encounter a "livelock" situation where it is continuing
to send heartbeats, but no progress is being made. To prevent the consumer from holding onto its partitions
indefinitely in this case, we provide a liveness detection mechanism using the <code>max.poll.interval.ms</code>
setting. Basically if you don't call poll at least as frequently as the configured max interval,
then the client will proactively leave the group so that another consumer can take over its partitions. When this happens,
you may see an offset commit failure (as indicated by a <a href="CommitFailedException.html" title="class in org.apache.kafka.clients.consumer"><code>CommitFailedException</code></a> thrown from a call to <a href="#commitSync()"><code>commitSync()</code></a>).
This is a safety mechanism which guarantees that only active members of the group are able to commit offsets.
So to stay in the group, you must continue to call poll.
<p>
The consumer provides two configuration settings to control the behavior of the poll loop:
<ol>
<li><code>max.poll.interval.ms</code>: By increasing the interval between expected polls, you can give
the consumer more time to handle a batch of records returned from <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a>. The drawback
is that increasing this value may delay a group rebalance since the consumer will only join the rebalance
inside the call to poll. You can use this setting to bound the time to finish a rebalance, but
you risk slower progress if the consumer cannot actually call <a href="#poll(java.time.Duration)"><code>poll</code></a> often enough.</li>
<li><code>max.poll.records</code>: Use this setting to limit the total records returned from a single
call to poll. This can make it easier to predict the maximum that must be handled within each poll
interval. By tuning this value, you may be able to reduce the poll interval, which will reduce the
impact of group rebalancing.</li>
</ol>
<p>
For use cases where message processing time varies unpredictably, neither of these options may be sufficient.
The recommended way to handle these cases is to move message processing to another thread, which allows
the consumer to continue calling <a href="#poll(java.time.Duration)"><code>poll</code></a> while the processor is still working.
Some care must be taken to ensure that committed offsets do not get ahead of the actual position.
Typically, you must disable automatic commits and manually commit processed offsets for records only after the
thread has finished handling them (depending on the delivery semantics you need).
Note also that you will need to <a href="#pause(java.util.Collection)"><code>pause</code></a> the partition so that no new records are received
from poll until after thread has finished handling those previously returned.
<h3>Usage Examples</h3>
The consumer APIs offer flexibility to cover a variety of consumption use cases. Here are some examples to
demonstrate how to use them.
<h4>Automatic Offset Committing</h4>
This example demonstrates a simple usage of Kafka's consumer api that relies on automatic offset committing.
<p>
<pre>
Properties props = new Properties();
props.setProperty(&quot;bootstrap.servers&quot;, &quot;localhost:9092&quot;);
props.setProperty(&quot;group.id&quot;, &quot;test&quot;);
props.setProperty(&quot;enable.auto.commit&quot;, &quot;true&quot;);
props.setProperty(&quot;auto.commit.interval.ms&quot;, &quot;1000&quot;);
props.setProperty(&quot;key.deserializer&quot;, &quot;org.apache.kafka.common.serialization.StringDeserializer&quot;);
props.setProperty(&quot;value.deserializer&quot;, &quot;org.apache.kafka.common.serialization.StringDeserializer&quot;);
KafkaConsumer&lt;String, String&gt; consumer = new KafkaConsumer&lt;&gt;(props);
consumer.subscribe(Arrays.asList(&quot;foo&quot;, &quot;bar&quot;));
while (true) {
ConsumerRecords&lt;String, String&gt; records = consumer.poll(Duration.ofMillis(100));
for (ConsumerRecord&lt;String, String&gt; record : records)
System.out.printf(&quot;offset = %d, key = %s, value = %s%n&quot;, record.offset(), record.key(), record.value());
}
</pre>
The connection to the cluster is bootstrapped by specifying a list of one or more brokers to contact using the
configuration <code>bootstrap.servers</code>. This list is just used to discover the rest of the brokers in the
cluster and need not be an exhaustive list of servers in the cluster (though you may want to specify more than one in
case there are servers down when the client is connecting).
<p>
Setting <code>enable.auto.commit</code> means that offsets are committed automatically with a frequency controlled by
the config <code>auto.commit.interval.ms</code>.
<p>
In this example the consumer is subscribing to the topics <i>foo</i> and <i>bar</i> as part of a group of consumers
called <i>test</i> as configured with <code>group.id</code>.
<p>
The deserializer settings specify how to turn bytes into objects. For example, by specifying string deserializers, we
are saying that our record's key and value will just be simple strings.
<h4>Manual Offset Control</h4>
Instead of relying on the consumer to periodically commit consumed offsets, users can also control when records
should be considered as consumed and hence commit their offsets. This is useful when the consumption of the messages
is coupled with some processing logic and hence a message should not be considered as consumed until it is completed processing.
<p>
<pre>
Properties props = new Properties();
props.setProperty(&quot;bootstrap.servers&quot;, &quot;localhost:9092&quot;);
props.setProperty(&quot;group.id&quot;, &quot;test&quot;);
props.setProperty(&quot;enable.auto.commit&quot;, &quot;false&quot;);
props.setProperty(&quot;key.deserializer&quot;, &quot;org.apache.kafka.common.serialization.StringDeserializer&quot;);
props.setProperty(&quot;value.deserializer&quot;, &quot;org.apache.kafka.common.serialization.StringDeserializer&quot;);
KafkaConsumer&lt;String, String&gt; consumer = new KafkaConsumer&lt;&gt;(props);
consumer.subscribe(Arrays.asList(&quot;foo&quot;, &quot;bar&quot;));
final int minBatchSize = 200;
List&lt;ConsumerRecord&lt;String, String&gt;&gt; buffer = new ArrayList&lt;&gt;();
while (true) {
ConsumerRecords&lt;String, String&gt; records = consumer.poll(Duration.ofMillis(100));
for (ConsumerRecord&lt;String, String&gt; record : records) {
buffer.add(record);
}
if (buffer.size() &gt;= minBatchSize) {
insertIntoDb(buffer);
consumer.commitSync();
buffer.clear();
}
}
</pre>
In this example we will consume a batch of records and batch them up in memory. When we have enough records
batched, we will insert them into a database. If we allowed offsets to auto commit as in the previous example, records
would be considered consumed after they were returned to the user in <a href="#poll(java.time.Duration)"><code>poll</code></a>. It would then be
possible
for our process to fail after batching the records, but before they had been inserted into the database.
<p>
To avoid this, we will manually commit the offsets only after the corresponding records have been inserted into the
database. This gives us exact control of when a record is considered consumed. This raises the opposite possibility:
the process could fail in the interval after the insert into the database but before the commit (even though this
would likely just be a few milliseconds, it is a possibility). In this case the process that took over consumption
would consume from last committed offset and would repeat the insert of the last batch of data. Used in this way
Kafka provides what is often called "at-least-once" delivery guarantees, as each record will likely be delivered one
time but in failure cases could be duplicated.
<p>
<b>Note: Using automatic offset commits can also give you "at-least-once" delivery, but the requirement is that
you must consume all data returned from each call to <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> before any subsequent calls, or before
<a href="#close()"><code>closing</code></a> the consumer. If you fail to do either of these, it is possible for the committed offset
to get ahead of the consumed position, which results in missing records. The advantage of using manual offset
control is that you have direct control over when a record is considered "consumed."</b>
<p>
The above example uses <a href="#commitSync()"><code>commitSync</code></a> to mark all received records as committed. In some cases
you may wish to have even finer control over which records have been committed by specifying an offset explicitly.
In the example below we commit offset after we finish handling the records in each partition.
<p>
<pre>
try {
while(running) {
ConsumerRecords&lt;String, String&gt; records = consumer.poll(Duration.ofMillis(Long.MAX_VALUE));
for (TopicPartition partition : records.partitions()) {
List&lt;ConsumerRecord&lt;String, String&gt;&gt; partitionRecords = records.records(partition);
for (ConsumerRecord&lt;String, String&gt; record : partitionRecords) {
System.out.println(record.offset() + &quot;: &quot; + record.value());
}
long lastOffset = partitionRecords.get(partitionRecords.size() - 1).offset();
consumer.commitSync(Collections.singletonMap(partition, new OffsetAndMetadata(lastOffset + 1)));
}
}
} finally {
consumer.close();
}
</pre>
<b>Note: The committed offset should always be the offset of the next message that your application will read.</b>
Thus, when calling <a href="#commitSync(java.util.Map)"><code>commitSync(offsets)</code></a> you should add one to the offset of the last message processed.
<h4><a name="manualassignment">Manual Partition Assignment</a></h4>
In the previous examples, we subscribed to the topics we were interested in and let Kafka dynamically assign a
fair share of the partitions for those topics based on the active consumers in the group. However, in
some cases you may need finer control over the specific partitions that are assigned. For example:
<p>
<ul>
<li>If the process is maintaining some kind of local state associated with that partition (like a
local on-disk key-value store), then it should only get records for the partition it is maintaining on disk.
<li>If the process itself is highly available and will be restarted if it fails (perhaps using a
cluster management framework like YARN, Mesos, or AWS facilities, or as part of a stream processing framework). In
this case there is no need for Kafka to detect the failure and reassign the partition since the consuming process
will be restarted on another machine.
</ul>
<p>
To use this mode, instead of subscribing to the topic using <a href="#subscribe(java.util.Collection)"><code>subscribe</code></a>, you just call
<a href="#assign(java.util.Collection)"><code>assign(Collection)</code></a> with the full list of partitions that you want to consume.
<pre>
String topic = &quot;foo&quot;;
TopicPartition partition0 = new TopicPartition(topic, 0);
TopicPartition partition1 = new TopicPartition(topic, 1);
consumer.assign(Arrays.asList(partition0, partition1));
</pre>
Once assigned, you can call <a href="#poll(java.time.Duration)"><code>poll</code></a> in a loop, just as in the preceding examples to consume
records. The group that the consumer specifies is still used for committing offsets, but now the set of partitions
will only change with another call to <a href="#assign(java.util.Collection)"><code>assign</code></a>. Manual partition assignment does
not use group coordination, so consumer failures will not cause assigned partitions to be rebalanced. Each consumer
acts independently even if it shares a groupId with another consumer. To avoid offset commit conflicts, you should
usually ensure that the groupId is unique for each consumer instance.
<p>
Note that it isn't possible to mix manual partition assignment (i.e. using <a href="#assign(java.util.Collection)"><code>assign</code></a>)
with dynamic partition assignment through topic subscription (i.e. using <a href="#subscribe(java.util.Collection)"><code>subscribe</code></a>).
<h4><a name="rebalancecallback">Storing Offsets Outside Kafka</h4>
The consumer application need not use Kafka's built-in offset storage, it can store offsets in a store of its own
choosing. The primary use case for this is allowing the application to store both the offset and the results of the
consumption in the same system in a way that both the results and offsets are stored atomically. This is not always
possible, but when it is it will make the consumption fully atomic and give "exactly once" semantics that are
stronger than the default "at-least once" semantics you get with Kafka's offset commit functionality.
<p>
Here are a couple of examples of this type of usage:
<ul>
<li>If the results of the consumption are being stored in a relational database, storing the offset in the database
as well can allow committing both the results and offset in a single transaction. Thus either the transaction will
succeed and the offset will be updated based on what was consumed or the result will not be stored and the offset
won't be updated.
<li>If the results are being stored in a local store it may be possible to store the offset there as well. For
example a search index could be built by subscribing to a particular partition and storing both the offset and the
indexed data together. If this is done in a way that is atomic, it is often possible to have it be the case that even
if a crash occurs that causes unsync'd data to be lost, whatever is left has the corresponding offset stored as well.
This means that in this case the indexing process that comes back having lost recent updates just resumes indexing
from what it has ensuring that no updates are lost.
</ul>
<p>
Each record comes with its own offset, so to manage your own offset you just need to do the following:
<ul>
<li>Configure <code>enable.auto.commit=false</code>
<li>Use the offset provided with each <a href="ConsumerRecord.html" title="class in org.apache.kafka.clients.consumer"><code>ConsumerRecord</code></a> to save your position.
<li>On restart restore the position of the consumer using <a href="#seek(org.apache.kafka.common.TopicPartition,long)"><code>seek(TopicPartition, long)</code></a>.
</ul>
<p>
This type of usage is simplest when the partition assignment is also done manually (this would be likely in the
search index use case described above). If the partition assignment is done automatically special care is
needed to handle the case where partition assignments change. This can be done by providing a
<a href="ConsumerRebalanceListener.html" title="interface in org.apache.kafka.clients.consumer"><code>ConsumerRebalanceListener</code></a> instance in the call to <a href="#subscribe(java.util.Collection,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribe(Collection, ConsumerRebalanceListener)</code></a>
and <a href="#subscribe(java.util.regex.Pattern,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribe(Pattern, ConsumerRebalanceListener)</code></a>.
For example, when partitions are taken from a consumer the consumer will want to commit its offset for those partitions by
implementing <a href="ConsumerRebalanceListener.html#onPartitionsRevoked(java.util.Collection)"><code>ConsumerRebalanceListener.onPartitionsRevoked(Collection)</code></a>. When partitions are assigned to a
consumer, the consumer will want to look up the offset for those new partitions and correctly initialize the consumer
to that position by implementing <a href="ConsumerRebalanceListener.html#onPartitionsAssigned(java.util.Collection)"><code>ConsumerRebalanceListener.onPartitionsAssigned(Collection)</code></a>.
<p>
Another common use for <a href="ConsumerRebalanceListener.html" title="interface in org.apache.kafka.clients.consumer"><code>ConsumerRebalanceListener</code></a> is to flush any caches the application maintains for
partitions that are moved elsewhere.
<h4>Controlling The Consumer's Position</h4>
In most use cases the consumer will simply consume records from beginning to end, periodically committing its
position (either automatically or manually). However Kafka allows the consumer to manually control its position,
moving forward or backwards in a partition at will. This means a consumer can re-consume older records, or skip to
the most recent records without actually consuming the intermediate records.
<p>
There are several instances where manually controlling the consumer's position can be useful.
<p>
One case is for time-sensitive record processing it may make sense for a consumer that falls far enough behind to not
attempt to catch up processing all records, but rather just skip to the most recent records.
<p>
Another use case is for a system that maintains local state as described in the previous section. In such a system
the consumer will want to initialize its position on start-up to whatever is contained in the local store. Likewise
if the local state is destroyed (say because the disk is lost) the state may be recreated on a new machine by
re-consuming all the data and recreating the state (assuming that Kafka is retaining sufficient history).
<p>
Kafka allows specifying the position using <a href="#seek(org.apache.kafka.common.TopicPartition,long)"><code>seek(TopicPartition, long)</code></a> to specify the new position. Special
methods for seeking to the earliest and latest offset the server maintains are also available (
<a href="#seekToBeginning(java.util.Collection)"><code>seekToBeginning(Collection)</code></a> and <a href="#seekToEnd(java.util.Collection)"><code>seekToEnd(Collection)</code></a> respectively).
<h4>Consumption Flow Control</h4>
If a consumer is assigned multiple partitions to fetch data from, it will try to consume from all of them at the same time,
effectively giving these partitions the same priority for consumption. However in some cases consumers may want to
first focus on fetching from some subset of the assigned partitions at full speed, and only start fetching other partitions
when these partitions have few or no data to consume.
<p>
One of such cases is stream processing, where processor fetches from two topics and performs the join on these two streams.
When one of the topics is long lagging behind the other, the processor would like to pause fetching from the ahead topic
in order to get the lagging stream to catch up. Another example is bootstrapping upon consumer starting up where there are
a lot of history data to catch up, the applications usually want to get the latest data on some of the topics before consider
fetching other topics.
<p>
Kafka supports dynamic controlling of consumption flows by using <a href="#pause(java.util.Collection)"><code>pause(Collection)</code></a> and <a href="#resume(java.util.Collection)"><code>resume(Collection)</code></a>
to pause the consumption on the specified assigned partitions and resume the consumption
on the specified paused partitions respectively in the future <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> calls.
<h3>Reading Transactional Messages</h3>
<p>
Transactions were introduced in Kafka 0.11.0 wherein applications can write to multiple topics and partitions atomically.
In order for this to work, consumers reading from these partitions should be configured to only read committed data.
This can be achieved by setting the <code>isolation.level=read_committed</code> in the consumer's configuration.
<p>
In <code>read_committed</code> mode, the consumer will read only those transactional messages which have been
successfully committed. It will continue to read non-transactional messages as before. There is no client-side
buffering in <code>read_committed</code> mode. Instead, the end offset of a partition for a <code>read_committed</code>
consumer would be the offset of the first message in the partition belonging to an open transaction. This offset
is known as the 'Last Stable Offset'(LSO).</p>
<p>
A <code>read_committed</code> consumer will only read up to the LSO and filter out any transactional
messages which have been aborted. The LSO also affects the behavior of <a href="#seekToEnd(java.util.Collection)"><code>seekToEnd(Collection)</code></a> and
<a href="#endOffsets(java.util.Collection)"><code>endOffsets(Collection)</code></a> for <code>read_committed</code> consumers, details of which are in each method's documentation.
Finally, the fetch lag metrics are also adjusted to be relative to the LSO for <code>read_committed</code> consumers.
<p>
Partitions with transactional messages will include commit or abort markers which indicate the result of a transaction.
There markers are not returned to applications, yet have an offset in the log. As a result, applications reading from
topics with transactional messages will see gaps in the consumed offsets. These missing messages would be the transaction
markers, and they are filtered out for consumers in both isolation levels. Additionally, applications using
<code>read_committed</code> consumers may also see gaps due to aborted transactions, since those messages would not
be returned by the consumer and yet would have valid offsets.
<h3><a name="multithreaded">Multi-threaded Processing</a></h3>
The Kafka consumer is NOT thread-safe. All network I/O happens in the thread of the application
making the call. It is the responsibility of the user to ensure that multi-threaded access
is properly synchronized. Un-synchronized access will result in <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/ConcurrentModificationException.html" title="class or interface in java.util" class="external-link"><code>ConcurrentModificationException</code></a>.
<p>
The only exception to this rule is <a href="#wakeup()"><code>wakeup()</code></a>, which can safely be used from an external thread to
interrupt an active operation. In this case, a <a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors"><code>WakeupException</code></a> will be
thrown from the thread blocking on the operation. This can be used to shutdown the consumer from another thread.
The following snippet shows the typical pattern:
<pre>
public class KafkaConsumerRunner implements Runnable {
private final AtomicBoolean closed = new AtomicBoolean(false);
private final KafkaConsumer consumer;
public KafkaConsumerRunner(KafkaConsumer consumer) {
this.consumer = consumer;
}
@Override
public void run() {
try {
consumer.subscribe(Arrays.asList("topic"));
while (!closed.get()) {
ConsumerRecords records = consumer.poll(Duration.ofMillis(10000));
// Handle new records
}
} catch (WakeupException e) {
// Ignore exception if closing
if (!closed.get()) throw e;
} finally {
consumer.close();
}
}
// Shutdown hook which can be called from a separate thread
public void shutdown() {
closed.set(true);
consumer.wakeup();
}
}
</pre>
Then in a separate thread, the consumer can be shutdown by setting the closed flag and waking up the consumer.
<p>
<pre>
closed.set(true);
consumer.wakeup();
</pre>
<p>
Note that while it is possible to use thread interrupts instead of <a href="#wakeup()"><code>wakeup()</code></a> to abort a blocking operation
(in which case, <a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors"><code>InterruptException</code></a> will be raised), we discourage their use since they may cause a clean
shutdown of the consumer to be aborted. Interrupts are mainly supported for those cases where using <a href="#wakeup()"><code>wakeup()</code></a>
is impossible, e.g. when a consumer thread is managed by code that is unaware of the Kafka client.
<p>
We have intentionally avoided implementing a particular threading model for processing. This leaves several
options for implementing multi-threaded processing of records.
<h4>1. One Consumer Per Thread</h4>
A simple option is to give each thread its own consumer instance. Here are the pros and cons of this approach:
<ul>
<li><b>PRO</b>: It is the easiest to implement
<li><b>PRO</b>: It is often the fastest as no inter-thread co-ordination is needed
<li><b>PRO</b>: It makes in-order processing on a per-partition basis very easy to implement (each thread just
processes messages in the order it receives them).
<li><b>CON</b>: More consumers means more TCP connections to the cluster (one per thread). In general Kafka handles
connections very efficiently so this is generally a small cost.
<li><b>CON</b>: Multiple consumers means more requests being sent to the server and slightly less batching of data
which can cause some drop in I/O throughput.
<li><b>CON</b>: The number of total threads across all processes will be limited by the total number of partitions.
</ul>
<h4>2. Decouple Consumption and Processing</h4>
Another alternative is to have one or more consumer threads that do all data consumption and hands off
<a href="ConsumerRecords.html" title="class in org.apache.kafka.clients.consumer"><code>ConsumerRecords</code></a> instances to a blocking queue consumed by a pool of processor threads that actually handle
the record processing.
This option likewise has pros and cons:
<ul>
<li><b>PRO</b>: This option allows independently scaling the number of consumers and processors. This makes it
possible to have a single consumer that feeds many processor threads, avoiding any limitation on partitions.
<li><b>CON</b>: Guaranteeing order across the processors requires particular care as the threads will execute
independently an earlier chunk of data may actually be processed after a later chunk of data just due to the luck of
thread execution timing. For processing that has no ordering requirements this is not a problem.
<li><b>CON</b>: Manually committing the position becomes harder as it requires that all threads co-ordinate to ensure
that processing is complete for that partition.
</ul>
There are many possible variations on this approach. For example each processor thread can have its own queue, and
the consumer threads can hash into these queues using the TopicPartition to ensure in-order consumption and simplify
commit.</div>
</section>
<section class="summary">
<ul class="summary-list">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<li>
<section class="constructor-summary" id="constructor-summary">
<h2>Constructor Summary</h2>
<div class="caption"><span>Constructors</span></div>
<div class="summary-table two-column-summary">
<div class="table-header col-first">Constructor</div>
<div class="table-header col-last">Description</div>
<div class="col-constructor-name even-row-color"><code><a href="#%3Cinit%3E(java.util.Map)" class="member-name-link">KafkaConsumer</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a>&gt;&nbsp;configs)</code></div>
<div class="col-last even-row-color">
<div class="block">A consumer is instantiated by providing a set of key-value pairs as configuration.</div>
</div>
<div class="col-constructor-name odd-row-color"><code><a href="#%3Cinit%3E(java.util.Map,org.apache.kafka.common.serialization.Deserializer,org.apache.kafka.common.serialization.Deserializer)" class="member-name-link">KafkaConsumer</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a>&gt;&nbsp;configs,
<a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization">Deserializer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>&gt;&nbsp;keyDeserializer,
<a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization">Deserializer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;&nbsp;valueDeserializer)</code></div>
<div class="col-last odd-row-color">
<div class="block">A consumer is instantiated by providing a set of key-value pairs as configuration, and a key and a value <a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization"><code>Deserializer</code></a>.</div>
</div>
<div class="col-constructor-name even-row-color"><code><a href="#%3Cinit%3E(java.util.Properties)" class="member-name-link">KafkaConsumer</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Properties.html" title="class or interface in java.util" class="external-link">Properties</a>&nbsp;properties)</code></div>
<div class="col-last even-row-color">
<div class="block">A consumer is instantiated by providing a <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Properties.html" title="class or interface in java.util" class="external-link"><code>Properties</code></a> object as configuration.</div>
</div>
<div class="col-constructor-name odd-row-color"><code><a href="#%3Cinit%3E(java.util.Properties,org.apache.kafka.common.serialization.Deserializer,org.apache.kafka.common.serialization.Deserializer)" class="member-name-link">KafkaConsumer</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Properties.html" title="class or interface in java.util" class="external-link">Properties</a>&nbsp;properties,
<a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization">Deserializer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>&gt;&nbsp;keyDeserializer,
<a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization">Deserializer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;&nbsp;valueDeserializer)</code></div>
<div class="col-last odd-row-color">
<div class="block">A consumer is instantiated by providing a <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Properties.html" title="class or interface in java.util" class="external-link"><code>Properties</code></a> object as configuration, and a
key and a value <a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization"><code>Deserializer</code></a>.</div>
</div>
</div>
</section>
</li>
<!-- ========== METHOD SUMMARY =========== -->
<li>
<section class="method-summary" id="method-summary">
<h2>Method Summary</h2>
<div id="method-summary-table">
<div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab4" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab4', 3)" class="table-tab">Concrete Methods</button><button id="method-summary-table-tab6" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab6', 3)" class="table-tab">Deprecated Methods</button></div>
<div id="method-summary-table.tabpanel" role="tabpanel">
<div class="summary-table three-column-summary" aria-labelledby="method-summary-table-tab0">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Method</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#assign(java.util.Collection)" class="member-name-link">assign</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Manually assign a list of partitions to this consumer.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#assignment()" class="member-name-link">assignment</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the set of partitions currently assigned to this consumer.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#beginningOffsets(java.util.Collection)" class="member-name-link">beginningOffsets</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the first offset for the given partitions.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#beginningOffsets(java.util.Collection,java.time.Duration)" class="member-name-link">beginningOffsets</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the first offset for the given partitions.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#close()" class="member-name-link">close</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Close the consumer, waiting for up to the default timeout of 30 seconds for any needed cleanup.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#close(java.time.Duration)" class="member-name-link">close</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Tries to close the consumer cleanly within the specified timeout.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#commitAsync()" class="member-name-link">commitAsync</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Commit offsets returned on the last <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> for all the subscribed list of topics and partition.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#commitAsync(java.util.Map,org.apache.kafka.clients.consumer.OffsetCommitCallback)" class="member-name-link">commitAsync</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a>&gt;&nbsp;offsets,
<a href="OffsetCommitCallback.html" title="interface in org.apache.kafka.clients.consumer">OffsetCommitCallback</a>&nbsp;callback)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Commit the specified offsets for the specified list of topics and partitions to Kafka.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#commitAsync(org.apache.kafka.clients.consumer.OffsetCommitCallback)" class="member-name-link">commitAsync</a><wbr>(<a href="OffsetCommitCallback.html" title="interface in org.apache.kafka.clients.consumer">OffsetCommitCallback</a>&nbsp;callback)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Commit offsets returned on the last <a href="#poll(java.time.Duration)"><code>poll()</code></a> for the subscribed list of topics and partitions.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#commitSync()" class="member-name-link">commitSync</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Commit offsets returned on the last <a href="#poll(java.time.Duration)"><code>poll()</code></a> for all the subscribed list of topics and
partitions.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#commitSync(java.time.Duration)" class="member-name-link">commitSync</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Commit offsets returned on the last <a href="#poll(java.time.Duration)"><code>poll()</code></a> for all the subscribed list of topics and
partitions.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#commitSync(java.util.Map)" class="member-name-link">commitSync</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a>&gt;&nbsp;offsets)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Commit the specified offsets for the specified list of topics and partitions.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#commitSync(java.util.Map,java.time.Duration)" class="member-name-link">commitSync</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a>&gt;&nbsp;offsets,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Commit the specified offsets for the specified list of topics and partitions.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#committed(java.util.Set)" class="member-name-link">committed</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the last committed offsets for the given partitions (whether the commit happened by this process or
another).</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a>&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#committed(java.util.Set,java.time.Duration)" class="member-name-link">committed</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the last committed offsets for the given partitions (whether the commit happened by this process or
another).</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4 method-summary-table-tab6"><code><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4 method-summary-table-tab6"><code><a href="#committed(org.apache.kafka.common.TopicPartition)" class="member-name-link">committed</a><wbr>(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;partition)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4 method-summary-table-tab6">
<div class="block"><span class="deprecated-label">Deprecated.</span>
<div class="deprecation-comment">since 2.4 Use <a href="#committed(java.util.Set)"><code>committed(Set)</code></a> instead</div>
</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4 method-summary-table-tab6"><code><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4 method-summary-table-tab6"><code><a href="#committed(org.apache.kafka.common.TopicPartition,java.time.Duration)" class="member-name-link">committed</a><wbr>(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;partition,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4 method-summary-table-tab6">
<div class="block"><span class="deprecated-label">Deprecated.</span>
<div class="deprecation-comment">since 2.4 Use <a href="#committed(java.util.Set,java.time.Duration)"><code>committed(Set, Duration)</code></a> instead</div>
</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/OptionalLong.html" title="class or interface in java.util" class="external-link">OptionalLong</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#currentLag(org.apache.kafka.common.TopicPartition)" class="member-name-link">currentLag</a><wbr>(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;topicPartition)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the consumer's current lag on the partition.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#endOffsets(java.util.Collection)" class="member-name-link">endOffsets</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the end offsets for the given partitions.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#endOffsets(java.util.Collection,java.time.Duration)" class="member-name-link">endOffsets</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the end offsets for the given partitions.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#enforceRebalance()" class="member-name-link">enforceRebalance</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#enforceRebalance(java.lang.String)" class="member-name-link">enforceRebalance</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&nbsp;reason)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Alert the consumer to trigger a new rebalance by rejoining the group.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="ConsumerGroupMetadata.html" title="class in org.apache.kafka.clients.consumer">ConsumerGroupMetadata</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#groupMetadata()" class="member-name-link">groupMetadata</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Return the current group metadata associated with this consumer.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../common/PartitionInfo.html" title="class in org.apache.kafka.common">PartitionInfo</a>&gt;&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#listTopics()" class="member-name-link">listTopics</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get metadata about partitions for all topics that the user is authorized to view.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../common/PartitionInfo.html" title="class in org.apache.kafka.common">PartitionInfo</a>&gt;&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#listTopics(java.time.Duration)" class="member-name-link">listTopics</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get metadata about partitions for all topics that the user is authorized to view.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/MetricName.html" title="class in org.apache.kafka.common">MetricName</a>,<wbr>? extends <a href="../../common/Metric.html" title="interface in org.apache.kafka.common">Metric</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#metrics()" class="member-name-link">metrics</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the metrics kept by the consumer</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndTimestamp.html" title="class in org.apache.kafka.clients.consumer">OffsetAndTimestamp</a>&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#offsetsForTimes(java.util.Map)" class="member-name-link">offsetsForTimes</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>&gt;&nbsp;timestampsToSearch)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Look up the offsets for the given partitions by timestamp.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndTimestamp.html" title="class in org.apache.kafka.clients.consumer">OffsetAndTimestamp</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#offsetsForTimes(java.util.Map,java.time.Duration)" class="member-name-link">offsetsForTimes</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>&gt;&nbsp;timestampsToSearch,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Look up the offsets for the given partitions by timestamp.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../common/PartitionInfo.html" title="class in org.apache.kafka.common">PartitionInfo</a>&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#partitionsFor(java.lang.String)" class="member-name-link">partitionsFor</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&nbsp;topic)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get metadata about the partitions for a given topic.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../common/PartitionInfo.html" title="class in org.apache.kafka.common">PartitionInfo</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#partitionsFor(java.lang.String,java.time.Duration)" class="member-name-link">partitionsFor</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&nbsp;topic,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get metadata about the partitions for a given topic.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#pause(java.util.Collection)" class="member-name-link">pause</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Suspend fetching from the requested partitions.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#paused()" class="member-name-link">paused</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the set of partitions that were previously paused by a call to <a href="#pause(java.util.Collection)"><code>pause(Collection)</code></a>.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4 method-summary-table-tab6"><code><a href="ConsumerRecords.html" title="class in org.apache.kafka.clients.consumer">ConsumerRecords</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4 method-summary-table-tab6"><code><a href="#poll(long)" class="member-name-link">poll</a><wbr>(long&nbsp;timeoutMs)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4 method-summary-table-tab6">
<div class="block"><span class="deprecated-label">Deprecated.</span>
<div class="deprecation-comment">Since 2.0.</div>
</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="ConsumerRecords.html" title="class in org.apache.kafka.clients.consumer">ConsumerRecords</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#poll(java.time.Duration)" class="member-name-link">poll</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Fetch data for the topics or partitions specified using one of the subscribe/assign APIs.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>long</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#position(org.apache.kafka.common.TopicPartition)" class="member-name-link">position</a><wbr>(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;partition)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the offset of the <i>next record</i> that will be fetched (if a record with that offset exists).</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>long</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#position(org.apache.kafka.common.TopicPartition,java.time.Duration)" class="member-name-link">position</a><wbr>(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;partition,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the offset of the <i>next record</i> that will be fetched (if a record with that offset exists).</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#resume(java.util.Collection)" class="member-name-link">resume</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Resume specified partitions which have been paused with <a href="#pause(java.util.Collection)"><code>pause(Collection)</code></a>.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#seek(org.apache.kafka.common.TopicPartition,long)" class="member-name-link">seek</a><wbr>(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;partition,
long&nbsp;offset)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Overrides the fetch offsets that the consumer will use on the next <a href="#poll(java.time.Duration)"><code>poll(timeout)</code></a>.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#seek(org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata)" class="member-name-link">seek</a><wbr>(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;partition,
<a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a>&nbsp;offsetAndMetadata)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Overrides the fetch offsets that the consumer will use on the next <a href="#poll(java.time.Duration)"><code>poll(timeout)</code></a>.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#seekToBeginning(java.util.Collection)" class="member-name-link">seekToBeginning</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Seek to the first offset for each of the given partitions.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#seekToEnd(java.util.Collection)" class="member-name-link">seekToEnd</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Seek to the last offset for each of the given partitions.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#subscribe(java.util.Collection)" class="member-name-link">subscribe</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&gt;&nbsp;topics)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Subscribe to the given list of topics to get dynamically assigned partitions.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#subscribe(java.util.Collection,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)" class="member-name-link">subscribe</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&gt;&nbsp;topics,
<a href="ConsumerRebalanceListener.html" title="interface in org.apache.kafka.clients.consumer">ConsumerRebalanceListener</a>&nbsp;listener)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Subscribe to the given list of topics to get dynamically
assigned partitions.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#subscribe(java.util.regex.Pattern)" class="member-name-link">subscribe</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html" title="class or interface in java.util.regex" class="external-link">Pattern</a>&nbsp;pattern)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Subscribe to all topics matching specified pattern to get dynamically assigned partitions.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#subscribe(java.util.regex.Pattern,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)" class="member-name-link">subscribe</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html" title="class or interface in java.util.regex" class="external-link">Pattern</a>&nbsp;pattern,
<a href="ConsumerRebalanceListener.html" title="interface in org.apache.kafka.clients.consumer">ConsumerRebalanceListener</a>&nbsp;listener)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Subscribe to all topics matching specified pattern to get dynamically assigned partitions.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#subscription()" class="member-name-link">subscription</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Get the current subscription.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#unsubscribe()" class="member-name-link">unsubscribe</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Unsubscribe from topics currently subscribed with <a href="#subscribe(java.util.Collection)"><code>subscribe(Collection)</code></a> or <a href="#subscribe(java.util.regex.Pattern)"><code>subscribe(Pattern)</code></a>.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#wakeup()" class="member-name-link">wakeup</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Wakeup the consumer.</div>
</div>
</div>
</div>
</div>
<div class="inherited-list">
<h3 id="methods-inherited-from-class-java.lang.Object">Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></h3>
<code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#clone()" title="class or interface in java.lang" class="external-link">clone</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link">equals</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#finalize()" title="class or interface in java.lang" class="external-link">finalize</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#getClass()" title="class or interface in java.lang" class="external-link">getClass</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#hashCode()" title="class or interface in java.lang" class="external-link">hashCode</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#notify()" title="class or interface in java.lang" class="external-link">notify</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#notifyAll()" title="class or interface in java.lang" class="external-link">notifyAll</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#toString()" title="class or interface in java.lang" class="external-link">toString</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait()" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait(long)" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait(long,int)" title="class or interface in java.lang" class="external-link">wait</a></code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="details-list">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<li>
<section class="constructor-details" id="constructor-detail">
<h2>Constructor Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="&lt;init&gt;(java.util.Map)">
<h3>KafkaConsumer</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="element-name">KafkaConsumer</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a>&gt;&nbsp;configs)</span></div>
<div class="block">A consumer is instantiated by providing a set of key-value pairs as configuration. Valid configuration strings
are documented <a href="http://kafka.apache.org/documentation.html#consumerconfigs">here</a>. Values can be
either strings or objects of the appropriate type (for example a numeric configuration would accept either the
string "42" or the integer 42).
<p>
Valid configuration strings are documented at <a href="ConsumerConfig.html" title="class in org.apache.kafka.clients.consumer"><code>ConsumerConfig</code></a>.
<p>
Note: after creating a <code>KafkaConsumer</code> you must always <a href="#close()"><code>close()</code></a> it to avoid resource leaks.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>configs</code> - The consumer configs</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="&lt;init&gt;(java.util.Properties)">
<h3>KafkaConsumer</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="element-name">KafkaConsumer</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Properties.html" title="class or interface in java.util" class="external-link">Properties</a>&nbsp;properties)</span></div>
<div class="block">A consumer is instantiated by providing a <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Properties.html" title="class or interface in java.util" class="external-link"><code>Properties</code></a> object as configuration.
<p>
Valid configuration strings are documented at <a href="ConsumerConfig.html" title="class in org.apache.kafka.clients.consumer"><code>ConsumerConfig</code></a>.
<p>
Note: after creating a <code>KafkaConsumer</code> you must always <a href="#close()"><code>close()</code></a> it to avoid resource leaks.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>properties</code> - The consumer configuration properties</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="&lt;init&gt;(java.util.Properties,org.apache.kafka.common.serialization.Deserializer,org.apache.kafka.common.serialization.Deserializer)">
<h3>KafkaConsumer</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="element-name">KafkaConsumer</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Properties.html" title="class or interface in java.util" class="external-link">Properties</a>&nbsp;properties,
<a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization">Deserializer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>&gt;&nbsp;keyDeserializer,
<a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization">Deserializer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;&nbsp;valueDeserializer)</span></div>
<div class="block">A consumer is instantiated by providing a <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Properties.html" title="class or interface in java.util" class="external-link"><code>Properties</code></a> object as configuration, and a
key and a value <a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization"><code>Deserializer</code></a>.
<p>
Valid configuration strings are documented at <a href="ConsumerConfig.html" title="class in org.apache.kafka.clients.consumer"><code>ConsumerConfig</code></a>.
<p>
Note: after creating a <code>KafkaConsumer</code> you must always <a href="#close()"><code>close()</code></a> it to avoid resource leaks.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>properties</code> - The consumer configuration properties</dd>
<dd><code>keyDeserializer</code> - The deserializer for key that implements <a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization"><code>Deserializer</code></a>. The configure() method
won't be called in the consumer when the deserializer is passed in directly.</dd>
<dd><code>valueDeserializer</code> - The deserializer for value that implements <a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization"><code>Deserializer</code></a>. The configure() method
won't be called in the consumer when the deserializer is passed in directly.</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="&lt;init&gt;(java.util.Map,org.apache.kafka.common.serialization.Deserializer,org.apache.kafka.common.serialization.Deserializer)">
<h3>KafkaConsumer</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="element-name">KafkaConsumer</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a>&gt;&nbsp;configs,
<a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization">Deserializer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>&gt;&nbsp;keyDeserializer,
<a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization">Deserializer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;&nbsp;valueDeserializer)</span></div>
<div class="block">A consumer is instantiated by providing a set of key-value pairs as configuration, and a key and a value <a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization"><code>Deserializer</code></a>.
<p>
Valid configuration strings are documented at <a href="ConsumerConfig.html" title="class in org.apache.kafka.clients.consumer"><code>ConsumerConfig</code></a>.
<p>
Note: after creating a <code>KafkaConsumer</code> you must always <a href="#close()"><code>close()</code></a> it to avoid resource leaks.</div>
<dl class="notes">
<dt>Parameters:</dt>
<dd><code>configs</code> - The consumer configs</dd>
<dd><code>keyDeserializer</code> - The deserializer for key that implements <a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization"><code>Deserializer</code></a>. The configure() method
won't be called in the consumer when the deserializer is passed in directly.</dd>
<dd><code>valueDeserializer</code> - The deserializer for value that implements <a href="../../common/serialization/Deserializer.html" title="interface in org.apache.kafka.common.serialization"><code>Deserializer</code></a>. The configure() method
won't be called in the consumer when the deserializer is passed in directly.</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
<!-- ============ METHOD DETAIL ========== -->
<li>
<section class="method-details" id="method-detail">
<h2>Method Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="assignment()">
<h3>assignment</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;</span>&nbsp;<span class="element-name">assignment</span>()</div>
<div class="block">Get the set of partitions currently assigned to this consumer. If subscription happened by directly assigning
partitions using <a href="#assign(java.util.Collection)"><code>assign(Collection)</code></a> then this will simply return the same partitions that
were assigned. If topic subscription was used, then this will give the set of topic partitions currently assigned
to the consumer (which may be none if the assignment hasn't happened yet, or the partitions are in the
process of getting reassigned).</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#assignment()">assignment</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Returns:</dt>
<dd>The set of partitions currently assigned to this consumer</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#assignment()"><code>assignment()</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="subscription()">
<h3>subscription</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&gt;</span>&nbsp;<span class="element-name">subscription</span>()</div>
<div class="block">Get the current subscription. Will return the same topics used in the most recent call to
<a href="#subscribe(java.util.Collection,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribe(Collection, ConsumerRebalanceListener)</code></a>, or an empty set if no such call has been made.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#subscription()">subscription</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Returns:</dt>
<dd>The set of topics currently subscribed to</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#subscription()"><code>subscription()</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="subscribe(java.util.Collection,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)">
<h3>subscribe</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">subscribe</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&gt;&nbsp;topics,
<a href="ConsumerRebalanceListener.html" title="interface in org.apache.kafka.clients.consumer">ConsumerRebalanceListener</a>&nbsp;listener)</span></div>
<div class="block">Subscribe to the given list of topics to get dynamically
assigned partitions. <b>Topic subscriptions are not incremental. This list will replace the current
assignment (if there is one).</b> Note that it is not possible to combine topic subscription with group management
with manual partition assignment through <a href="#assign(java.util.Collection)"><code>assign(Collection)</code></a>.
If the given list of topics is empty, it is treated the same as <a href="#unsubscribe()"><code>unsubscribe()</code></a>.
<p>
As part of group management, the consumer will keep track of the list of consumers that belong to a particular
group and will trigger a rebalance operation if any one of the following events are triggered:
<ul>
<li>Number of partitions change for any of the subscribed topics
<li>A subscribed topic is created or deleted
<li>An existing member of the consumer group is shutdown or fails
<li>A new member is added to the consumer group
</ul>
<p>
When any of these events are triggered, the provided listener will be invoked first to indicate that
the consumer's assignment has been revoked, and then again when the new assignment has been received.
Note that rebalances will only occur during an active call to <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a>, so callbacks will
also only be invoked during that time.
The provided listener will immediately override any listener set in a previous call to subscribe.
It is guaranteed, however, that the partitions revoked/assigned through this interface are from topics
subscribed in this call. See <a href="ConsumerRebalanceListener.html" title="interface in org.apache.kafka.clients.consumer"><code>ConsumerRebalanceListener</code></a> for more details.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#subscribe(java.util.Collection,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)">subscribe</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>topics</code> - The list of topics to subscribe to</dd>
<dd><code>listener</code> - Non-null listener instance to get notifications on partition assignment/revocation for the
subscribed topics</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - If topics is null or contains null or empty elements, or if listener is null</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - If <code>subscribe()</code> is called previously with pattern, or assign is called
previously (without a subsequent call to <a href="#unsubscribe()"><code>unsubscribe()</code></a>), or if not
configured at-least one partition assignment strategy</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list-long">
<li><a href="#subscribe(java.util.Collection,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribe(Collection, ConsumerRebalanceListener)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="subscribe(java.util.Collection)">
<h3>subscribe</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">subscribe</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&gt;&nbsp;topics)</span></div>
<div class="block">Subscribe to the given list of topics to get dynamically assigned partitions.
<b>Topic subscriptions are not incremental. This list will replace the current
assignment (if there is one).</b> It is not possible to combine topic subscription with group management
with manual partition assignment through <a href="#assign(java.util.Collection)"><code>assign(Collection)</code></a>.
If the given list of topics is empty, it is treated the same as <a href="#unsubscribe()"><code>unsubscribe()</code></a>.
<p>
This is a short-hand for <a href="#subscribe(java.util.Collection,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribe(Collection, ConsumerRebalanceListener)</code></a>, which
uses a no-op listener. If you need the ability to seek to particular offsets, you should prefer
<a href="#subscribe(java.util.Collection,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribe(Collection, ConsumerRebalanceListener)</code></a>, since group rebalances will cause partition offsets
to be reset. You should also provide your own listener if you are doing your own offset
management since the listener gives you an opportunity to commit offsets before a rebalance finishes.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#subscribe(java.util.Collection)">subscribe</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>topics</code> - The list of topics to subscribe to</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - If topics is null or contains null or empty elements</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - If <code>subscribe()</code> is called previously with pattern, or assign is called
previously (without a subsequent call to <a href="#unsubscribe()"><code>unsubscribe()</code></a>), or if not
configured at-least one partition assignment strategy</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#subscribe(java.util.Collection)"><code>subscribe(Collection)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="subscribe(java.util.regex.Pattern,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)">
<h3>subscribe</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">subscribe</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html" title="class or interface in java.util.regex" class="external-link">Pattern</a>&nbsp;pattern,
<a href="ConsumerRebalanceListener.html" title="interface in org.apache.kafka.clients.consumer">ConsumerRebalanceListener</a>&nbsp;listener)</span></div>
<div class="block">Subscribe to all topics matching specified pattern to get dynamically assigned partitions.
The pattern matching will be done periodically against all topics existing at the time of check.
This can be controlled through the <code>metadata.max.age.ms</code> configuration: by lowering
the max metadata age, the consumer will refresh metadata more often and check for matching topics.
<p>
See <a href="#subscribe(java.util.Collection,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribe(Collection, ConsumerRebalanceListener)</code></a> for details on the
use of the <a href="ConsumerRebalanceListener.html" title="interface in org.apache.kafka.clients.consumer"><code>ConsumerRebalanceListener</code></a>. Generally rebalances are triggered when there
is a change to the topics matching the provided pattern and when consumer group membership changes.
Group rebalances only take place during an active call to <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a>.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#subscribe(java.util.regex.Pattern,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)">subscribe</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>pattern</code> - Pattern to subscribe to</dd>
<dd><code>listener</code> - Non-null listener instance to get notifications on partition assignment/revocation for the
subscribed topics</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - If pattern or listener is null</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - If <code>subscribe()</code> is called previously with topics, or assign is called
previously (without a subsequent call to <a href="#unsubscribe()"><code>unsubscribe()</code></a>), or if not
configured at-least one partition assignment strategy</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list-long">
<li><a href="#subscribe(java.util.regex.Pattern,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribe(Pattern, ConsumerRebalanceListener)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="subscribe(java.util.regex.Pattern)">
<h3>subscribe</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">subscribe</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html" title="class or interface in java.util.regex" class="external-link">Pattern</a>&nbsp;pattern)</span></div>
<div class="block">Subscribe to all topics matching specified pattern to get dynamically assigned partitions.
The pattern matching will be done periodically against topics existing at the time of check.
<p>
This is a short-hand for <a href="#subscribe(java.util.regex.Pattern,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribe(Pattern, ConsumerRebalanceListener)</code></a>, which
uses a no-op listener. If you need the ability to seek to particular offsets, you should prefer
<a href="#subscribe(java.util.regex.Pattern,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribe(Pattern, ConsumerRebalanceListener)</code></a>, since group rebalances will cause partition offsets
to be reset. You should also provide your own listener if you are doing your own offset
management since the listener gives you an opportunity to commit offsets before a rebalance finishes.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#subscribe(java.util.regex.Pattern)">subscribe</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>pattern</code> - Pattern to subscribe to</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - If pattern is null</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - If <code>subscribe()</code> is called previously with topics, or assign is called
previously (without a subsequent call to <a href="#unsubscribe()"><code>unsubscribe()</code></a>), or if not
configured at-least one partition assignment strategy</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#subscribe(java.util.regex.Pattern)"><code>subscribe(Pattern)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="unsubscribe()">
<h3>unsubscribe</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">unsubscribe</span>()</div>
<div class="block">Unsubscribe from topics currently subscribed with <a href="#subscribe(java.util.Collection)"><code>subscribe(Collection)</code></a> or <a href="#subscribe(java.util.regex.Pattern)"><code>subscribe(Pattern)</code></a>.
This also clears any partitions directly assigned through <a href="#assign(java.util.Collection)"><code>assign(Collection)</code></a>.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#unsubscribe()">unsubscribe</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors (e.g. rebalance callback errors)</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#unsubscribe()"><code>unsubscribe()</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="assign(java.util.Collection)">
<h3>assign</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">assign</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</span></div>
<div class="block">Manually assign a list of partitions to this consumer. This interface does not allow for incremental assignment
and will replace the previous assignment (if there is one).
<p>
If the given list of topic partitions is empty, it is treated the same as <a href="#unsubscribe()"><code>unsubscribe()</code></a>.
<p>
Manual topic assignment through this method does not use the consumer's group management
functionality. As such, there will be no rebalance operation triggered when group membership or cluster and topic
metadata change. Note that it is not possible to use both manual partition assignment with <a href="#assign(java.util.Collection)"><code>assign(Collection)</code></a>
and group assignment with <a href="#subscribe(java.util.Collection,org.apache.kafka.clients.consumer.ConsumerRebalanceListener)"><code>subscribe(Collection, ConsumerRebalanceListener)</code></a>.
<p>
If auto-commit is enabled, an async commit (based on the old assignment) will be triggered before the new
assignment replaces the old one.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#assign(java.util.Collection)">assign</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partitions</code> - The list of partitions to assign this consumer</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - If partitions is null or contains null or empty topics</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - If <code>subscribe()</code> is called previously with topics or pattern
(without a subsequent call to <a href="#unsubscribe()"><code>unsubscribe()</code></a>)</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#assign(java.util.Collection)"><code>assign(Collection)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="poll(long)">
<h3>poll</h3>
<div class="member-signature"><span class="annotations"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Deprecated.html" title="class or interface in java.lang" class="external-link">@Deprecated</a>
</span><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="ConsumerRecords.html" title="class in org.apache.kafka.clients.consumer">ConsumerRecords</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</span>&nbsp;<span class="element-name">poll</span><wbr><span class="parameters">(long&nbsp;timeoutMs)</span></div>
<div class="deprecation-block"><span class="deprecated-label">Deprecated.</span>
<div class="deprecation-comment">Since 2.0. Use <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a>, which does not block beyond the timeout awaiting partition
assignment. See <a href="https://cwiki.apache.org/confluence/x/5kiHB">KIP-266</a> for more information.</div>
</div>
<div class="block">Fetch data for the topics or partitions specified using one of the subscribe/assign APIs. It is an error to not have
subscribed to any topics or partitions before polling for data.
<p>
On each poll, consumer will try to use the last consumed offset as the starting offset and fetch sequentially. The last
consumed offset can be manually set through <a href="#seek(org.apache.kafka.common.TopicPartition,long)"><code>seek(TopicPartition, long)</code></a> or automatically set as the last committed
offset for the subscribed list of partitions</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#poll(long)">poll</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>timeoutMs</code> - The time, in milliseconds, spent waiting in poll if data is not available in the buffer.
If 0, returns immediately with any records that are available currently in the buffer, else returns empty.
Must not be negative.</dd>
<dt>Returns:</dt>
<dd>map of topic to records since the last fetch for the subscribed list of topics and partitions</dd>
<dt>Throws:</dt>
<dd><code><a href="InvalidOffsetException.html" title="class in org.apache.kafka.clients.consumer">InvalidOffsetException</a></code> - if the offset for a partition or set of
partitions is undefined or out of range and no offset reset policy has been configured</dd>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if caller lacks Read access to any of the subscribed
topics or to the configured groupId. See the exception for more details</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors (e.g. invalid groupId or
session timeout, errors deserializing key/value pairs, or any new error cases in future versions)</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - if the timeout value is negative</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - if the consumer is not subscribed to any topics or manually assigned any
partitions to consume from</dd>
<dd><code><a href="../../common/errors/FencedInstanceIdException.html" title="class in org.apache.kafka.common.errors">FencedInstanceIdException</a></code> - if this consumer instance gets fenced by broker.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#poll(long)"><code>poll(long)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="poll(java.time.Duration)">
<h3>poll</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="ConsumerRecords.html" title="class in org.apache.kafka.clients.consumer">ConsumerRecords</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</span>&nbsp;<span class="element-name">poll</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</span></div>
<div class="block">Fetch data for the topics or partitions specified using one of the subscribe/assign APIs. It is an error to not have
subscribed to any topics or partitions before polling for data.
<p>
On each poll, consumer will try to use the last consumed offset as the starting offset and fetch sequentially. The last
consumed offset can be manually set through <a href="#seek(org.apache.kafka.common.TopicPartition,long)"><code>seek(TopicPartition, long)</code></a> or automatically set as the last committed
offset for the subscribed list of partitions
<p>
This method returns immediately if there are records available or if the position advances past control records
or aborted transactions when isolation.level=read_committed.
Otherwise, it will await the passed timeout. If the timeout expires, an empty record set will be returned.
Note that this method may block beyond the timeout in order to execute custom
<a href="ConsumerRebalanceListener.html" title="interface in org.apache.kafka.clients.consumer"><code>ConsumerRebalanceListener</code></a> callbacks.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#poll(java.time.Duration)">poll</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>timeout</code> - The maximum time to block (must not be greater than <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html#MAX_VALUE" title="class or interface in java.lang" class="external-link"><code>Long.MAX_VALUE</code></a> milliseconds)</dd>
<dt>Returns:</dt>
<dd>map of topic to records since the last fetch for the subscribed list of topics and partitions</dd>
<dt>Throws:</dt>
<dd><code><a href="InvalidOffsetException.html" title="class in org.apache.kafka.clients.consumer">InvalidOffsetException</a></code> - if the offset for a partition or set of
partitions is undefined or out of range and no offset reset policy has been configured</dd>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if caller lacks Read access to any of the subscribed
topics or to the configured groupId. See the exception for more details</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors (e.g. invalid groupId or
session timeout, errors deserializing key/value pairs, your rebalance callback thrown exceptions,
or any new error cases in future versions)</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - if the timeout value is negative</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - if the consumer is not subscribed to any topics or manually assigned any
partitions to consume from</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/ArithmeticException.html" title="class or interface in java.lang" class="external-link">ArithmeticException</a></code> - if the timeout is greater than <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html#MAX_VALUE" title="class or interface in java.lang" class="external-link"><code>Long.MAX_VALUE</code></a> milliseconds.</dd>
<dd><code><a href="../../common/errors/InvalidTopicException.html" title="class in org.apache.kafka.common.errors">InvalidTopicException</a></code> - if the current subscription contains any invalid
topic (per <code>Topic.validate(String)</code>)</dd>
<dd><code><a href="../../common/errors/UnsupportedVersionException.html" title="class in org.apache.kafka.common.errors">UnsupportedVersionException</a></code> - if the consumer attempts to fetch stable offsets
when the broker doesn't support this feature</dd>
<dd><code><a href="../../common/errors/FencedInstanceIdException.html" title="class in org.apache.kafka.common.errors">FencedInstanceIdException</a></code> - if this consumer instance gets fenced by broker.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="commitSync()">
<h3>commitSync</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">commitSync</span>()</div>
<div class="block">Commit offsets returned on the last <a href="#poll(java.time.Duration)"><code>poll()</code></a> for all the subscribed list of topics and
partitions.
<p>
This commits offsets only to Kafka. The offsets committed using this API will be used on the first fetch after
every rebalance and also on startup. As such, if you need to store offsets in anything other than Kafka, this API
should not be used.
<p>
This is a synchronous commit and will block until either the commit succeeds, an unrecoverable error is
encountered (in which case it is thrown to the caller), or the timeout specified by <code>default.api.timeout.ms</code> expires
(in which case a <a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors"><code>TimeoutException</code></a> is thrown to the caller).
<p>
Note that asynchronous offset commits sent previously with the <a href="#commitAsync(org.apache.kafka.clients.consumer.OffsetCommitCallback)"><code>commitAsync(OffsetCommitCallback)</code></a>
(or similar) are guaranteed to have their callbacks invoked prior to completion of this method.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#commitSync()">commitSync</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Throws:</dt>
<dd><code><a href="CommitFailedException.html" title="class in org.apache.kafka.clients.consumer">CommitFailedException</a></code> - if the commit failed and cannot be retried.
This fatal error can only occur if you are using automatic group management with <a href="#subscribe(java.util.Collection)"><code>subscribe(Collection)</code></a>,
or if there is an active group with the same <code>group.id</code> which is using group management. In such cases,
when you are trying to commit to partitions that are no longer assigned to this consumer because the
consumer is for example no longer part of the group this exception would be thrown.</dd>
<dd><code><a href="../../common/errors/RebalanceInProgressException.html" title="class in org.apache.kafka.common.errors">RebalanceInProgressException</a></code> - if the consumer instance is in the middle of a rebalance
so it is not yet determined which partitions would be assigned to the consumer. In such cases you can first
complete the rebalance by calling <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> and commit can be reconsidered afterwards.
NOTE when you reconsider committing after the rebalance, the assigned partitions may have changed,
and also for those partitions that are still assigned their fetch positions may have changed too
if more records are returned from the <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> call.</dd>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic or to the
configured groupId. See the exception for more details</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors (e.g. if offset metadata
is too large or if the topic does not exist).</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the timeout specified by <code>default.api.timeout.ms</code> expires
before successful completion of the offset commit</dd>
<dd><code><a href="../../common/errors/FencedInstanceIdException.html" title="class in org.apache.kafka.common.errors">FencedInstanceIdException</a></code> - if this consumer instance gets fenced by broker.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#commitSync()"><code>commitSync()</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="commitSync(java.time.Duration)">
<h3>commitSync</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">commitSync</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</span></div>
<div class="block">Commit offsets returned on the last <a href="#poll(java.time.Duration)"><code>poll()</code></a> for all the subscribed list of topics and
partitions.
<p>
This commits offsets only to Kafka. The offsets committed using this API will be used on the first fetch after
every rebalance and also on startup. As such, if you need to store offsets in anything other than Kafka, this API
should not be used.
<p>
This is a synchronous commit and will block until either the commit succeeds, an unrecoverable error is
encountered (in which case it is thrown to the caller), or the passed timeout expires.
<p>
Note that asynchronous offset commits sent previously with the <a href="#commitAsync(org.apache.kafka.clients.consumer.OffsetCommitCallback)"><code>commitAsync(OffsetCommitCallback)</code></a>
(or similar) are guaranteed to have their callbacks invoked prior to completion of this method.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#commitSync(java.time.Duration)">commitSync</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Throws:</dt>
<dd><code><a href="CommitFailedException.html" title="class in org.apache.kafka.clients.consumer">CommitFailedException</a></code> - if the commit failed and cannot be retried.
This can only occur if you are using automatic group management with <a href="#subscribe(java.util.Collection)"><code>subscribe(Collection)</code></a>,
or if there is an active group with the same <code>group.id</code> which is using group management. In such cases,
when you are trying to commit to partitions that are no longer assigned to this consumer because the
consumer is for example no longer part of the group this exception would be thrown.</dd>
<dd><code><a href="../../common/errors/RebalanceInProgressException.html" title="class in org.apache.kafka.common.errors">RebalanceInProgressException</a></code> - if the consumer instance is in the middle of a rebalance
so it is not yet determined which partitions would be assigned to the consumer. In such cases you can first
complete the rebalance by calling <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> and commit can be reconsidered afterwards.
NOTE when you reconsider committing after the rebalance, the assigned partitions may have changed,
and also for those partitions that are still assigned their fetch positions may have changed too
if more records are returned from the <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> call.</dd>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic or to the
configured groupId. See the exception for more details</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors (e.g. if offset metadata
is too large or if the topic does not exist).</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the timeout expires before successful completion
of the offset commit</dd>
<dd><code><a href="../../common/errors/FencedInstanceIdException.html" title="class in org.apache.kafka.common.errors">FencedInstanceIdException</a></code> - if this consumer instance gets fenced by broker.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#commitSync(java.time.Duration)"><code>commitSync(Duration)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="commitSync(java.util.Map)">
<h3>commitSync</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">commitSync</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a>&gt;&nbsp;offsets)</span></div>
<div class="block">Commit the specified offsets for the specified list of topics and partitions.
<p>
This commits offsets to Kafka. The offsets committed using this API will be used on the first fetch after every
rebalance and also on startup. As such, if you need to store offsets in anything other than Kafka, this API
should not be used. The committed offset should be the next message your application will consume,
i.e. lastProcessedMessageOffset + 1. If automatic group management with <a href="#subscribe(java.util.Collection)"><code>subscribe(Collection)</code></a> is used,
then the committed offsets must belong to the currently auto-assigned partitions.
<p>
This is a synchronous commit and will block until either the commit succeeds or an unrecoverable error is
encountered (in which case it is thrown to the caller), or the timeout specified by <code>default.api.timeout.ms</code> expires
(in which case a <a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors"><code>TimeoutException</code></a> is thrown to the caller).
<p>
Note that asynchronous offset commits sent previously with the <a href="#commitAsync(org.apache.kafka.clients.consumer.OffsetCommitCallback)"><code>commitAsync(OffsetCommitCallback)</code></a>
(or similar) are guaranteed to have their callbacks invoked prior to completion of this method.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#commitSync(java.util.Map)">commitSync</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>offsets</code> - A map of offsets by partition with associated metadata</dd>
<dt>Throws:</dt>
<dd><code><a href="CommitFailedException.html" title="class in org.apache.kafka.clients.consumer">CommitFailedException</a></code> - if the commit failed and cannot be retried.
This can only occur if you are using automatic group management with <a href="#subscribe(java.util.Collection)"><code>subscribe(Collection)</code></a>,
or if there is an active group with the same <code>group.id</code> which is using group management. In such cases,
when you are trying to commit to partitions that are no longer assigned to this consumer because the
consumer is for example no longer part of the group this exception would be thrown.</dd>
<dd><code><a href="../../common/errors/RebalanceInProgressException.html" title="class in org.apache.kafka.common.errors">RebalanceInProgressException</a></code> - if the consumer instance is in the middle of a rebalance
so it is not yet determined which partitions would be assigned to the consumer. In such cases you can first
complete the rebalance by calling <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> and commit can be reconsidered afterwards.
NOTE when you reconsider committing after the rebalance, the assigned partitions may have changed,
and also for those partitions that are still assigned their fetch positions may have changed too
if more records are returned from the <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> call, so when you retry committing
you should consider updating the passed in <code>offset</code> parameter.</dd>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic or to the
configured groupId. See the exception for more details</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - if the committed offset is negative</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors (e.g. if offset metadata
is too large or if the topic does not exist).</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the timeout expires before successful completion
of the offset commit</dd>
<dd><code><a href="../../common/errors/FencedInstanceIdException.html" title="class in org.apache.kafka.common.errors">FencedInstanceIdException</a></code> - if this consumer instance gets fenced by broker.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#commitSync(java.util.Map)"><code>commitSync(Map)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="commitSync(java.util.Map,java.time.Duration)">
<h3>commitSync</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">commitSync</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a>&gt;&nbsp;offsets,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</span></div>
<div class="block">Commit the specified offsets for the specified list of topics and partitions.
<p>
This commits offsets to Kafka. The offsets committed using this API will be used on the first fetch after every
rebalance and also on startup. As such, if you need to store offsets in anything other than Kafka, this API
should not be used. The committed offset should be the next message your application will consume,
i.e. lastProcessedMessageOffset + 1. If automatic group management with <a href="#subscribe(java.util.Collection)"><code>subscribe(Collection)</code></a> is used,
then the committed offsets must belong to the currently auto-assigned partitions.
<p>
This is a synchronous commit and will block until either the commit succeeds, an unrecoverable error is
encountered (in which case it is thrown to the caller), or the timeout expires.
<p>
Note that asynchronous offset commits sent previously with the <a href="#commitAsync(org.apache.kafka.clients.consumer.OffsetCommitCallback)"><code>commitAsync(OffsetCommitCallback)</code></a>
(or similar) are guaranteed to have their callbacks invoked prior to completion of this method.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#commitSync(java.util.Map,java.time.Duration)">commitSync</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>offsets</code> - A map of offsets by partition with associated metadata</dd>
<dd><code>timeout</code> - The maximum amount of time to await completion of the offset commit</dd>
<dt>Throws:</dt>
<dd><code><a href="CommitFailedException.html" title="class in org.apache.kafka.clients.consumer">CommitFailedException</a></code> - if the commit failed and cannot be retried.
This can only occur if you are using automatic group management with <a href="#subscribe(java.util.Collection)"><code>subscribe(Collection)</code></a>,
or if there is an active group with the same <code>group.id</code> which is using group management. In such cases,
when you are trying to commit to partitions that are no longer assigned to this consumer because the
consumer is for example no longer part of the group this exception would be thrown.</dd>
<dd><code><a href="../../common/errors/RebalanceInProgressException.html" title="class in org.apache.kafka.common.errors">RebalanceInProgressException</a></code> - if the consumer instance is in the middle of a rebalance
so it is not yet determined which partitions would be assigned to the consumer. In such cases you can first
complete the rebalance by calling <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> and commit can be reconsidered afterwards.
NOTE when you reconsider committing after the rebalance, the assigned partitions may have changed,
and also for those partitions that are still assigned their fetch positions may have changed too
if more records are returned from the <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> call, so when you retry committing
you should consider updating the passed in <code>offset</code> parameter.</dd>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic or to the
configured groupId. See the exception for more details</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - if the committed offset is negative</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors (e.g. if offset metadata
is too large or if the topic does not exist).</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the timeout expires before successful completion
of the offset commit</dd>
<dd><code><a href="../../common/errors/FencedInstanceIdException.html" title="class in org.apache.kafka.common.errors">FencedInstanceIdException</a></code> - if this consumer instance gets fenced by broker.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list-long">
<li><a href="#commitSync(java.util.Map,java.time.Duration)"><code>commitSync(Map, Duration)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="commitAsync()">
<h3>commitAsync</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">commitAsync</span>()</div>
<div class="block">Commit offsets returned on the last <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> for all the subscribed list of topics and partition.
Same as <a href="#commitAsync(org.apache.kafka.clients.consumer.OffsetCommitCallback)"><code>commitAsync(null)</code></a></div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#commitAsync()">commitAsync</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/FencedInstanceIdException.html" title="class in org.apache.kafka.common.errors">FencedInstanceIdException</a></code> - if this consumer instance gets fenced by broker.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#commitAsync()"><code>commitAsync()</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="commitAsync(org.apache.kafka.clients.consumer.OffsetCommitCallback)">
<h3>commitAsync</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">commitAsync</span><wbr><span class="parameters">(<a href="OffsetCommitCallback.html" title="interface in org.apache.kafka.clients.consumer">OffsetCommitCallback</a>&nbsp;callback)</span></div>
<div class="block">Commit offsets returned on the last <a href="#poll(java.time.Duration)"><code>poll()</code></a> for the subscribed list of topics and partitions.
<p>
This commits offsets only to Kafka. The offsets committed using this API will be used on the first fetch after
every rebalance and also on startup. As such, if you need to store offsets in anything other than Kafka, this API
should not be used.
<p>
This is an asynchronous call and will not block. Any errors encountered are either passed to the callback
(if provided) or discarded.
<p>
Offsets committed through multiple calls to this API are guaranteed to be sent in the same order as
the invocations. Corresponding commit callbacks are also invoked in the same order. Additionally note that
offsets committed through this API are guaranteed to complete before a subsequent call to <a href="#commitSync()"><code>commitSync()</code></a>
(and variants) returns.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#commitAsync(org.apache.kafka.clients.consumer.OffsetCommitCallback)">commitAsync</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>callback</code> - Callback to invoke when the commit completes</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/FencedInstanceIdException.html" title="class in org.apache.kafka.common.errors">FencedInstanceIdException</a></code> - if this consumer instance gets fenced by broker.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list-long">
<li><a href="#commitAsync(org.apache.kafka.clients.consumer.OffsetCommitCallback)"><code>commitAsync(OffsetCommitCallback)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="commitAsync(java.util.Map,org.apache.kafka.clients.consumer.OffsetCommitCallback)">
<h3>commitAsync</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">commitAsync</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a>&gt;&nbsp;offsets,
<a href="OffsetCommitCallback.html" title="interface in org.apache.kafka.clients.consumer">OffsetCommitCallback</a>&nbsp;callback)</span></div>
<div class="block">Commit the specified offsets for the specified list of topics and partitions to Kafka.
<p>
This commits offsets to Kafka. The offsets committed using this API will be used on the first fetch after every
rebalance and also on startup. As such, if you need to store offsets in anything other than Kafka, this API
should not be used. The committed offset should be the next message your application will consume,
i.e. lastProcessedMessageOffset + 1. If automatic group management with <a href="#subscribe(java.util.Collection)"><code>subscribe(Collection)</code></a> is used,
then the committed offsets must belong to the currently auto-assigned partitions.
<p>
This is an asynchronous call and will not block. Any errors encountered are either passed to the callback
(if provided) or discarded.
<p>
Offsets committed through multiple calls to this API are guaranteed to be sent in the same order as
the invocations. Corresponding commit callbacks are also invoked in the same order. Additionally note that
offsets committed through this API are guaranteed to complete before a subsequent call to <a href="#commitSync()"><code>commitSync()</code></a>
(and variants) returns.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#commitAsync(java.util.Map,org.apache.kafka.clients.consumer.OffsetCommitCallback)">commitAsync</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>offsets</code> - A map of offsets by partition with associate metadata. This map will be copied internally, so it
is safe to mutate the map after returning.</dd>
<dd><code>callback</code> - Callback to invoke when the commit completes</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/FencedInstanceIdException.html" title="class in org.apache.kafka.common.errors">FencedInstanceIdException</a></code> - if this consumer instance gets fenced by broker.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list-long">
<li><a href="#commitAsync(java.util.Map,org.apache.kafka.clients.consumer.OffsetCommitCallback)"><code>commitAsync(Map, OffsetCommitCallback)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="seek(org.apache.kafka.common.TopicPartition,long)">
<h3>seek</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">seek</span><wbr><span class="parameters">(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;partition,
long&nbsp;offset)</span></div>
<div class="block">Overrides the fetch offsets that the consumer will use on the next <a href="#poll(java.time.Duration)"><code>poll(timeout)</code></a>. If this API
is invoked for the same partition more than once, the latest offset will be used on the next poll(). Note that
you may lose data if this API is arbitrarily used in the middle of consumption, to reset the fetch offsets
<p>
The next Consumer Record which will be retrieved when poll() is invoked will have the offset specified, given that
a record with that offset exists (i.e. it is a valid offset).
<p>
<a href="#seekToBeginning(java.util.Collection)"><code>seekToBeginning(Collection)</code></a> will go to the first offset in the topic.
seek(0) is equivalent to seekToBeginning for a TopicPartition with beginning offset 0,
assuming that there is a record at offset 0 still available.
<a href="#seekToEnd(java.util.Collection)"><code>seekToEnd(Collection)</code></a> is equivalent to seeking to the last offset of the partition, but behavior depends on
<code>isolation.level</code>, so see <a href="#seekToEnd(java.util.Collection)"><code>seekToEnd(Collection)</code></a> documentation for more details.
<p>
Seeking to the offset smaller than the log start offset or larger than the log end offset
means an invalid offset is reached.
Invalid offset behaviour is controlled by the <code>auto.offset.reset</code> property.
If this is set to "earliest", the next poll will return records from the starting offset.
If it is set to "latest", it will seek to the last offset (similar to seekToEnd()).
If it is set to "none", an <code>OffsetOutOfRangeException</code> will be thrown.
<p>
Note that, the seek offset won't change to the in-flight fetch request, it will take effect in next fetch request.
So, the consumer might wait for <code>fetch.max.wait.ms</code> before starting to fetch the records from desired offset.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#seek(org.apache.kafka.common.TopicPartition,long)">seek</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partition</code> - the TopicPartition on which the seek will be performed.</dd>
<dd><code>offset</code> - the next offset returned by poll().</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - if the provided offset is negative</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - if the provided TopicPartition is not assigned to this consumer</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list-long">
<li><a href="#seek(org.apache.kafka.common.TopicPartition,long)"><code>seek(TopicPartition, long)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="seek(org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata)">
<h3>seek</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">seek</span><wbr><span class="parameters">(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;partition,
<a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a>&nbsp;offsetAndMetadata)</span></div>
<div class="block">Overrides the fetch offsets that the consumer will use on the next <a href="#poll(java.time.Duration)"><code>poll(timeout)</code></a>. If this API
is invoked for the same partition more than once, the latest offset will be used on the next poll(). Note that
you may lose data if this API is arbitrarily used in the middle of consumption, to reset the fetch offsets. This
method allows for setting the leaderEpoch along with the desired offset.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#seek(org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata)">seek</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - if the provided offset is negative</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - if the provided TopicPartition is not assigned to this consumer</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list-long">
<li><a href="#seek(org.apache.kafka.common.TopicPartition,org.apache.kafka.clients.consumer.OffsetAndMetadata)"><code>seek(TopicPartition, OffsetAndMetadata)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="seekToBeginning(java.util.Collection)">
<h3>seekToBeginning</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">seekToBeginning</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</span></div>
<div class="block">Seek to the first offset for each of the given partitions. This function evaluates lazily, seeking to the
first offset in all partitions only when <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> or <a href="#position(org.apache.kafka.common.TopicPartition)"><code>position(TopicPartition)</code></a> are called.
If no partitions are provided, seek to the first offset for all of the currently assigned partitions.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#seekToBeginning(java.util.Collection)">seekToBeginning</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - if <code>partitions</code> is <code>null</code></dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - if any of the provided partitions are not currently assigned to this consumer</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#seekToBeginning(java.util.Collection)"><code>seekToBeginning(Collection)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="seekToEnd(java.util.Collection)">
<h3>seekToEnd</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">seekToEnd</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</span></div>
<div class="block">Seek to the last offset for each of the given partitions. This function evaluates lazily, seeking to the
final offset in all partitions only when <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> or <a href="#position(org.apache.kafka.common.TopicPartition)"><code>position(TopicPartition)</code></a> are called.
If no partitions are provided, seek to the final offset for all of the currently assigned partitions.
<p>
If <code>isolation.level=read_committed</code>, the end offset will be the Last Stable Offset, i.e., the offset
of the first message with an open transaction.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#seekToEnd(java.util.Collection)">seekToEnd</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - if <code>partitions</code> is <code>null</code></dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - if any of the provided partitions are not currently assigned to this consumer</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#seekToEnd(java.util.Collection)"><code>seekToEnd(Collection)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="position(org.apache.kafka.common.TopicPartition)">
<h3>position</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">long</span>&nbsp;<span class="element-name">position</span><wbr><span class="parameters">(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;partition)</span></div>
<div class="block">Get the offset of the <i>next record</i> that will be fetched (if a record with that offset exists).
This method may issue a remote call to the server if there is no current position for the given partition.
<p>
This call will block until either the position could be determined or an unrecoverable error is
encountered (in which case it is thrown to the caller), or the timeout specified by <code>default.api.timeout.ms</code> expires
(in which case a <a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors"><code>TimeoutException</code></a> is thrown to the caller).</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#position(org.apache.kafka.common.TopicPartition)">position</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partition</code> - The partition to get the position for</dd>
<dt>Returns:</dt>
<dd>The current position of the consumer (that is, the offset of the next record to be fetched)</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - if the provided TopicPartition is not assigned to this consumer</dd>
<dd><code><a href="InvalidOffsetException.html" title="class in org.apache.kafka.clients.consumer">InvalidOffsetException</a></code> - if no offset is currently defined for
the partition</dd>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic or to the
configured groupId. See the exception for more details</dd>
<dd><code><a href="../../common/errors/UnsupportedVersionException.html" title="class in org.apache.kafka.common.errors">UnsupportedVersionException</a></code> - if the consumer attempts to fetch stable offsets
when the broker doesn't support this feature</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the position cannot be determined before the
timeout specified by <code>default.api.timeout.ms</code> expires</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#position(org.apache.kafka.common.TopicPartition)"><code>position(TopicPartition)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="position(org.apache.kafka.common.TopicPartition,java.time.Duration)">
<h3>position</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">long</span>&nbsp;<span class="element-name">position</span><wbr><span class="parameters">(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;partition,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</span></div>
<div class="block">Get the offset of the <i>next record</i> that will be fetched (if a record with that offset exists).
This method may issue a remote call to the server if there is no current position
for the given partition.
<p>
This call will block until the position can be determined, an unrecoverable error is
encountered (in which case it is thrown to the caller), or the timeout expires.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#position(org.apache.kafka.common.TopicPartition,java.time.Duration)">position</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partition</code> - The partition to get the position for</dd>
<dd><code>timeout</code> - The maximum amount of time to await determination of the current position</dd>
<dt>Returns:</dt>
<dd>The current position of the consumer (that is, the offset of the next record to be fetched)</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - if the provided TopicPartition is not assigned to this consumer</dd>
<dd><code><a href="InvalidOffsetException.html" title="class in org.apache.kafka.clients.consumer">InvalidOffsetException</a></code> - if no offset is currently defined for
the partition</dd>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the position cannot be determined before the
passed timeout expires</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic or to the
configured groupId. See the exception for more details</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list-long">
<li><a href="#position(org.apache.kafka.common.TopicPartition,java.time.Duration)"><code>position(TopicPartition, Duration)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="committed(org.apache.kafka.common.TopicPartition)">
<h3>committed</h3>
<div class="member-signature"><span class="annotations"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Deprecated.html" title="class or interface in java.lang" class="external-link">@Deprecated</a>
</span><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a></span>&nbsp;<span class="element-name">committed</span><wbr><span class="parameters">(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;partition)</span></div>
<div class="deprecation-block"><span class="deprecated-label">Deprecated.</span>
<div class="deprecation-comment">since 2.4 Use <a href="#committed(java.util.Set)"><code>committed(Set)</code></a> instead</div>
</div>
<div class="block">Get the last committed offset for the given partition (whether the commit happened by this process or
another). This offset will be used as the position for the consumer in the event of a failure.
<p>
This call will do a remote call to get the latest committed offset from the server, and will block until the
committed offset is gotten successfully, an unrecoverable error is encountered (in which case it is thrown to
the caller), or the timeout specified by <code>default.api.timeout.ms</code> expires (in which case a
<a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors"><code>TimeoutException</code></a> is thrown to the caller).</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#committed(org.apache.kafka.common.TopicPartition)">committed</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partition</code> - The partition to check</dd>
<dt>Returns:</dt>
<dd>The last committed offset and metadata or null if there was no prior commit</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic or to the
configured groupId. See the exception for more details</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the committed offset cannot be found before
the timeout specified by <code>default.api.timeout.ms</code> expires.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#committed(org.apache.kafka.common.TopicPartition)"><code>committed(TopicPartition)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="committed(org.apache.kafka.common.TopicPartition,java.time.Duration)">
<h3>committed</h3>
<div class="member-signature"><span class="annotations"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Deprecated.html" title="class or interface in java.lang" class="external-link">@Deprecated</a>
</span><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a></span>&nbsp;<span class="element-name">committed</span><wbr><span class="parameters">(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;partition,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</span></div>
<div class="deprecation-block"><span class="deprecated-label">Deprecated.</span>
<div class="deprecation-comment">since 2.4 Use <a href="#committed(java.util.Set,java.time.Duration)"><code>committed(Set, Duration)</code></a> instead</div>
</div>
<div class="block">Get the last committed offset for the given partition (whether the commit happened by this process or
another). This offset will be used as the position for the consumer in the event of a failure.
<p>
This call will block until the position can be determined, an unrecoverable error is
encountered (in which case it is thrown to the caller), or the timeout expires.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#committed(org.apache.kafka.common.TopicPartition,java.time.Duration)">committed</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partition</code> - The partition to check</dd>
<dd><code>timeout</code> - The maximum amount of time to await the current committed offset</dd>
<dt>Returns:</dt>
<dd>The last committed offset and metadata or null if there was no prior commit</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic or to the
configured groupId. See the exception for more details</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the committed offset cannot be found before
expiration of the timeout</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list-long">
<li><a href="#committed(org.apache.kafka.common.TopicPartition,java.time.Duration)"><code>committed(TopicPartition, Duration)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="committed(java.util.Set)">
<h3>committed</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a>&gt;</span>&nbsp;<span class="element-name">committed</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</span></div>
<div class="block">Get the last committed offsets for the given partitions (whether the commit happened by this process or
another). The returned offsets will be used as the position for the consumer in the event of a failure.
<p>
If any of the partitions requested do not exist, an exception would be thrown.
<p>
This call will do a remote call to get the latest committed offsets from the server, and will block until the
committed offsets are gotten successfully, an unrecoverable error is encountered (in which case it is thrown to
the caller), or the timeout specified by <code>default.api.timeout.ms</code> expires (in which case a
<a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors"><code>TimeoutException</code></a> is thrown to the caller).</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#committed(java.util.Set)">committed</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partitions</code> - The partitions to check</dd>
<dt>Returns:</dt>
<dd>The latest committed offsets for the given partitions; <code>null</code> will be returned for the
partition if there is no such message.</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic or to the
configured groupId. See the exception for more details</dd>
<dd><code><a href="../../common/errors/UnsupportedVersionException.html" title="class in org.apache.kafka.common.errors">UnsupportedVersionException</a></code> - if the consumer attempts to fetch stable offsets
when the broker doesn't support this feature</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the committed offset cannot be found before
the timeout specified by <code>default.api.timeout.ms</code> expires.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#committed(java.util.Set)"><code>committed(Set)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="committed(java.util.Set,java.time.Duration)">
<h3>committed</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndMetadata.html" title="class in org.apache.kafka.clients.consumer">OffsetAndMetadata</a>&gt;</span>&nbsp;<span class="element-name">committed</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</span></div>
<div class="block">Get the last committed offsets for the given partitions (whether the commit happened by this process or
another). The returned offsets will be used as the position for the consumer in the event of a failure.
<p>
If any of the partitions requested do not exist, an exception would be thrown.
<p>
This call will block to do a remote call to get the latest committed offsets from the server.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#committed(java.util.Set,java.time.Duration)">committed</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partitions</code> - The partitions to check</dd>
<dd><code>timeout</code> - The maximum amount of time to await the latest committed offsets</dd>
<dt>Returns:</dt>
<dd>The latest committed offsets for the given partitions; <code>null</code> will be returned for the
partition if there is no such message.</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic or to the
configured groupId. See the exception for more details</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the committed offset cannot be found before
expiration of the timeout</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list-long">
<li><a href="#committed(java.util.Set,java.time.Duration)"><code>committed(Set, Duration)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="metrics()">
<h3>metrics</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/MetricName.html" title="class in org.apache.kafka.common">MetricName</a>,<wbr>? extends <a href="../../common/Metric.html" title="interface in org.apache.kafka.common">Metric</a>&gt;</span>&nbsp;<span class="element-name">metrics</span>()</div>
<div class="block">Get the metrics kept by the consumer</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#metrics()">metrics</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#metrics()"><code>metrics()</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="partitionsFor(java.lang.String)">
<h3>partitionsFor</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../common/PartitionInfo.html" title="class in org.apache.kafka.common">PartitionInfo</a>&gt;</span>&nbsp;<span class="element-name">partitionsFor</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&nbsp;topic)</span></div>
<div class="block">Get metadata about the partitions for a given topic. This method will issue a remote call to the server if it
does not already have any metadata about the given topic.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#partitionsFor(java.lang.String)">partitionsFor</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>topic</code> - The topic to get partition metadata for</dd>
<dt>Returns:</dt>
<dd>The list of partitions, which will be empty when the given topic is not found</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the specified topic. See the exception for more details</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the offset metadata could not be fetched before
the amount of time allocated by <code>default.api.timeout.ms</code> expires.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#partitionsFor(java.lang.String)"><code>partitionsFor(String)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="partitionsFor(java.lang.String,java.time.Duration)">
<h3>partitionsFor</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../common/PartitionInfo.html" title="class in org.apache.kafka.common">PartitionInfo</a>&gt;</span>&nbsp;<span class="element-name">partitionsFor</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&nbsp;topic,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</span></div>
<div class="block">Get metadata about the partitions for a given topic. This method will issue a remote call to the server if it
does not already have any metadata about the given topic.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#partitionsFor(java.lang.String,java.time.Duration)">partitionsFor</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>topic</code> - The topic to get partition metadata for</dd>
<dd><code>timeout</code> - The maximum of time to await topic metadata</dd>
<dt>Returns:</dt>
<dd>The list of partitions, which will be empty when the given topic is not found</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the specified topic. See
the exception for more details</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if topic metadata cannot be fetched before expiration
of the passed timeout</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list-long">
<li><a href="#partitionsFor(java.lang.String,java.time.Duration)"><code>partitionsFor(String, Duration)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="listTopics()">
<h3>listTopics</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../common/PartitionInfo.html" title="class in org.apache.kafka.common">PartitionInfo</a>&gt;&gt;</span>&nbsp;<span class="element-name">listTopics</span>()</div>
<div class="block">Get metadata about partitions for all topics that the user is authorized to view. This method will issue a
remote call to the server.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#listTopics()">listTopics</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Returns:</dt>
<dd>The map of topics and its partitions</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the offset metadata could not be fetched before
the amount of time allocated by <code>default.api.timeout.ms</code> expires.</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#listTopics()"><code>listTopics()</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="listTopics(java.time.Duration)">
<h3>listTopics</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/List.html" title="class or interface in java.util" class="external-link">List</a>&lt;<a href="../../common/PartitionInfo.html" title="class in org.apache.kafka.common">PartitionInfo</a>&gt;&gt;</span>&nbsp;<span class="element-name">listTopics</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</span></div>
<div class="block">Get metadata about partitions for all topics that the user is authorized to view. This method will issue a
remote call to the server.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#listTopics(java.time.Duration)">listTopics</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>timeout</code> - The maximum time this operation will block to fetch topic metadata</dd>
<dt>Returns:</dt>
<dd>The map of topics and its partitions</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors">WakeupException</a></code> - if <a href="#wakeup()"><code>wakeup()</code></a> is called before or while this
function is called</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted before or while
this function is called</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the topic metadata could not be fetched before
expiration of the passed timeout</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other unrecoverable errors</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#listTopics(java.time.Duration)"><code>listTopics(Duration)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="pause(java.util.Collection)">
<h3>pause</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">pause</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</span></div>
<div class="block">Suspend fetching from the requested partitions. Future calls to <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> will not return
any records from these partitions until they have been resumed using <a href="#resume(java.util.Collection)"><code>resume(Collection)</code></a>.
Note that this method does not affect partition subscription. In particular, it does not cause a group
rebalance when automatic assignment is used.
Note: Rebalance will not preserve the pause/resume state.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#pause(java.util.Collection)">pause</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partitions</code> - The partitions which should be paused</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - if any of the provided partitions are not currently assigned to this consumer</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#pause(java.util.Collection)"><code>pause(Collection)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="resume(java.util.Collection)">
<h3>resume</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">resume</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</span></div>
<div class="block">Resume specified partitions which have been paused with <a href="#pause(java.util.Collection)"><code>pause(Collection)</code></a>. New calls to
<a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> will return records from these partitions if there are any to be fetched.
If the partitions were not previously paused, this method is a no-op.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#resume(java.util.Collection)">resume</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partitions</code> - The partitions which should be resumed</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - if any of the provided partitions are not currently assigned to this consumer</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#resume(java.util.Collection)"><code>resume(Collection)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="paused()">
<h3>paused</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Set.html" title="class or interface in java.util" class="external-link">Set</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;</span>&nbsp;<span class="element-name">paused</span>()</div>
<div class="block">Get the set of partitions that were previously paused by a call to <a href="#pause(java.util.Collection)"><code>pause(Collection)</code></a>.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#paused()">paused</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Returns:</dt>
<dd>The set of paused partitions</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#paused()"><code>paused()</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="offsetsForTimes(java.util.Map)">
<h3>offsetsForTimes</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndTimestamp.html" title="class in org.apache.kafka.clients.consumer">OffsetAndTimestamp</a>&gt;</span>&nbsp;<span class="element-name">offsetsForTimes</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>&gt;&nbsp;timestampsToSearch)</span></div>
<div class="block">Look up the offsets for the given partitions by timestamp. The returned offset for each partition is the
earliest offset whose timestamp is greater than or equal to the given timestamp in the corresponding partition.
This is a blocking call. The consumer does not have to be assigned the partitions.
If the message format version in a partition is before 0.10.0, i.e. the messages do not have timestamps, null
will be returned for that partition.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#offsetsForTimes(java.util.Map)">offsetsForTimes</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>timestampsToSearch</code> - the mapping from partition to the timestamp to look up.</dd>
<dt>Returns:</dt>
<dd>a mapping from partition to the timestamp and offset of the first message with timestamp greater
than or equal to the target timestamp. <code>null</code> will be returned for the partition if there is no
such message.</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic(s). See the exception for more details</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - if the target timestamp is negative</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the offset metadata could not be fetched before
the amount of time allocated by <code>default.api.timeout.ms</code> expires.</dd>
<dd><code><a href="../../common/errors/UnsupportedVersionException.html" title="class in org.apache.kafka.common.errors">UnsupportedVersionException</a></code> - if the broker does not support looking up
the offsets by timestamp</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#offsetsForTimes(java.util.Map)"><code>offsetsForTimes(Map)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="offsetsForTimes(java.util.Map,java.time.Duration)">
<h3>offsetsForTimes</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="OffsetAndTimestamp.html" title="class in org.apache.kafka.clients.consumer">OffsetAndTimestamp</a>&gt;</span>&nbsp;<span class="element-name">offsetsForTimes</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>&gt;&nbsp;timestampsToSearch,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</span></div>
<div class="block">Look up the offsets for the given partitions by timestamp. The returned offset for each partition is the
earliest offset whose timestamp is greater than or equal to the given timestamp in the corresponding partition.
This is a blocking call. The consumer does not have to be assigned the partitions.
If the message format version in a partition is before 0.10.0, i.e. the messages do not have timestamps, null
will be returned for that partition.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#offsetsForTimes(java.util.Map,java.time.Duration)">offsetsForTimes</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>timestampsToSearch</code> - the mapping from partition to the timestamp to look up.</dd>
<dd><code>timeout</code> - The maximum amount of time to await retrieval of the offsets</dd>
<dt>Returns:</dt>
<dd>a mapping from partition to the timestamp and offset of the first message with timestamp greater
than or equal to the target timestamp. <code>null</code> will be returned for the partition if there is no
such message.</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic(s). See the exception for more details</dd>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - if the target timestamp is negative</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the offset metadata could not be fetched before
expiration of the passed timeout</dd>
<dd><code><a href="../../common/errors/UnsupportedVersionException.html" title="class in org.apache.kafka.common.errors">UnsupportedVersionException</a></code> - if the broker does not support looking up
the offsets by timestamp</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list-long">
<li><a href="#offsetsForTimes(java.util.Map,java.time.Duration)"><code>offsetsForTimes(Map, Duration)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="beginningOffsets(java.util.Collection)">
<h3>beginningOffsets</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>&gt;</span>&nbsp;<span class="element-name">beginningOffsets</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</span></div>
<div class="block">Get the first offset for the given partitions.
<p>
This method does not change the current consumer position of the partitions.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#beginningOffsets(java.util.Collection)">beginningOffsets</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partitions</code> - the partitions to get the earliest offsets.</dd>
<dt>Returns:</dt>
<dd>The earliest available offsets for the given partitions</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic(s). See the exception for more details</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the offset metadata could not be fetched before
expiration of the configured <code>default.api.timeout.ms</code></dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#seekToBeginning(java.util.Collection)"><code>seekToBeginning(Collection)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="beginningOffsets(java.util.Collection,java.time.Duration)">
<h3>beginningOffsets</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>&gt;</span>&nbsp;<span class="element-name">beginningOffsets</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</span></div>
<div class="block">Get the first offset for the given partitions.
<p>
This method does not change the current consumer position of the partitions.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#beginningOffsets(java.util.Collection,java.time.Duration)">beginningOffsets</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partitions</code> - the partitions to get the earliest offsets</dd>
<dd><code>timeout</code> - The maximum amount of time to await retrieval of the beginning offsets</dd>
<dt>Returns:</dt>
<dd>The earliest available offsets for the given partitions</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic(s). See the exception for more details</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the offset metadata could not be fetched before
expiration of the passed timeout</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#seekToBeginning(java.util.Collection)"><code>seekToBeginning(Collection)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="endOffsets(java.util.Collection)">
<h3>endOffsets</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>&gt;</span>&nbsp;<span class="element-name">endOffsets</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions)</span></div>
<div class="block">Get the end offsets for the given partitions. In the default <code>read_uncommitted</code> isolation level, the end
offset is the high watermark (that is, the offset of the last successfully replicated message plus one). For
<code>read_committed</code> consumers, the end offset is the last stable offset (LSO), which is the minimum of
the high watermark and the smallest offset of any open transaction. Finally, if the partition has never been
written to, the end offset is 0.
<p>
This method does not change the current consumer position of the partitions.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#endOffsets(java.util.Collection)">endOffsets</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partitions</code> - the partitions to get the end offsets.</dd>
<dt>Returns:</dt>
<dd>The end offsets for the given partitions.</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic(s). See the exception for more details</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the offset metadata could not be fetched before
the amount of time allocated by <code>default.api.timeout.ms</code> expires</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#seekToEnd(java.util.Collection)"><code>seekToEnd(Collection)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="endOffsets(java.util.Collection,java.time.Duration)">
<h3>endOffsets</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Long.html" title="class or interface in java.lang" class="external-link">Long</a>&gt;</span>&nbsp;<span class="element-name">endOffsets</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Collection.html" title="class or interface in java.util" class="external-link">Collection</a>&lt;<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&gt;&nbsp;partitions,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</span></div>
<div class="block">Get the end offsets for the given partitions. In the default <code>read_uncommitted</code> isolation level, the end
offset is the high watermark (that is, the offset of the last successfully replicated message plus one). For
<code>read_committed</code> consumers, the end offset is the last stable offset (LSO), which is the minimum of
the high watermark and the smallest offset of any open transaction. Finally, if the partition has never been
written to, the end offset is 0.
<p>
This method does not change the current consumer position of the partitions.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#endOffsets(java.util.Collection,java.time.Duration)">endOffsets</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>partitions</code> - the partitions to get the end offsets.</dd>
<dd><code>timeout</code> - The maximum amount of time to await retrieval of the end offsets</dd>
<dt>Returns:</dt>
<dd>The end offsets for the given partitions.</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/AuthenticationException.html" title="class in org.apache.kafka.common.errors">AuthenticationException</a></code> - if authentication fails. See the exception for more details</dd>
<dd><code><a href="../../common/errors/AuthorizationException.html" title="class in org.apache.kafka.common.errors">AuthorizationException</a></code> - if not authorized to the topic(s). See the exception for more details</dd>
<dd><code><a href="../../common/errors/TimeoutException.html" title="class in org.apache.kafka.common.errors">TimeoutException</a></code> - if the offsets could not be fetched before
expiration of the passed timeout</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#seekToEnd(java.util.Collection)"><code>seekToEnd(Collection)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="currentLag(org.apache.kafka.common.TopicPartition)">
<h3>currentLag</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/OptionalLong.html" title="class or interface in java.util" class="external-link">OptionalLong</a></span>&nbsp;<span class="element-name">currentLag</span><wbr><span class="parameters">(<a href="../../common/TopicPartition.html" title="class in org.apache.kafka.common">TopicPartition</a>&nbsp;topicPartition)</span></div>
<div class="block">Get the consumer's current lag on the partition. Returns an "empty" <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/OptionalLong.html" title="class or interface in java.util" class="external-link"><code>OptionalLong</code></a> if the lag is not known,
for example if there is no position yet, or if the end offset is not known yet.
<p>
This method uses locally cached metadata. If the log end offset is not known yet, it triggers a request to fetch
the log end offset, but returns immediately.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#currentLag(org.apache.kafka.common.TopicPartition)">currentLag</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>topicPartition</code> - The partition to get the lag for.</dd>
<dt>Returns:</dt>
<dd>This <code>Consumer</code> instance's current lag for the given partition.</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - if the <code>topicPartition</code> is not assigned</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#currentLag(org.apache.kafka.common.TopicPartition)"><code>currentLag(TopicPartition)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="groupMetadata()">
<h3>groupMetadata</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="ConsumerGroupMetadata.html" title="class in org.apache.kafka.clients.consumer">ConsumerGroupMetadata</a></span>&nbsp;<span class="element-name">groupMetadata</span>()</div>
<div class="block">Return the current group metadata associated with this consumer.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#groupMetadata()">groupMetadata</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Returns:</dt>
<dd>consumer group metadata</dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/InvalidGroupIdException.html" title="class in org.apache.kafka.common.errors">InvalidGroupIdException</a></code> - if consumer does not have a group</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#groupMetadata()"><code>groupMetadata()</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="enforceRebalance(java.lang.String)">
<h3>enforceRebalance</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">enforceRebalance</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>&nbsp;reason)</span></div>
<div class="block">Alert the consumer to trigger a new rebalance by rejoining the group. This is a nonblocking call that forces
the consumer to trigger a new rebalance on the next <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a> call. Note that this API does not
itself initiate the rebalance, so you must still call <a href="#poll(java.time.Duration)"><code>poll(Duration)</code></a>. If a rebalance is already in
progress this call will be a no-op. If you wish to force an additional rebalance you must complete the current
one by calling poll before retrying this API.
<p>
You do not need to call this during normal processing, as the consumer group will manage itself
automatically and rebalance when necessary. However there may be situations where the application wishes to
trigger a rebalance that would otherwise not occur. For example, if some condition external and invisible to
the Consumer and its group changes in a way that would affect the userdata encoded in the
<a href="ConsumerPartitionAssignor.Subscription.html" title="class in org.apache.kafka.clients.consumer"><code>Subscription</code></a>, the Consumer
will not be notified and no rebalance will occur. This API can be used to force the group to rebalance so that
the assignor can perform a partition reassignment based on the latest userdata. If your assignor does not use
this userdata, or you do not use a custom
<a href="ConsumerPartitionAssignor.html" title="interface in org.apache.kafka.clients.consumer"><code>ConsumerPartitionAssignor</code></a>, you should not
use this API.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#enforceRebalance(java.lang.String)">enforceRebalance</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>reason</code> - The reason why the new rebalance is needed.</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalStateException.html" title="class or interface in java.lang" class="external-link">IllegalStateException</a></code> - if the consumer does not use group subscription</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#enforceRebalance(java.lang.String)"><code>enforceRebalance(String)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="enforceRebalance()">
<h3>enforceRebalance</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">enforceRebalance</span>()</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#enforceRebalance()">enforceRebalance</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#enforceRebalance(java.lang.String)"><code>enforceRebalance(String)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="close()">
<h3>close</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">close</span>()</div>
<div class="block">Close the consumer, waiting for up to the default timeout of 30 seconds for any needed cleanup.
If auto-commit is enabled, this will commit the current offsets if possible within the default
timeout. See <a href="#close(java.time.Duration)"><code>close(Duration)</code></a> for details. Note that <a href="#wakeup()"><code>wakeup()</code></a>
cannot be used to interrupt close.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/AutoCloseable.html#close()" title="class or interface in java.lang" class="external-link">close</a></code>&nbsp;in interface&nbsp;<code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/AutoCloseable.html" title="class or interface in java.lang" class="external-link">AutoCloseable</a></code></dd>
<dt>Specified by:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Closeable.html#close()" title="class or interface in java.io" class="external-link">close</a></code>&nbsp;in interface&nbsp;<code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Closeable.html" title="class or interface in java.io" class="external-link">Closeable</a></code></dd>
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#close()">close</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Throws:</dt>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - if the calling thread is interrupted
before or while this function is called</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other error during close</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#close()"><code>close()</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="close(java.time.Duration)">
<h3>close</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">close</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Duration.html" title="class or interface in java.time" class="external-link">Duration</a>&nbsp;timeout)</span></div>
<div class="block">Tries to close the consumer cleanly within the specified timeout. This method waits up to
<code>timeout</code> for the consumer to complete pending commits and leave the group.
If auto-commit is enabled, this will commit the current offsets if possible within the
timeout. If the consumer is unable to complete offset commits and gracefully leave the group
before the timeout expires, the consumer is force closed. Note that <a href="#wakeup()"><code>wakeup()</code></a> cannot be
used to interrupt close.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#close(java.time.Duration)">close</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>Parameters:</dt>
<dd><code>timeout</code> - The maximum time to wait for consumer to close gracefully. The value must be
non-negative. Specifying a timeout of zero means do not wait for pending requests to complete.</dd>
<dt>Throws:</dt>
<dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/IllegalArgumentException.html" title="class or interface in java.lang" class="external-link">IllegalArgumentException</a></code> - If the <code>timeout</code> is negative.</dd>
<dd><code><a href="../../common/errors/InterruptException.html" title="class in org.apache.kafka.common.errors">InterruptException</a></code> - If the thread is interrupted before or while this function is called</dd>
<dd><code><a href="../../common/KafkaException.html" title="class in org.apache.kafka.common">KafkaException</a></code> - for any other error during close</dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#close(java.time.Duration)"><code>close(Duration)</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
<li>
<section class="detail" id="wakeup()">
<h3>wakeup</h3>
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">wakeup</span>()</div>
<div class="block">Wakeup the consumer. This method is thread-safe and is useful in particular to abort a long poll.
The thread which is blocking in an operation will throw <a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors"><code>WakeupException</code></a>.
If no thread is blocking in a method which can throw <a href="../../common/errors/WakeupException.html" title="class in org.apache.kafka.common.errors"><code>WakeupException</code></a>, the next call to such a method will raise it instead.</div>
<dl class="notes">
<dt>Specified by:</dt>
<dd><code><a href="Consumer.html#wakeup()">wakeup</a></code>&nbsp;in interface&nbsp;<code><a href="Consumer.html" title="interface in org.apache.kafka.clients.consumer">Consumer</a>&lt;<a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">K</a>,<wbr><a href="KafkaConsumer.html" title="type parameter in KafkaConsumer">V</a>&gt;</code></dd>
<dt>See Also:</dt>
<dd>
<ul class="see-list">
<li><a href="#wakeup()"><code>wakeup()</code></a></li>
</ul>
</dd>
</dl>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
<!-- ========= END OF CLASS DATA ========= -->
</main>
</div>
</div>
</body>
</html>