use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-ce by iitsoftware.
the class MessageSenderJob method copyMessage.
private MessageImpl copyMessage(MessageImpl msg) throws Exception {
DataByteArrayOutputStream dbos = new DataByteArrayOutputStream();
DataByteArrayInputStream dbis = new DataByteArrayInputStream();
dbos.rewind();
msg.writeContent(dbos);
dbis.reset();
dbis.setBuffer(dbos.getBuffer(), 0, dbos.getCount());
MessageImpl msgCopy = MessageImpl.createInstance(dbis.readInt());
msgCopy.readContent(dbis);
return msgCopy;
}
use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-client by iitsoftware.
the class AMQPMessage method decode.
private void decode() throws Exception {
DataInput dataInput = null;
if (multiBody != null) {
dataInput = new DataStreamInputStream(new MultiByteArrayInputStream(multiBody, totalSize));
bodySize = totalSize;
} else {
dataInput = new DataByteArrayInputStream(body);
bodySize = body.length;
}
parseSections(dataInput);
}
use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-client by iitsoftware.
the class Packager method getNextPacket.
public void getNextPacket(TransferFrame currentFrame) throws IOException {
currentFrame.setMore(AMQPBoolean.FALSE);
if (messageFormat != -1)
currentFrame.setMessageFormat(new MessageFormat(messageFormat));
currentPacketNumber++;
byte[] b = null;
if (dbis != null) {
int len = Math.min(dbis.available(), maxPacketLength - currentFrame.getPredictedSize());
b = new byte[len];
dbis.readFully(b);
} else {
if (maxPacketLength - currentFrame.getPredictedSize() - size >= 0) {
if (data.length != size) {
b = new byte[size];
System.arraycopy(data, 0, b, 0, size);
data = null;
} else
b = data;
} else {
if (dbis == null) {
dbis = new DataByteArrayInputStream();
dbis.setBuffer(data, 0, size);
}
int len = Math.min(dbis.available(), maxPacketLength - currentFrame.getPredictedSize());
b = new byte[len];
dbis.readFully(b);
}
}
if (hasMore())
currentFrame.setMore(AMQPBoolean.TRUE);
currentFrame.setPayload(b);
if (predictedNumberPackets == -1)
predictedNumberPackets = size / b.length + 1;
}
use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-client by iitsoftware.
the class SMQPUtil method toMessage.
public static MessageImpl toMessage(byte[] b) throws Exception {
DataByteArrayInputStream dbis = new DataByteArrayInputStream(b);
MessageImpl msg = MessageImpl.createInstance(dbis.readInt());
msg.readContent((LengthCaptureDataInput) dbis);
return msg;
}
use of com.swiftmq.tools.util.DataByteArrayInputStream in project swiftmq-client by iitsoftware.
the class SMQPUtil method toMessage.
public static MessageImpl toMessage(byte[] b) throws Exception {
DataByteArrayInputStream dbis = new DataByteArrayInputStream(b);
MessageImpl msg = MessageImpl.createInstance(dbis.readInt());
msg.readContent((LengthCaptureDataInput) dbis);
return msg;
}
Aggregations