我得到了一个奇怪的例外我到目前为止在Java中遇到过rabbitmq客户端和谷歌搜索没有产生任何有用的结果所以我把它带到SO:)
任何人都可以指出我对此或修复的可能解释?
java.lang.IllegalArgumentException: Short string too long; utf-8 encoded length = 830, max = 255.
at com.rabbitmq.client.impl.ValueWriter.writeShortstr(ValueWriter.java:51) ~[amqp-client-2.8.4.jar:na]
at com.rabbitmq.client.impl.MethodArgumentWriter.writeShortstr(MethodArgumentWriter.java:75) ~[amqp-client-2.8.4.jar:na]
at com.rabbitmq.client.impl.AMQImpl$Queue$Bind.writeArgumentsTo(AMQImpl.java:1549) ~[amqp-client-2.8.4.jar:na]
at com.rabbitmq.client.impl.Method.toFrame(Method.java:83) ~[amqp-client-2.8.4.jar:na]
答案 0 :(得分:2)
public final void writeShortstr(String str)
throws IOException
{
byte [] bytes = str.getBytes("utf-8");
int length = bytes.length;
if (length > 255) {
throw new IllegalArgumentException(
"Short string too long; utf-8 encoded length = " + length +
", max = 255.");
}
out.writeByte(bytes.length);
out.write(bytes);
}
你的字符串太长了。