问题:
Kafka消费消息时,报错
Error processing message, stopping consumer: (kafka.tools.ConsoleConsumer
)
j
a
v
a
.
l
a
n
g
.
I
l
l
e
g
a
l
A
r
g
u
m
e
n
t
E
x
c
e
p
t
i
o
n
a
t
j
a
v
a
.
n
i
o
.
B
u
f
f
e
r
.
l
i
m
i
t
(
B
u
f
f
e
r
.
j
a
v
a
:
267
)
a
t
k
a
f
k
a
.
m
e
s
s
a
g
e
.
M
e
s
s
a
g
e
.
s
l
i
c
e
D
e
l
i
m
i
t
e
d
(
M
e
s
s
a
g
e
.
s
c
a
l
a
:
236
)
a
t
k
a
f
k
a
.
m
e
s
s
a
g
e
.
M
e
s
s
a
g
e
.
k
e
y
(
M
e
s
s
a
g
e
.
s
c
a
l
a
:
223
)
a
t
k
a
f
k
a
.
m
e
s
s
a
g
e
.
M
e
s
s
a
g
e
A
n
d
M
e
t
a
d
a
t
a
.
k
e
y
(
M
e
s
s
a
g
e
A
n
d
M
e
t
a
d
a
t
a
.
s
c
a
l
a
:
30
)
a
t
k
a
f
k
a
.
t
o
o
l
s
.
C
o
n
s
o
l
e
C
o
n
s
u
m
e
r
) java.lang.IllegalArgumentException at java.nio.Buffer.limit(Buffer.java:267) at kafka.message.Message.sliceDelimited(Message.scala:236) at kafka.message.Message.key(Message.scala:223) at kafka.message.MessageAndMetadata.key(MessageAndMetadata.scala:30) at kafka.tools.ConsoleConsumer
)java.lang.IllegalArgumentExceptionatjava.nio.Buffer.limit(Buffer.java:267)atkafka.message.Message.sliceDelimited(Message.scala:236)atkafka.message.Message.key(Message.scala:223)atkafka.message.MessageAndMetadata.key(MessageAndMetadata.scala:30)atkafka.tools.ConsoleConsumer
a
n
o
n
f
u
n
anonfun
anonfunmain
1.
a
p
p
l
y
(
C
o
n
s
o
l
e
C
o
n
s
u
m
e
r
.
s
c
a
l
a
:
168
)
a
t
k
a
f
k
a
.
t
o
o
l
s
.
C
o
n
s
o
l
e
C
o
n
s
u
m
e
r
1.apply(ConsoleConsumer.scala:168) at kafka.tools.ConsoleConsumer
1.apply(ConsoleConsumer.scala:168)atkafka.tools.ConsoleConsumer
a
n
o
n
f
u
n
anonfun
anonfunmain
1.
a
p
p
l
y
(
C
o
n
s
o
l
e
C
o
n
s
u
m
e
r
.
s
c
a
l
a
:
166
)
a
t
s
c
a
l
a
.
c
o
l
l
e
c
t
i
o
n
.
I
t
e
r
a
t
o
r
1.apply(ConsoleConsumer.scala:166) at scala.collection.Iterator
1.apply(ConsoleConsumer.scala:166)atscala.collection.Iteratorclass.foreach(Iterator.scala:727)
at kafka.utils.IteratorTemplate.foreach(IteratorTemplate.scala:32)
at scala.collection.IterableLike
c
l
a
s
s
.
f
o
r
e
a
c
h
(
I
t
e
r
a
b
l
e
L
i
k
e
.
s
c
a
l
a
:
72
)
a
t
k
a
f
k
a
.
c
o
n
s
u
m
e
r
.
K
a
f
k
a
S
t
r
e
a
m
.
f
o
r
e
a
c
h
(
K
a
f
k
a
S
t
r
e
a
m
.
s
c
a
l
a
:
25
)
a
t
k
a
f
k
a
.
t
o
o
l
s
.
C
o
n
s
o
l
e
C
o
n
s
u
m
e
r
class.foreach(IterableLike.scala:72) at kafka.consumer.KafkaStream.foreach(KafkaStream.scala:25) at kafka.tools.ConsoleConsumer
class.foreach(IterableLike.scala:72)atkafka.consumer.KafkaStream.foreach(KafkaStream.scala:25)atkafka.tools.ConsoleConsumer.main(ConsoleConsumer.scala:166)
at kafka.tools.ConsoleConsumer.main(ConsoleConsumer.scala)
Consumed 0 messages
解决方案:
检查代码使用的kafka的jar包是否和集群中的kafka的jar包版本是否一致。
我的是本地代码用的2.11,集群中使用的2.10 导致一接收消息就报错