// Serialize each message as a separate chunk of bytes.
TypeMarshallingContext.setTypeMarshaller(getTypeMarshaller());
for (Iterator iter = messages.iterator(); iter.hasNext();)
{
AmfxOutput amfxOut = new AmfxOutput(serializationContext);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
DataOutputStream dataOutStream = new DataOutputStream(outStream);
amfxOut.setOutputStream(dataOutStream);
Message message = (Message)iter.next();
// Add performance information if MPI is enabled.
if (isRecordMessageSizes() || isRecordMessageTimes())
addPerformanceInfo(message);
if (Log.isDebug())
log.debug("Endpoint with id '" + getId() + "' is streaming message: " + message);
amfxOut.writeObject(message);
dataOutStream.flush();
byte[] messageBytes = outStream.toByteArray();
streamChunk(messageBytes, os, response);
// Update the push count for the StreamingEndpoint mbean.