-
1. Re: SOS !! Wierd Exception: java.lang.IllegalStateException: Packet hasn't been encoded/decoded yet
clebert.suconic Dec 6, 2011 9:51 AM (in response to ybhate)What version are you using?
Look at the LargeMessage Example
Post some code showing what you are doing.
-
2. Re: SOS !! Wierd Exception: java.lang.IllegalStateException: Packet hasn't been encoded/decoded yet
ybhate Dec 6, 2011 11:30 PM (in response to clebert.suconic)I am using Hornetq-2.2.5
Providing you some portion of the code. Note that this portion of the code fails only when i get the fileData as part of a response to a JMS request message.
So this is the flow - only during this flow the code fails and throws exception. Note that all other types of messages are recieved without any problem in the request-respone pattern shown below. The problem is only in the file data transfer.
Server 1 ----- sends JMS message to ----> server 2
Server 2 -----> reads a file ---> put the contents of the file into bytes message as shown below --> responds to the message by setting correlationId-->send the message -----> Server 1
Server 2 --> tried to read the data and put it into a disk file --> throws exception
the following code is used to put the file data into the BytesMessage
==================================================
//assume that somewhere in my code above i am getting the file data in the bufferedInputStream.
BytesMessage bytesMessage = session.createBytesMessage();
bytesMessage.setObjectProperty("JMS_HQ_InputStream", bufferedInputStream
);bytesMessage.setObjectProperty("ODPAYLOAD", payloadXml);
messageId = bytesMessage.getJMSMessageID();
m = bytesMessage;
if(properties != null && properties.size() >0)
msg_payloadUtil.addProperties(m, properties);
m.setJMSCorrelationID(correlationId);
the following code is used to read the data from the bytesMessage. And this is where it throws exception
===========================================================================
{
BufferedInputStream bufferedInputStream =
null;Calendar calendar = Calendar.getInstance();
String filePath= PropertiesUtil.getProperty(
"file.store.path").toString();StringBuilder appendFileExt =
appendFileExt.append(filePath).append(calendar.getTimeInMillis()).append(
"-").append(fileName);appendFileExt.append(filePath).append(calendar.getTimeInMillis());
File outputFile =
new File(appendFileExt.toString());FileOutputStream fileOutputStream =
new FileOutputStream(outputFile);BufferedOutputStream bufferedOutput =
new BufferedOutputStream(fileOutputStream);byteMsg.setObjectProperty(
"JMS_HQ_SaveStream", bufferedOutput); // This is where it throws exception given in my discussionbufferedInputStream =
new BufferedInputStream(new FileInputStream(outputFile));}
catch(Exception e){e.printStackTrace();
}
}
==================================================
-
3. Re: SOS !! Wierd Exception: java.lang.IllegalStateException: Packet hasn't been encoded/decoded yet
clebert.suconic Dec 7, 2011 12:06 PM (in response to ybhate)Did you move to a different message on the caller of getFileData ?
it should always be the current message being received.
You can probably create a sample showing your issue. (use attachments through advanced editor here).