I seem to be stuck in sending compressed messages from PHP to NodeJS on top of Amazon SQS.
On the PHP side, I have:
$SQS->sendMessage(Array(
'QueueUrl' => $queueUrl,
'MessageBody' => 'article',
'MessageAttributes' => Array(
'json' => Array(
'BinaryValue' => bzcompress(json_encode(Array('type'=>'article','data'=>$vijest))),
'DataType' => 'Binary'
)
)
));
NOTE 1. I also tried to put the compressed data directly in the message, but the library gave me an error with some invalid byte data
On the Node side, I have:
body = decodeBzip(message.MessageAttributes.json.BinaryValue);
If the message is called by calling sqs.receiveMessage (), and this part works as it works for raw (uncompressed messages)
I get TypeError: wrong format
I also tried using:
PHP - Node
gzcompress () - zlib.inflateraw ()
gzdeflate () - zlib.inflate ()
gzencode () - zlib.gunzip ()
And each of these pairs gave me its version of the same error (in fact, the input data is erroneous)
, , -
?
EDIT 1. , - , bin2hex() php .toString('hex') Node . , API- Amazon SQS PHP BinaryAttribute base64, Node . , amazon aws, base64 Node, .
EDIT 2: , base64_encode() php base64 messageBody ( MessageAttributes). Node (messageBody, 'base64'), decodeBzip. , , MessageAttribute . 64 , , , .