Search in sources :

Example 31 with DataByteArrayInputStream

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;
}
Also used : DataByteArrayOutputStream(com.swiftmq.tools.util.DataByteArrayOutputStream) DataByteArrayInputStream(com.swiftmq.tools.util.DataByteArrayInputStream) MessageImpl(com.swiftmq.jms.MessageImpl)

Example 32 with DataByteArrayInputStream

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);
}
Also used : DataInput(java.io.DataInput) DataStreamInputStream(com.swiftmq.tools.util.DataStreamInputStream) MultiByteArrayInputStream(com.swiftmq.tools.util.MultiByteArrayInputStream) DataByteArrayInputStream(com.swiftmq.tools.util.DataByteArrayInputStream)

Example 33 with DataByteArrayInputStream

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;
}
Also used : MessageFormat(com.swiftmq.amqp.v100.generated.transport.definitions.MessageFormat) DataByteArrayInputStream(com.swiftmq.tools.util.DataByteArrayInputStream)

Example 34 with DataByteArrayInputStream

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;
}
Also used : DataByteArrayInputStream(com.swiftmq.tools.util.DataByteArrayInputStream)

Example 35 with DataByteArrayInputStream

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;
}
Also used : DataByteArrayInputStream(com.swiftmq.tools.util.DataByteArrayInputStream)

Aggregations

DataByteArrayInputStream (com.swiftmq.tools.util.DataByteArrayInputStream)68 InvalidSelectorException (javax.jms.InvalidSelectorException)22 ResourceLimitException (com.swiftmq.swiftlet.auth.ResourceLimitException)21 QueuePushTransaction (com.swiftmq.swiftlet.queue.QueuePushTransaction)21 RingBuffer (com.swiftmq.tools.collection.RingBuffer)21 JMSException (javax.jms.JMSException)21 MessageImpl (com.swiftmq.jms.MessageImpl)20 EntityList (com.swiftmq.mgmt.EntityList)15 List (java.util.List)15 InvalidDestinationException (javax.jms.InvalidDestinationException)14 TopicImpl (com.swiftmq.jms.TopicImpl)8 QueueImpl (com.swiftmq.jms.QueueImpl)7 DataByteArrayOutputStream (com.swiftmq.tools.util.DataByteArrayOutputStream)7 IOException (java.io.IOException)7 com.swiftmq.jms (com.swiftmq.jms)2 AddressString (com.swiftmq.amqp.v100.generated.messaging.message_format.AddressString)1 MessageFormat (com.swiftmq.amqp.v100.generated.transport.definitions.MessageFormat)1 CountableBufferedInputStream (com.swiftmq.impl.net.netty.CountableBufferedInputStream)1 CountableWrappedOutputStream (com.swiftmq.impl.net.netty.CountableWrappedOutputStream)1 BytesMessageImpl (com.swiftmq.jms.BytesMessageImpl)1