|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Message.getBuffer() behaviourHi, Bela!
I send message: channel.send(null, null, new byte[] {}); And receive it public void receive(Message msg) { StringBuilder bytes = new StringBuilder(); for (byte b : msg.getBuffer()) { bytes.append(b); bytes.append(" "); } logger.trace("ReceiverImpl: {}. Object bytes: {}", msg, bytes.toString()); } This is i have in log: ReceiverImpl: [dst: <null>, src: bcomp-16979 (2 headers), size=5 bytes]. Object bytes: 19 0 0 0 0 My question is shouldn't it to be refactored to return empty byte array as sent? Cause the current behaviour is counterintuitive. Thanks, Bulat Nigmatullin ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ javagroups-users mailing list javagroups-users@... https://lists.sourceforge.net/lists/listinfo/javagroups-users |
|
|
Re: Message.getBuffer() behaviourIn receive(), instead of calling msg.getBuffer(), you'll need to call
msg.getObject(), then you'll get new empty byte[] array. In send() you called (indirectly) Message.setObject(), so you'll need to do the same in receive(). Note that this is not very efficient: I recommend you create a message like this: byte[] buffer; Message msg=new Message(null, null, buffer); // calls Message.setBuffer(byte[]) and in receive(): Message msg; byte[] buffer=msg.getBuffer(); Bulat Nigmatullin wrote: > Hi, Bela! > > I send message: > > channel.send(null, null, new byte[] {}); > > And receive it > > public void receive(Message msg) { > StringBuilder bytes = new StringBuilder(); > for (byte b : msg.getBuffer()) { > bytes.append(b); > bytes.append(" "); > } > logger.trace("ReceiverImpl: {}. Object bytes: {}", msg, > bytes.toString()); > } > > This is i have in log: > > ReceiverImpl: [dst: <null>, src: bcomp-16979 (2 headers), size=5 bytes]. > Object bytes: 19 0 0 0 0 > > My question is shouldn't it to be refactored to return empty byte array > as sent? Cause the current behaviour is counterintuitive. -- Bela Ban Lead JGroups / Clustering Team JBoss ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ javagroups-users mailing list javagroups-users@... https://lists.sourceforge.net/lists/listinfo/javagroups-users |
| Free embeddable forum powered by Nabble | Forum Help |