com.taosdata.jdbc.tmq

## Class JNIConsumer<V>

- java.lang.Object
- - com.taosdata.jdbc.tmq.JNIConsumer<V>

All Implemented Interfaces:
  Consumer<V>

    public class JNIConsumer<V>
    extends Object
    implements Consumer<V>

### Constructor Summary

Constructors
Constructor and Description
`JNIConsumer()`

### Method Summary

All Methods Instance Methods Concrete Methods
`Set<TopicPartition>` `assignment()` Get the set of partitions currently assigned to this consumer.
`Map<TopicPartition,Long>` `beginningOffsets(String topic)`
`void` `close()` close consumer
`void` `commitAsync(Map<TopicPartition,OffsetAndMetadata> offsets, OffsetCommitCallback<V> callback)`
`void` `commitAsync(OffsetCommitCallback<V> callback)`
`void` `commitSync()` commit offset with sync
`void` `commitSync(Map<TopicPartition,OffsetAndMetadata> offsets)`
`Map<TopicPartition,OffsetAndMetadata>` `committed(Set<TopicPartition> partitions)`
`OffsetAndMetadata` `committed(TopicPartition partition)` Get the last committed offset for the given partition.
`void` `create(Properties properties)` create consumer
`Map<TopicPartition,Long>` `endOffsets(String topic)`
`String` `getErrMsg(int code)`
`ConsumerRecords<V>` `poll(Duration timeout, Deserializer<V> deserializer)` get result records
`Map<TopicPartition,Long>` `position(String topic)`
`long` `position(TopicPartition partition)` Get the offset of the next record that will be fetched.
`void` `seek(TopicPartition partition, long offset)` If this API is invoked for the same partition more than once, the latest offset will be used on the next poll().
`void` `seekToBeginning(Collection<TopicPartition> partitions)`
`void` `seekToEnd(Collection<TopicPartition> partitions)`
`void` `subscribe(Collection<String> topics)` subscribe topics
`Set<String>` `subscription()` get subscribe topics
`void` `unsubscribe()` unsubscribe topics

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### JNIConsumer

    public JNIConsumer()

### Method Detail

#### create

    public void create(Properties properties)
                throws SQLException

Description copied from interface: `Consumer`
create consumer

Specified by:
  `create` in interface `Consumer<V>`
Parameters:
  `properties` - ip / port / user / password and so on.
Throws:
  `SQLException` - jni exception

#### subscribe

    public void subscribe(Collection<String> topics)
                   throws SQLException

Description copied from interface: `Consumer`
subscribe topics

Specified by:
  `subscribe` in interface `Consumer<V>`
Parameters:
  `topics` - collection of topics
Throws:
  `SQLException`

#### unsubscribe

    public void unsubscribe()
                     throws SQLException

Description copied from interface: `Consumer`
unsubscribe topics

Specified by:
  `unsubscribe` in interface `Consumer<V>`
Throws:
  `SQLException`

#### subscription

    public Set<String> subscription()
                             throws SQLException

Description copied from interface: `Consumer`
get subscribe topics

Specified by:
  `subscription` in interface `Consumer<V>`
Returns:
  topic set
Throws:
  `SQLException`

#### poll

    public ConsumerRecords<V> poll(Duration timeout,
                                   Deserializer<V> deserializer)
                            throws SQLException

Description copied from interface: `Consumer`
get result records

Specified by:
  `poll` in interface `Consumer<V>`
Parameters:
  `timeout` - wait time for poll data
  `deserializer` - convert resultSet to javaBean
Returns:
  ConsumerRecord is the collection of javaBean
Throws:
  `SQLException` - java reflect exception or resultSet convert exception

#### commitAsync

    public void commitAsync(OffsetCommitCallback<V> callback)
                     throws SQLException

Specified by:
  `commitAsync` in interface `Consumer<V>`
Throws:
  `SQLException`

#### commitAsync

    public void commitAsync(Map<TopicPartition,OffsetAndMetadata> offsets,
                            OffsetCommitCallback<V> callback)

Specified by:
  `commitAsync` in interface `Consumer<V>`

#### commitSync

    public void commitSync()
                    throws SQLException

Description copied from interface: `Consumer`
commit offset with sync

Specified by:
  `commitSync` in interface `Consumer<V>`
Throws:
  `SQLException`

#### commitSync

    public void commitSync(Map<TopicPartition,OffsetAndMetadata> offsets)
                    throws SQLException

Specified by:
  `commitSync` in interface `Consumer<V>`
Throws:
  `SQLException`

#### seek

    public void seek(TopicPartition partition,
                     long offset)

Description copied from interface: `Consumer`
If this API is invoked for the same partition more than once, the latest offset will be used on the next poll().

Specified by:
  `seek` in interface `Consumer<V>`

#### position

    public long position(TopicPartition partition)
                  throws SQLException

Description copied from interface: `Consumer`
Get the offset of the next record that will be fetched.

Specified by:
  `position` in interface `Consumer<V>`
Throws:
  `SQLException`

#### position

    public Map<TopicPartition,Long> position(String topic)
                                      throws SQLException

Specified by:
  `position` in interface `Consumer<V>`
Throws:
  `SQLException`

#### beginningOffsets

    public Map<TopicPartition,Long> beginningOffsets(String topic)

Specified by:
  `beginningOffsets` in interface `Consumer<V>`

#### endOffsets

    public Map<TopicPartition,Long> endOffsets(String topic)

Specified by:
  `endOffsets` in interface `Consumer<V>`

#### seekToBeginning

    public void seekToBeginning(Collection<TopicPartition> partitions)
                         throws SQLException

Specified by:
  `seekToBeginning` in interface `Consumer<V>`
Throws:
  `SQLException`

#### seekToEnd

    public void seekToEnd(Collection<TopicPartition> partitions)
                   throws SQLException

Specified by:
  `seekToEnd` in interface `Consumer<V>`
Throws:
  `SQLException`

#### assignment

    public Set<TopicPartition> assignment()
                                   throws SQLException

Description copied from interface: `Consumer`
Get the set of partitions currently assigned to this consumer.

Specified by:
  `assignment` in interface `Consumer<V>`
Throws:
  `SQLException`

#### committed

    public OffsetAndMetadata committed(TopicPartition partition)
                                throws SQLException

Description copied from interface: `Consumer`
Get the last committed offset for the given partition. This offset will be used as the position for the consumer in the event of a failure.

Specified by:
  `committed` in interface `Consumer<V>`
Throws:
  `SQLException`

#### committed

    public Map<TopicPartition,OffsetAndMetadata> committed(Set<TopicPartition> partitions)
                                                    throws SQLException

Specified by:
  `committed` in interface `Consumer<V>`
Throws:
  `SQLException`

#### close

    public void close()
               throws SQLException

Description copied from interface: `Consumer`
close consumer

Specified by:
  `close` in interface `Consumer<V>`
Throws:
  `SQLException`

#### getErrMsg

    public String getErrMsg(int code)