tag:blogger.com,1999:blog-6104363047659965830.post5573003234144831827..comments2024-01-04T03:35:33.398-07:00Comments on Technical Tidbit of the Day: Kafka tipsMichael Malakhttp://www.blogger.com/profile/10007582156392845677noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-6104363047659965830.post-74361363597700581932013-06-05T17:30:35.776-06:002013-06-05T17:30:35.776-06:00Hi!
First of all, thanks for your posts.
I'm...Hi!<br /><br />First of all, thanks for your posts.<br /><br />I'm wondering about the implications of using message.payload.array(), as this is what I've been doing for a while and (as far as I can tell) without problem.<br /><br />The way I'm doing it is that I'm instantiating a String which contains the relevant (payload) part of the Kafka message in the following way:<br /><br />new String(message.payload.array(), Message.payloadOffset(message.magic), message.payloadSize)<br /><br />i.e.: this constructor: http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#String(byte[], int, int)<br /><br />If my understanding is correct, this uses the underlying Array[Byte] but starts and ends at proper indexes using payloadOffset() and payloadSize.<br /><br />Do you envision any pitfalls with this approach? Am I missing anything?<br /><br />N.B.: The above code is scala, hence why some of the missing double parenthesis ().Anonymoushttps://www.blogger.com/profile/17740873897611422980noreply@blogger.com