Search in sources :

Example 6 with ReadWritePacket

use of com.sun.messaging.jmq.io.ReadWritePacket in project openmq by eclipse-ee4j.

the class IMQDualThreadConnection method writePacket.

public void writePacket(Packet p, boolean control) {
    if (control) {
        if (DEBUG || DUMP_PACKET || OUT_DUMP_PACKET) {
            int flag = (DUMP_PACKET || OUT_DUMP_PACKET) ? Logger.INFO : Logger.DEBUGHIGH;
            logger.log(flag, "\n------------------------------" + "\nSending Control Packet - Dumping" + "\n------------------------------" + "\n" + p.dumpPacketString("<<<<****") + "\n------------------------------");
        }
    } else {
        if (DEBUG || DUMP_PACKET || OUT_DUMP_PACKET) {
            int flag = (DUMP_PACKET || OUT_DUMP_PACKET) ? Logger.INFO : Logger.DEBUGHIGH;
            logger.log(flag, "\n------------------------------" + "\nSending JMS Message -" + " Dumping" + "\n------------------------------" + "\n" + p.dumpPacketString("<<<<****") + "\n------------------------------");
        }
    }
    pktsOut[p.getPacketType()]++;
    // LKS- deal with metrics
    try {
        ReadWritePacket rp = new ReadWritePacket();
        rp.fill(p, !control);
        // CR 6897721 always sent STOP_REPLY via the output queue
        if (Globals.getAPIDirectTwoThreadSyncReplies() && rp.isReply() && rp.getPacketType() != PacketType.STOP_REPLY) {
            // this is a reply packet
            // this is the same thread that sent the request, so we
            // save the reply in a ThreadLocal to pass it directly to the requester
            putReply(rp);
        } else {
            // this packet is not a reply to the client but originates in the broker
            // (e.g. a message being sent to a consumer)
            // write it to the output queue for the client to pick up in due course
            outputQueue.add(rp);
        }
    } catch (IOException ex) {
        logger.log(Logger.DEBUG, "Unable to duplicate packet ", ex);
    }
}
Also used : ReadWritePacket(com.sun.messaging.jmq.io.ReadWritePacket) IOException(java.io.IOException)

Example 7 with ReadWritePacket

use of com.sun.messaging.jmq.io.ReadWritePacket in project openmq by eclipse-ee4j.

the class IMQEmbeddedConnection method readInPacket.

// -------------------------------------------------------------------------
// Sending/Receiving Messages
// -------------------------------------------------------------------------
@Override
protected boolean readInPacket(Packet p) throws IOException {
    // get and fill packet
    try {
        Object o = inputQueue.take();
        if (o instanceof EOF) {
            EOF eof = (EOF) o;
            throw new IOException("Connection has been closed:" + eof.getReason());
        }
        // note of type ReadWritePacket
        Packet newp = (Packet) o;
        // Make a copy
        // 
        // IF CLIENT IS MAKING A COPY, this can be a shallow copy
        // Otherwise, this needs to be a deep copy
        // 
        // LKS-XXX: revisit and make sure it should be shallow
        p.fill(newp, false);
    } catch (IOException ex) {
        // rethrow
        throw ex;
    } catch (Exception ex) {
        // LKS-XXX handle better
        Globals.getLogger().logStack(Logger.DEBUG, "Error retrieving message", ex);
        throw new IOException("Issue processing :" + ex);
    }
    return true;
}
Also used : ReadWritePacket(com.sun.messaging.jmq.io.ReadWritePacket) Packet(com.sun.messaging.jmq.io.Packet) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException)

Example 8 with ReadWritePacket

use of com.sun.messaging.jmq.io.ReadWritePacket in project openmq by eclipse-ee4j.

the class DirectConnectionHandler method close.

@Override
public synchronized void close() throws IOException {
    if (isClosed) {
        return;
    }
    ReadWritePacket pkt = new ReadWritePacket();
    pkt.setPacketType(PacketType.NONE);
    this.isClosed = true;
    // wake up read channel
    try {
        this.inBoundQ.put(pkt);
    } catch (Exception e) {
        IOException ioe = new IOException(e.getMessage());
        throw ioe;
    }
}
Also used : ReadWritePacket(com.sun.messaging.jmq.io.ReadWritePacket) IOException(java.io.IOException) JMSException(jakarta.jms.JMSException) IOException(java.io.IOException)

Example 9 with ReadWritePacket

use of com.sun.messaging.jmq.io.ReadWritePacket in project openmq by eclipse-ee4j.

the class DirectConnectionHandler method readPacket.

@Override
public ReadWritePacket readPacket() throws IOException {
    ReadWritePacket pkt = null;
    try {
        if (isClosed == false) {
            pkt = (ReadWritePacket) this.inBoundQ.take();
        }
        if (directDebug) {
            System.out.println("Direct connection read pkt..." + pkt);
            // pkt.dump(System.out);
            System.out.flush();
        }
        if (isClosed) {
            throw new IOException("Connection is closed.");
        }
    } catch (InterruptedException inte) {
    }
    return pkt;
}
Also used : ReadWritePacket(com.sun.messaging.jmq.io.ReadWritePacket) IOException(java.io.IOException)

Aggregations

ReadWritePacket (com.sun.messaging.jmq.io.ReadWritePacket)9 IOException (java.io.IOException)6 JMSException (jakarta.jms.JMSException)2 BigPacketException (com.sun.messaging.jmq.io.BigPacketException)1 Packet (com.sun.messaging.jmq.io.Packet)1 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)1 Session (jakarta.websocket.Session)1