[rabbitmq-discuss] Publishing binary data using the java client

Christian Strack strack at Mathematik.Uni-Marburg.de
Sun Jan 13 08:58:54 GMT 2013


Hello Matthias

Thank you for pointing that out for me. This solved my problem. Sorry for not sending directly executable code, I must have overseen this request.

Regards,
Christian

Am 13.01.2013 um 00:15 schrieb Matthias Radestock <matthias at rabbitmq.com>:

> Christian,
> 
> On 12/01/13 17:44, Christian Strack wrote:
>> Hello Matthias and Michael and thank you for your fast response. In
>> this mail is the full code including de- and encoding:
> 
> Thanks for posting this. While it's not executable code, I think I've spotted the problem...
> 
> Here's a fragment of the receiver code:
> 
>>        byte[] data = new byte[4];
>> 
>>        for(int i=0; i<count;i++){
>>            t.read(data, 4);
>>            System.out.println("Received Package #"+i);
>>            new_value = ByteBuffer.wrap(data).getInt();
> 
> You appear to expect the 'read' invocation to modify the 'data' array that you pass in as an argument.
> 
> But 'read' looks like this:
> 
>>    public int read(byte[] data, int len) {
>>        try {
>>            Delivery delivery = consumer.nextDelivery();
>>            if (delivery != null){
>>                data = delivery.getBody();
>>                System.out.println(new String(data));
>>                return len;
>>            }
> 
> The delivery.getBody() call returns a reference to an array, and the above simply assigns a that reference to the local 'data' variable.
> 
> So the data that is being read never makes it out of that function.
> 
> 
> Regards,
> 
> Matthias.
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss



More information about the rabbitmq-discuss mailing list