Search in sources :

Example 1 with DataHandler

use of com.sun.messaging.jmq.jmsserver.data.handlers.DataHandler in project openmq by eclipse-ee4j.

the class CoreLifecycleImpl method initHandlers.

@Override
public void initHandlers(PacketRouter pktrtr, ConnectionManager cmgr, PacketRouter admin_pktrtr, AdminDataHandler admin_datahdrl) throws BrokerException {
    this.pktr = pktrtr;
    HelloHandler hello = new HelloHandler(cmgr);
    hello.setCoreLifecycle(this);
    GetLicenseHandler getLicense = new GetLicenseHandler();
    getLicense.setCoreLifecycle(this);
    GoodbyeHandler goodbye = new GoodbyeHandler();
    goodbye.setCoreLifecycle(this);
    StartStopHandler startstop = new StartStopHandler();
    startstop.setCoreLifecycle(this);
    ConsumerHandler conhdlr = new ConsumerHandler();
    conhdlr.setCoreLifecycle(this);
    ProducerHandler prodhandler = new ProducerHandler();
    prodhandler.setCoreLifecycle(this);
    DestinationHandler desthandler = new DestinationHandler();
    desthandler.setCoreLifecycle(this);
    QBrowseHandler qbrowserhdlr = new QBrowseHandler();
    qbrowserhdlr.setCoreLifecycle(this);
    AuthHandler authenticate = new AuthHandler();
    authenticate.setCoreLifecycle(this);
    SessionHandler sessionhdlr = new SessionHandler();
    sessionhdlr.setCoreLifecycle(this);
    PingHandler pinghandler = new PingHandler();
    pinghandler.setCoreLifecycle(this);
    DataHandler datahdrl = new DataHandler();
    datahdrl.setCoreLifecycle(this);
    AckHandler ackhandler = new AckHandler();
    ackhandler.setCoreLifecycle(this);
    RedeliverHandler redeliverhdlr = new RedeliverHandler();
    redeliverhdlr.setCoreLifecycle(this);
    DeliverHandler deliverhdlr = new DeliverHandler();
    deliverhdlr.setCoreLifecycle(this);
    TransactionHandler thandler = new TransactionHandler();
    thandler.setCoreLifecycle(this);
    VerifyDestinationHandler vdhandler = new VerifyDestinationHandler();
    vdhandler.setCoreLifecycle(this);
    ClientIDHandler clienthandler = new ClientIDHandler();
    clienthandler.setCoreLifecycle(this);
    FlowHandler flowhdlr = new FlowHandler();
    flowhdlr.setCoreLifecycle(this);
    FlowPausedHandler fphandler = new FlowPausedHandler();
    fphandler.setCoreLifecycle(this);
    GenerateUIDHandler genUIDhandler = new GenerateUIDHandler();
    genUIDhandler.setCoreLifecycle(this);
    InfoRequestHandler infohandler = new InfoRequestHandler();
    infohandler.setCoreLifecycle(this);
    VerifyTransactionHandler vthandler = new VerifyTransactionHandler();
    vthandler.setCoreLifecycle(this);
    pktrtr.addHandler(PacketType.HELLO, hello);
    pktrtr.addHandler(PacketType.AUTHENTICATE, authenticate);
    pktrtr.addHandler(PacketType.GET_LICENSE, getLicense);
    pktrtr.addHandler(PacketType.ADD_CONSUMER, conhdlr);
    pktrtr.addHandler(PacketType.DELETE_CONSUMER, conhdlr);
    pktrtr.addHandler(PacketType.ADD_PRODUCER, prodhandler);
    pktrtr.addHandler(PacketType.START, startstop);
    pktrtr.addHandler(PacketType.STOP, startstop);
    pktrtr.addHandler(PacketType.ACKNOWLEDGE, ackhandler);
    pktrtr.addHandler(PacketType.BROWSE, qbrowserhdlr);
    pktrtr.addHandler(PacketType.GOODBYE, goodbye);
    pktrtr.addHandler(PacketType.REDELIVER, redeliverhdlr);
    pktrtr.addHandler(PacketType.CREATE_DESTINATION, desthandler);
    pktrtr.addHandler(PacketType.DESTROY_DESTINATION, desthandler);
    pktrtr.addHandler(PacketType.VERIFY_DESTINATION, vdhandler);
    pktrtr.addHandler(PacketType.DELIVER, deliverhdlr);
    pktrtr.addHandler(PacketType.START_TRANSACTION, thandler);
    pktrtr.addHandler(PacketType.COMMIT_TRANSACTION, thandler);
    pktrtr.addHandler(PacketType.ROLLBACK_TRANSACTION, thandler);
    pktrtr.addHandler(PacketType.PREPARE_TRANSACTION, thandler);
    pktrtr.addHandler(PacketType.END_TRANSACTION, thandler);
    pktrtr.addHandler(PacketType.RECOVER_TRANSACTION, thandler);
    pktrtr.addHandler(PacketType.SET_CLIENTID, clienthandler);
    pktrtr.addHandler(PacketType.GENERATE_UID, genUIDhandler);
    pktrtr.addHandler(PacketType.MAP_MESSAGE, datahdrl);
    pktrtr.addHandler(PacketType.BYTES_MESSAGE, datahdrl);
    pktrtr.addHandler(PacketType.MESSAGE, datahdrl);
    pktrtr.addHandler(PacketType.MESSAGE_SET, datahdrl);
    pktrtr.addHandler(PacketType.OBJECT_MESSAGE, datahdrl);
    pktrtr.addHandler(PacketType.STREAM_MESSAGE, datahdrl);
    pktrtr.addHandler(PacketType.TEXT_MESSAGE, datahdrl);
    pktrtr.addHandler(PacketType.RESUME_FLOW, flowhdlr);
    pktrtr.addHandler(PacketType.FLOW_PAUSED, fphandler);
    pktrtr.addHandler(PacketType.CREATE_SESSION, sessionhdlr);
    pktrtr.addHandler(PacketType.DELETE_PRODUCER, prodhandler);
    pktrtr.addHandler(PacketType.DESTROY_SESSION, sessionhdlr);
    pktrtr.addHandler(PacketType.PING, pinghandler);
    pktrtr.addHandler(PacketType.INFO_REQUEST, infohandler);
    pktrtr.addHandler(PacketType.VERIFY_TRANSACTION, vthandler);
    // Map message handles -> messages. For the admin service this
    // is just like the regular JMS service except we have a specialized
    // data handler
    admin_pktrtr.addHandler(PacketType.HELLO, hello);
    admin_pktrtr.addHandler(PacketType.AUTHENTICATE, authenticate);
    admin_pktrtr.addHandler(PacketType.GET_LICENSE, getLicense);
    admin_pktrtr.addHandler(PacketType.ADD_CONSUMER, conhdlr);
    admin_pktrtr.addHandler(PacketType.DELETE_CONSUMER, conhdlr);
    admin_pktrtr.addHandler(PacketType.ADD_PRODUCER, prodhandler);
    admin_pktrtr.addHandler(PacketType.START, startstop);
    admin_pktrtr.addHandler(PacketType.STOP, startstop);
    admin_pktrtr.addHandler(PacketType.ACKNOWLEDGE, ackhandler);
    admin_pktrtr.addHandler(PacketType.BROWSE, qbrowserhdlr);
    admin_pktrtr.addHandler(PacketType.GOODBYE, goodbye);
    admin_pktrtr.addHandler(PacketType.REDELIVER, redeliverhdlr);
    admin_pktrtr.addHandler(PacketType.CREATE_DESTINATION, desthandler);
    admin_pktrtr.addHandler(PacketType.DESTROY_DESTINATION, desthandler);
    admin_pktrtr.addHandler(PacketType.VERIFY_DESTINATION, vdhandler);
    admin_pktrtr.addHandler(PacketType.DELIVER, deliverhdlr);
    admin_pktrtr.addHandler(PacketType.START_TRANSACTION, thandler);
    admin_pktrtr.addHandler(PacketType.COMMIT_TRANSACTION, thandler);
    admin_pktrtr.addHandler(PacketType.ROLLBACK_TRANSACTION, thandler);
    admin_pktrtr.addHandler(PacketType.PREPARE_TRANSACTION, thandler);
    admin_pktrtr.addHandler(PacketType.END_TRANSACTION, thandler);
    admin_pktrtr.addHandler(PacketType.RECOVER_TRANSACTION, thandler);
    admin_pktrtr.addHandler(PacketType.SET_CLIENTID, clienthandler);
    admin_pktrtr.addHandler(PacketType.GENERATE_UID, genUIDhandler);
    admin_pktrtr.addHandler(PacketType.MAP_MESSAGE, admin_datahdrl);
    admin_pktrtr.addHandler(PacketType.BYTES_MESSAGE, admin_datahdrl);
    admin_pktrtr.addHandler(PacketType.MESSAGE, admin_datahdrl);
    admin_pktrtr.addHandler(PacketType.MESSAGE_SET, admin_datahdrl);
    admin_pktrtr.addHandler(PacketType.OBJECT_MESSAGE, admin_datahdrl);
    admin_pktrtr.addHandler(PacketType.STREAM_MESSAGE, admin_datahdrl);
    admin_pktrtr.addHandler(PacketType.TEXT_MESSAGE, admin_datahdrl);
    admin_pktrtr.addHandler(PacketType.RESUME_FLOW, flowhdlr);
    admin_pktrtr.addHandler(PacketType.FLOW_PAUSED, fphandler);
    admin_pktrtr.addHandler(PacketType.CREATE_SESSION, sessionhdlr);
    admin_pktrtr.addHandler(PacketType.DELETE_PRODUCER, prodhandler);
    admin_pktrtr.addHandler(PacketType.DESTROY_SESSION, sessionhdlr);
}
Also used : GetLicenseHandler(com.sun.messaging.jmq.jmsserver.common.handlers.GetLicenseHandler) AuthHandler(com.sun.messaging.jmq.jmsserver.common.handlers.AuthHandler) SessionHandler(com.sun.messaging.jmq.jmsserver.common.handlers.SessionHandler) VerifyDestinationHandler(com.sun.messaging.jmq.jmsserver.common.handlers.VerifyDestinationHandler) DestinationHandler(com.sun.messaging.jmq.jmsserver.data.handlers.DestinationHandler) PingHandler(com.sun.messaging.jmq.jmsserver.common.handlers.PingHandler) VerifyTransactionHandler(com.sun.messaging.jmq.jmsserver.data.handlers.VerifyTransactionHandler) GoodbyeHandler(com.sun.messaging.jmq.jmsserver.common.handlers.GoodbyeHandler) ProducerHandler(com.sun.messaging.jmq.jmsserver.data.handlers.ProducerHandler) HelloHandler(com.sun.messaging.jmq.jmsserver.common.handlers.HelloHandler) DataHandler(com.sun.messaging.jmq.jmsserver.data.handlers.DataHandler) AdminDataHandler(com.sun.messaging.jmq.jmsserver.data.handlers.admin.AdminDataHandler) InfoRequestHandler(com.sun.messaging.jmq.jmsserver.common.handlers.InfoRequestHandler) ConsumerHandler(com.sun.messaging.jmq.jmsserver.data.handlers.ConsumerHandler) ClientIDHandler(com.sun.messaging.jmq.jmsserver.common.handlers.ClientIDHandler) VerifyTransactionHandler(com.sun.messaging.jmq.jmsserver.data.handlers.VerifyTransactionHandler) TransactionHandler(com.sun.messaging.jmq.jmsserver.data.handlers.TransactionHandler) VerifyDestinationHandler(com.sun.messaging.jmq.jmsserver.common.handlers.VerifyDestinationHandler) FlowPausedHandler(com.sun.messaging.jmq.jmsserver.common.handlers.FlowPausedHandler) RedeliverHandler(com.sun.messaging.jmq.jmsserver.data.handlers.RedeliverHandler) QBrowseHandler(com.sun.messaging.jmq.jmsserver.data.handlers.QBrowseHandler) GenerateUIDHandler(com.sun.messaging.jmq.jmsserver.common.handlers.GenerateUIDHandler) DeliverHandler(com.sun.messaging.jmq.jmsserver.data.handlers.DeliverHandler) FlowHandler(com.sun.messaging.jmq.jmsserver.common.handlers.FlowHandler) StartStopHandler(com.sun.messaging.jmq.jmsserver.common.handlers.StartStopHandler) AckHandler(com.sun.messaging.jmq.jmsserver.data.handlers.AckHandler)

Example 2 with DataHandler

use of com.sun.messaging.jmq.jmsserver.data.handlers.DataHandler in project openmq by eclipse-ee4j.

the class ProtocolImpl method processMessage.

/**
 * route, store and forward a message
 */
@Override
public void processMessage(IMQConnection con, Packet msg) throws BrokerException, SelectorFormatException, IOException {
    DataHandler handler = (DataHandler) pr.getHandler(PacketType.MESSAGE);
    Destination d = null;
    PacketReference ref = null;
    Set s = null;
    boolean route = false;
    boolean isadmin = con.isAdminConnection();
    List<MessageDeliveryTimeInfo> deliveryDelayReadyList = new ArrayList<>();
    try {
        Destination[] ds = DL.getDestination(con.getPartitionedStore(), msg.getDestination(), msg.getIsQueue());
        d = ds[0];
        if (d == null) {
            throw new BrokerException("Unknown Destination:" + msg.getDestination());
        }
        Producer pausedProducer = handler.checkFlow(msg, con);
        boolean transacted = (msg.getTransactionID() != 0);
        if (DEBUG) {
            logger.log(Logger.INFO, "ProtocolImpl.PROCESS MESSAGE[" + msg + "]TID=" + msg.getTransactionID() + " to destination " + d + ", on conn=@" + con.hashCode() + "[" + con.getConnectionUID() + ", " + con + "]");
        }
        // OK generate a ref. This checks message size and
        // will be needed for later operations
        ref = handler.createReference(msg, d.getDestinationUID(), con, isadmin);
        // dont bother calling route if there are no messages
        // 
        // to improve performance, we route and later forward
        route = handler.queueMessage(d, ref, transacted);
        s = handler.routeMessage(con.getPartitionedStore(), transacted, ref, route, d, deliveryDelayReadyList);
        // handle producer flow control
        handler.pauseProducer(d, pausedProducer, con);
    } catch (BrokerException ex) {
        int status = ex.getStatusCode();
        if (status == Status.ERROR && ref != null && d != null) {
            handler.cleanupOnError(d, ref);
        }
        // rethrow
        throw ex;
    }
    if (route && s != null) {
        try {
            handler.forwardMessage(d, ref, s);
        } catch (Exception e) {
            Object[] emsg = { ref, d.getDestinationUID(), s };
            logger.logStack(Logger.WARNING, Globals.getBrokerResources().getKString(BrokerResources.X_ROUTE_PRODUCED_MSG_FAIL, emsg), e);
        }
    }
    if (deliveryDelayReadyList.size() > 0) {
        MessageDeliveryTimeInfo di = null;
        Iterator<MessageDeliveryTimeInfo> itr = deliveryDelayReadyList.iterator();
        while (itr.hasNext()) {
            di = itr.next();
            di.setDeliveryReady();
        }
    }
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) Set(java.util.Set) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) ArrayList(java.util.ArrayList) DataHandler(com.sun.messaging.jmq.jmsserver.data.handlers.DataHandler) AccessControlException(java.security.AccessControlException) SelectorFormatException(com.sun.messaging.jmq.util.selector.SelectorFormatException) IOException(java.io.IOException) MaxConsecutiveRollbackException(com.sun.messaging.jmq.jmsserver.util.MaxConsecutiveRollbackException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) Producer(com.sun.messaging.jmq.jmsserver.core.Producer) PacketReference(com.sun.messaging.jmq.jmsserver.core.PacketReference) MessageDeliveryTimeInfo(com.sun.messaging.jmq.jmsserver.core.MessageDeliveryTimeInfo)

Aggregations

DataHandler (com.sun.messaging.jmq.jmsserver.data.handlers.DataHandler)2 AuthHandler (com.sun.messaging.jmq.jmsserver.common.handlers.AuthHandler)1 ClientIDHandler (com.sun.messaging.jmq.jmsserver.common.handlers.ClientIDHandler)1 FlowHandler (com.sun.messaging.jmq.jmsserver.common.handlers.FlowHandler)1 FlowPausedHandler (com.sun.messaging.jmq.jmsserver.common.handlers.FlowPausedHandler)1 GenerateUIDHandler (com.sun.messaging.jmq.jmsserver.common.handlers.GenerateUIDHandler)1 GetLicenseHandler (com.sun.messaging.jmq.jmsserver.common.handlers.GetLicenseHandler)1 GoodbyeHandler (com.sun.messaging.jmq.jmsserver.common.handlers.GoodbyeHandler)1 HelloHandler (com.sun.messaging.jmq.jmsserver.common.handlers.HelloHandler)1 InfoRequestHandler (com.sun.messaging.jmq.jmsserver.common.handlers.InfoRequestHandler)1 PingHandler (com.sun.messaging.jmq.jmsserver.common.handlers.PingHandler)1 SessionHandler (com.sun.messaging.jmq.jmsserver.common.handlers.SessionHandler)1 StartStopHandler (com.sun.messaging.jmq.jmsserver.common.handlers.StartStopHandler)1 VerifyDestinationHandler (com.sun.messaging.jmq.jmsserver.common.handlers.VerifyDestinationHandler)1 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)1 MessageDeliveryTimeInfo (com.sun.messaging.jmq.jmsserver.core.MessageDeliveryTimeInfo)1 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)1 Producer (com.sun.messaging.jmq.jmsserver.core.Producer)1 AckHandler (com.sun.messaging.jmq.jmsserver.data.handlers.AckHandler)1 ConsumerHandler (com.sun.messaging.jmq.jmsserver.data.handlers.ConsumerHandler)1