Closed lufeng1102 closed 12 years ago
In AMQPQueue.cpp
between 348 to 349
strncpy(tmp, (char*) frame.payload.body_fragment.bytes, frame_len);
will be change to
memcpy(tmp, (char*) frame.payload.body_fragment.bytes, frame_len);
because the strncpy copies the first num characters of source to destination. If the end of the source C string (which is signaled by a null-character) is found before num characters have been copied, destination is padded with zeros until a total of num characters have been written to it.
May be add the getBinaryMessage() ?
Maybe i think there is no need to add this method in AMQPQueue, as long as we can change the getMessage() method in AMQPMessage class to getMessage(int32_t* length). The Message Caller can get the length of the message through this method. Or add a method getLength() in AMQPMessage to return the length of current message.
I Added You into commiters list
12 января 2012, 18:31 от lufeng reply@reply.github.com:
Maybe i think there is no need to add this method in AMQPQueue, as long as we can change the getMessage() method in AMQPMessage class to getMessage(int32_t* length). The Message Caller can get the length of the message through this method. Or add a method getLength() in AMQPMessage to return the length of current message.
Reply to this email directly or view it on GitHub: https://github.com/akalend/amqpcpp/issues/6#issuecomment-3463979
My message use msgPack to serialization and use snappy to compress , when i use amqpcpp to load it, the object AMQPMesage will no return the length of message, i only get the char* using getMessage() in AMQPMessage. So if the message is binary format , using amqp will not get the right message body.
My message is like this ,i use rabbit-c to dump it.
gxl@gxl-desktop:~/programe/Rabbitmq/rabbitmq-c-7cecf64752fd/examples$ ./amqp_listenq 192.168.166.62 5672 xunuu_build Result 0 Frame type 1, channel 1 Method AMQP_BASIC_DELIVER_METHOD
Delivery 1, exchange search_engine routingkey build
00000000: F1 0D F0 4E 00 A4 55 55 : 69 64 01 00 A5 74 69 74 ...N..UUid...tit 00000010: 6C 65 A7 53 75 6D 6D 65 : 72 79 DA 06 D8 50 6F 73 le.Summery...Pos 00000020: 74 67 72 65 53 51 4C 20 : 70 72 69 64 65 73 20 69 tgreSQL prides i 00000030: 74 73 65 6C 66 20 69 6E : 20 73 74 61 6E 64 61 72 tself in standar 00000040: 64 73 20 63 6F 6D 70 6C : 69 61 6E 63 65 2E 20 49 ds compliance. I 00000050: 74 73 20 01 2F 30 69 6D : 70 6C 65 6D 65 6E 74 61 ts ./0implementa 00000060: 74 69 6F 01 2D 90 72 6F : 6E 67 6C 79 20 63 6F 6E tio.-.rongly con 00000070: 66 6F 72 6D 73 20 74 6F : 20 74 68 65 20 41 4E 53 forms to the ANS