使用 AciveMQ 发送大型 java 对象时出现 java.io.EOFException。
下面是我要发送的大对象
class TestDataBean implements Serializable
{
private String testName = "TestName";
private String testDesc = "testDesc";
private String bigData = getBigString();
@Override
public String toString() {
return testName +" : "+testDesc+" : "+bigData.length();
}
private static String getBigString()
{
StringBuffer stringBuffer = new StringBuffer();
for(int i=0;i<1000; i++)
{
stringBuffer.append("tsssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss");
}
return stringBuffer.toString();
}
}
下面是堆栈跟踪。
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readLongUTF(Unknown Source)
at java.io.ObjectInputStream.readString(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)Recieved MSG : 0 : null
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at poc_publisher_subsciber.common.CommonUtil.getObject(CommonUtil.java:18)
at blob_messages.bsr_clients.GenesisMessageListener.onMessage(GenesisMessageListener.java:30)
at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:1298)
at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:131)
at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:202)
at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:122)
at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:43)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
生产者表明它发送了一个正确的对象。但在消费者方面,它会抛出异常。
我也尝试过使用 ActiveMQConnectionFactory 进行以下配置
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(url);
factory.setProducerWindowSize(1024000000);
factory.setSendTimeout(600000);
请建议我一些解决方案。提前致谢。