Amazon SQS 消息中的消息字符编码出现问题
我在使用 Amazon SQS 和 Zend(1.11.2) 时遇到一个相当令人费解的问题。我正在向我使用 snip-it 设置的队列发送一条消息,如下所示:
$sqs->send($queueURL, "opt1=foo opt2=bar");
该消息进入远端的应用程序,并被视为:
"opt1%3Dfoo+opt2%3Dbar"
接收应用程序是使用 com.xerox 用 Java 编写的.amazonws.sqs2 库,现已投入生产。
在 Drupal 下使用 Tarzan 的旧 php 模块中也有类似的发送代码,效果很好。我到处搜索并阅读了 Zend、Amazon 和 Java 库的文档,但我陷入了困境。
字符串的编码是可以理解的,但我不知道所使用的方法。进一步的测试表明,单引号、尖括号等也被转义为十六进制。
有什么想法吗?
肯
I have a rather puzzling problem with Amazon SQS and Zend(1.11.2). I am sending a message to the queue that I have setup with a snip-it that looks like this:
$sqs->send($queueURL, "opt1=foo opt2=bar");
The message comes in to the app at the far side and is seen as:
"opt1%3Dfoo+opt2%3Dbar"
The receiving app is written in Java using the com.xerox.amazonws.sqs2 library and is in production now.
There was similar sending code in an older php module that used Tarzan under Drupal that worked just fine. I have searched high and low and read the documentation for Zend, Amazon and the Java library and I am stuck.
The encoding of the string is understandable but I don't recognize the method being used. Further tests show that single quotes, angle brackets, etc. are also escaped as hex.
Any ideas?
Ken
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Typica (com.xerox.amazonaws) 有一个 'encoded' 内部使用 Base64 对消息进行编码的选项。默认情况下此功能处于启用状态。
一般来说,我们发现使用 SQS 时,使用 Base64 编码消息比 URL/百分比编码更麻烦。
我将在 PHP 中对消息文本进行 Base64 处理,将其写入队列,Typica 应该使用默认配置很好地解码。
Typica (com.xerox.amazonaws) has a 'encoded' option that internally uses Base64 to encode messages. This is on by default.
In general, we have found that encoding messages using Base64 is less troublesome then URL/percent encoding when using SQS.
I would Base64 the message text in PHP, write it to the queue, and Typica should decode just fine using the default config.