String streamName = “Stream1”;
Stream stream = project.getStream(streamName);
MessageWriter mw = pub.getMessageWriter(streamName);
RelativeRowWriter writer= mw.getRelativeRowWriter();
mw.startEnvelope(0); // can also be mw.startTransaction() for transactions.
for (int i = 0; i < recordsToPublish.length; i++) {
addRow(writer, incomingRecords[i], stream);
}
mw.endBlock();
pub.publish(mw);