You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Gaurav Agarwal <ga...@gmail.com> on 2015/04/25 19:43:49 UTC
Regarding key to b sent as part of producer message Please help
Hello
I am sending message from producer like this with DefaultEncoder.
KeyedMessage<String, byte[]> keyedMessage = new KeyedMessage<String,
byte[]>("topic",Serializations.serialize("s"),
Serializations.getSerialized(msg,rqst));
This is a compile time error at java level as it expects String
But if i use
KeyedMessage<String, byte[]> keyedMessage = new KeyedMessage<String,
byte[]>("topic","s",Serializations.getSerialized(msg,rqst));
as part of sending message , it gives me class cast exception as i have
configured DefaultEncoder and sending byte Message.
Re: Regarding key to b sent as part of producer message Please help
Posted by Gaurav Agarwal <ga...@gmail.com>.
Hi
I got it was doing something wrong. need to set the value like this,topic
is by default string
KeyedMessage<byte[], byte[]> keyedMessage = new KeyedMessage<byte[],
byte[]>("topic",Serializations.serialize("s"),
Serializations.getSerialized(msg,rqst));
On Sun, Apr 26, 2015 at 3:14 AM, Manoj Khangaonkar <kh...@gmail.com>
wrote:
> Hi
>
> Your key seems to be String.
>
> key.serializer.class might need to be set to StringEncoder.
>
> regards
>
> On Sat, Apr 25, 2015 at 10:43 AM, Gaurav Agarwal <ga...@gmail.com>
> wrote:
>
> > Hello
> >
> > I am sending message from producer like this with DefaultEncoder.
> >
> > KeyedMessage<String, byte[]> keyedMessage = new KeyedMessage<String,
> > byte[]>("topic",Serializations.serialize("s"),
> >
> > Serializations.getSerialized(msg,rqst));
> >
> > This is a compile time error at java level as it expects String
> >
> >
> > But if i use
> >
> >
> > KeyedMessage<String, byte[]> keyedMessage = new KeyedMessage<String,
> > byte[]>("topic","s",Serializations.getSerialized(msg,rqst));
> >
> >
> > as part of sending message , it gives me class cast exception as i have
> > configured DefaultEncoder and sending byte Message.
> >
>
>
>
> --
> http://khangaonkar.blogspot.com/
>
Re: Regarding key to b sent as part of producer message Please help
Posted by Manoj Khangaonkar <kh...@gmail.com>.
Hi
Your key seems to be String.
key.serializer.class might need to be set to StringEncoder.
regards
On Sat, Apr 25, 2015 at 10:43 AM, Gaurav Agarwal <ga...@gmail.com>
wrote:
> Hello
>
> I am sending message from producer like this with DefaultEncoder.
>
> KeyedMessage<String, byte[]> keyedMessage = new KeyedMessage<String,
> byte[]>("topic",Serializations.serialize("s"),
>
> Serializations.getSerialized(msg,rqst));
>
> This is a compile time error at java level as it expects String
>
>
> But if i use
>
>
> KeyedMessage<String, byte[]> keyedMessage = new KeyedMessage<String,
> byte[]>("topic","s",Serializations.getSerialized(msg,rqst));
>
>
> as part of sending message , it gives me class cast exception as i have
> configured DefaultEncoder and sending byte Message.
>
--
http://khangaonkar.blogspot.com/