Search in sources :

Example 1 with ConsumerClosedNoDeliveryException

use of com.sun.messaging.jmq.jmsservice.ConsumerClosedNoDeliveryException in project openmq by eclipse-ee4j.

the class DirectMDBSession method _deliverMessage.

/**
 * Deliver a message from this DirectSession - only one thread can do this at a time.
 */
@Override
protected synchronized JMSAck _deliverMessage(jakarta.jms.MessageListener msgListener, JMSPacket jmsPacket, long consumerId) throws ConsumerClosedNoDeliveryException {
    JMSAck jmsAck = null;
    if (this.enableThreadCheck) {
        // Relies on the *same* thread being used to deliver all messages
        // while this sesion is alive
        long tId = Thread.currentThread().getId();
        if (this.deliverThreadId == 0L) {
            // first time
            this.deliverThreadId = tId;
        } else {
            if (this.deliverThreadId != tId) {
                throw new RuntimeException("Invalid to call deliver from two different threads!");
            }
        }
    }
    jakarta.jms.Message jmsMsg = null;
    if (msgListener == null) {
        throw new RuntimeException("DirectConsumer:MessageListener not set!");
    }
    if (jmsPacket == null) {
        throw new RuntimeException("DirectConsumer:JMSPacket is null!");
    }
    try {
        jmsMsg = DirectPacket.constructMessage(jmsPacket, consumerId, this, this.jmsservice, false);
    } catch (Exception e) {
    }
    if (jmsMsg == null) {
        throw new RuntimeException("DirectConsumer:JMS Message in Packet is null!");
    }
    try {
        this.inDeliver = true;
        msgListener.onMessage(jmsMsg);
        // this.ds._deliverMessage(this.msgListener, jmsMsg);
        this.inDeliver = false;
        if (this.ackMode != SessionAckMode.CLIENT_ACKNOWLEDGE) {
            jmsAck = new DirectAck(this.connectionId, this.sessionId, consumerId, ((DirectPacket) jmsMsg).getReceivedSysMessageID(), JMSService.MessageAckType.ACKNOWLEDGE);
        }
    } catch (Exception e) {
        System.out.println("DirectConsumer:Caught Exception delivering message" + e.getMessage());
    }
    return jmsAck;
}
Also used : jakarta.jms(jakarta.jms) JMSAck(com.sun.messaging.jmq.jmsservice.JMSAck) ConsumerClosedNoDeliveryException(com.sun.messaging.jmq.jmsservice.ConsumerClosedNoDeliveryException)

Example 2 with ConsumerClosedNoDeliveryException

use of com.sun.messaging.jmq.jmsservice.ConsumerClosedNoDeliveryException in project openmq by eclipse-ee4j.

the class StompSubscriberSession method deliver.

@Override
public JMSAck deliver(JMSPacket msgpkt) throws ConsumerClosedNoDeliveryException {
    if (closing || closed || stompconn.isClosed()) {
        throw new ConsumerClosedNoDeliveryException("Subscriber " + this + " is closed");
    }
    try {
        final boolean needAck = (ackMode != SessionAckMode.AUTO_ACKNOWLEDGE);
        StompFrameMessage msg = toStompFrameMessage(subid, stompdest, msgpkt.getPacket(), needAck);
        if (stompconn.getProtocolHandler().getDEBUG()) {
            logger.log(logger.INFO, " SEND message " + msg + " for " + toString());
        }
        if (ackMode != SessionAckMode.CLIENT_ACKNOWLEDGE) {
            out.sendToClient(msg, stompconn.getProtocolHandler(), null);
            return new Ack(msgpkt.getPacket(), MessageAckType.ACKNOWLEDGE);
        } else {
            unackedMessages.add(msgpkt.getPacket().getSysMessageID());
            out.sendToClient(msg, stompconn.getProtocolHandler(), null);
        }
    } catch (Exception e) {
        logger.logStack(logger.WARNING, e.getMessage(), e);
    }
    return null;
}
Also used : ConsumerClosedNoDeliveryException(com.sun.messaging.jmq.jmsservice.ConsumerClosedNoDeliveryException) StompFrameMessage(com.sun.messaging.bridge.api.StompFrameMessage) JMSAck(com.sun.messaging.jmq.jmsservice.JMSAck) ConsumerClosedNoDeliveryException(com.sun.messaging.jmq.jmsservice.ConsumerClosedNoDeliveryException) StompProtocolException(com.sun.messaging.bridge.api.StompProtocolException) JMSServiceException(com.sun.messaging.jmq.jmsservice.JMSServiceException)

Example 3 with ConsumerClosedNoDeliveryException

use of com.sun.messaging.jmq.jmsservice.ConsumerClosedNoDeliveryException in project openmq by eclipse-ee4j.

the class DirectSession method _deliverMessage.

/**
 * Deliver a message from this DirectSession - only one thread can do this at a time.
 */
protected synchronized JMSAck _deliverMessage(jakarta.jms.MessageListener msgListener, JMSPacket jmsPacket, long consumerId) throws ConsumerClosedNoDeliveryException {
    JMSAck jmsAck = null;
    SysMessageID messageID = null;
    if (this.enableThreadCheck) {
        // Relies on the *same* thread being used to deliver all messages
        // while this sesion is alive
        long tId = Thread.currentThread().getId();
        if (this.deliverThreadId == 0L) {
            // first time
            this.deliverThreadId = tId;
        } else {
            if (this.deliverThreadId != tId) {
                throw new RuntimeException("Invalid to call deliver from two different threads!");
            }
        }
    }
    jakarta.jms.Message jmsMsg = null;
    if (msgListener == null) {
        throw new RuntimeException("DirectConsumer:MessageListener not set!");
    }
    if (jmsPacket == null) {
        throw new RuntimeException("DirectConsumer:JMSPacket is null!");
    }
    try {
        jmsMsg = DirectPacket.constructMessage(jmsPacket, consumerId, this, this.jmsservice, false);
    } catch (Exception e) {
    }
    if (jmsMsg == null) {
        throw new RuntimeException("DirectConsumer:JMS Message in Packet is null!");
    }
    try {
        this.inDeliver = true;
        msgListener.onMessage(jmsMsg);
        // this.ds._deliverMessage(this.msgListener, jmsMsg);
        this.inDeliver = false;
        messageID = ((DirectPacket) jmsMsg).getReceivedSysMessageID();
        if (this.ackMode != SessionAckMode.CLIENT_ACKNOWLEDGE) {
            /*
                 * if (this.dc.isManaged() && this.dc.isEnlisted()){ xaTxnId = this.dc._getXAResource()._getTransactionId(); } else {
                 * xaTxnId = this._getTransactionId(); }
                 */
            jmsAck = new DirectAck(this.connectionId, this.sessionId, consumerId, messageID, JMSService.MessageAckType.ACKNOWLEDGE);
        } else {
            // Do not need to recover an MDB Session
            if (!this._isMDBSession()) {
                // Insert message's SysMessageID and consumerId for recover
                // for non-MDB Session
                unackedMessageIDs.add(messageID);
                unackedConsumerIDs.add(consumerId);
            }
        }
    } catch (ConsumerClosedNoDeliveryException e) {
        throw e;
    } catch (Exception e) {
        System.out.println("DirectConsumer:Caught Exception delivering message" + e.getMessage());
    // Re-attempt redelivery semantics here
    // Ack UNDELIVERABLE or DEAD
    }
    return jmsAck;
}
Also used : Message(jakarta.jms.Message) ConsumerClosedNoDeliveryException(com.sun.messaging.jmq.jmsservice.ConsumerClosedNoDeliveryException) JMSAck(com.sun.messaging.jmq.jmsservice.JMSAck) SysMessageID(com.sun.messaging.jmq.io.SysMessageID) JMSException(jakarta.jms.JMSException) JMSServiceException(com.sun.messaging.jmq.jmsservice.JMSServiceException) InvalidDestinationException(jakarta.jms.InvalidDestinationException) MessageFormatException(jakarta.jms.MessageFormatException) InvalidSelectorException(jakarta.jms.InvalidSelectorException) ConsumerClosedNoDeliveryException(com.sun.messaging.jmq.jmsservice.ConsumerClosedNoDeliveryException) IllegalStateException(com.sun.messaging.jms.IllegalStateException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) JMSSecurityException(jakarta.jms.JMSSecurityException)

Example 4 with ConsumerClosedNoDeliveryException

use of com.sun.messaging.jmq.jmsservice.ConsumerClosedNoDeliveryException in project openmq by eclipse-ee4j.

the class OnMessageRunnerPool method getOnMessageRunner.

/**
 * Get an OnMessageRunner from the pool
 */
public synchronized OnMessageRunner getOnMessageRunner() throws JMSException {
    OnMessageRunner omr;
    // System.out.println("MQRA:OMRP:getOMR()");
    if (available.isEmpty()) {
        if (deactivating)
            throw new ConsumerClosedNoDeliveryException("MQRA:OMRP:getOMR:OnMessageRunnerPool is in deactivating");
        // System.out.println("MQRA:OMRP:getOMR:size=0");
        if (slackCount > 0) {
            // System.out.println("MQRA:OMRP:getOMR:adding from slack");
            omr = new OnMessageRunner(onMessageRunners.size(), this, epFactory, epConsumer, spec, useDirect);
            onMessageRunners.add(omr);
            slackCount--;
            // System.out.println("MQRA:OMRP:getOMR:slack-Getting omr Id="+omr.omrId);
            return omr;
        }
    }
    while (available.isEmpty()) {
        if (deactivating)
            throw new ConsumerClosedNoDeliveryException("MQRA:OMRP:getOMR:OnMessageRunnerPool is in deactivating");
        try {
            // System.out.println("MQRA:OMRP:getOMR:Waiting...");
            wait();
        } catch (InterruptedException ie) {
            // System.out.println("MQRA:OMRP:getOMR:Interrupted while waiting...throwing exception-"+ie.getMessage());
            JMSException jmse = new com.sun.messaging.jms.JMSException("MQRA:OMRP:Unable to get OMR from pool:" + ie.getMessage());
            jmse.setLinkedException(ie);
            throw jmse;
        }
    }
    omr = available.elementAt(available.size() - 1);
    // System.out.println("MQRA:OMRP:getOMR:Getting omr at index="+(available.size()-1)+" with omrId="+omr.omrId);
    available.removeElementAt(available.size() - 1);
    return omr;
}
Also used : jakarta.jms(jakarta.jms) ConsumerClosedNoDeliveryException(com.sun.messaging.jmq.jmsservice.ConsumerClosedNoDeliveryException)

Aggregations

ConsumerClosedNoDeliveryException (com.sun.messaging.jmq.jmsservice.ConsumerClosedNoDeliveryException)4 JMSAck (com.sun.messaging.jmq.jmsservice.JMSAck)3 JMSServiceException (com.sun.messaging.jmq.jmsservice.JMSServiceException)2 jakarta.jms (jakarta.jms)2 StompFrameMessage (com.sun.messaging.bridge.api.StompFrameMessage)1 StompProtocolException (com.sun.messaging.bridge.api.StompProtocolException)1 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)1 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)1 IllegalStateException (com.sun.messaging.jms.IllegalStateException)1 InvalidDestinationException (jakarta.jms.InvalidDestinationException)1 InvalidSelectorException (jakarta.jms.InvalidSelectorException)1 JMSException (jakarta.jms.JMSException)1 JMSSecurityException (jakarta.jms.JMSSecurityException)1 Message (jakarta.jms.Message)1 MessageFormatException (jakarta.jms.MessageFormatException)1