Search in sources :

Example 21 with Destination

use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.

the class DestinationManagerMonitor method getDestinations.

public ObjectName[] getDestinations() throws MBeanException {
    List dests = DestinationUtil.getVisibleDestinations();
    if (dests.size() == 0) {
        return (null);
    }
    ObjectName[] destONames = new ObjectName[dests.size()];
    for (int i = 0; i < dests.size(); i++) {
        Destination d = (Destination) dests.get(i);
        try {
            ObjectName o = MQObjectName.createDestinationMonitor(d.isQueue() ? DestinationType.QUEUE : DestinationType.TOPIC, d.getDestinationName());
            destONames[i] = o;
        } catch (Exception e) {
            handleOperationException(DestinationOperations.GET_DESTINATIONS, e);
        }
    }
    return (destONames);
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) List(java.util.List) MBeanException(javax.management.MBeanException) ObjectName(javax.management.ObjectName)

Example 22 with Destination

use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.

the class DestinationManagerConfig method getDestinations.

public ObjectName[] getDestinations() throws MBeanException {
    List dests = DestinationUtil.getVisibleDestinations();
    if (dests.size() == 0) {
        return (null);
    }
    ObjectName[] destONames = new ObjectName[dests.size()];
    for (int i = 0; i < dests.size(); i++) {
        Destination d = (Destination) dests.get(i);
        try {
            ObjectName o = MQObjectName.createDestinationConfig(d.isQueue() ? DestinationType.QUEUE : DestinationType.TOPIC, d.getDestinationName());
            destONames[i] = o;
        } catch (Exception e) {
            handleOperationException(DestinationOperations.GET_DESTINATIONS, e);
        }
    }
    return (destONames);
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) AttributeList(javax.management.AttributeList) List(java.util.List) MBeanException(javax.management.MBeanException) PropertyUpdateException(com.sun.messaging.jmq.jmsserver.config.PropertyUpdateException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) ObjectName(javax.management.ObjectName)

Example 23 with Destination

use of com.sun.messaging.jmq.jmsserver.core.Destination 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)

Example 24 with Destination

use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.

the class GetMetricsHandler method handle.

/**
 * Handle the incomming administration message.
 *
 * @param con The Connection the message came in on.
 * @param cmd_msg The administration message
 * @param cmd_props The properties from the administration message
 */
@Override
public boolean handle(IMQConnection con, Packet cmd_msg, Hashtable cmd_props) {
    if (DEBUG) {
        logger.log(Logger.DEBUG, this.getClass().getName() + ": " + cmd_props);
    }
    int status = Status.OK;
    String errMsg = null;
    String service = (String) cmd_props.get(MessageType.JMQ_SERVICE_NAME);
    String destination = (String) cmd_props.get(MessageType.JMQ_DESTINATION);
    Integer type = (Integer) cmd_props.get(MessageType.JMQ_DEST_TYPE);
    Object replyobj = null;
    String msgtype = null;
    if (destination != null) {
        try {
            Destination[] ds = DL.getDestination(null, destination, DestType.isQueue((type == null ? 0 : type.intValue())));
            // PART
            Destination d = ds[0];
            if (d == null) {
                status = Status.NOT_FOUND;
                int mytype = (type == null ? 0 : type.intValue());
                errMsg = rb.getString(rb.E_NO_SUCH_DESTINATION, getDestinationType(mytype), destination);
            } else {
                replyobj = d.getMetrics();
            }
        } catch (Exception ex) {
            int mytype = (type == null ? 0 : type.intValue());
            errMsg = rb.getString(rb.E_NO_SUCH_DESTINATION, getDestinationType(mytype), destination);
            status = Status.ERROR;
            // log the error
            logger.logStack(Logger.ERROR, rb.E_INTERNAL_BROKER_ERROR, this.getClass().getName() + ": failed to get destination (" + DestType.toString(mytype) + ":" + destination + ")", ex);
        }
        msgtype = "DESTINATION";
    } else {
        ServiceManager sm = Globals.getServiceManager();
        MetricManager mm = Globals.getMetricManager();
        MetricCounters mc = null;
        if (service != null && sm.getServiceType(service) == ServiceType.UNKNOWN) {
            status = Status.NOT_FOUND;
            errMsg = rb.getString(rb.X_NO_SUCH_SERVICE, service);
        } else {
            // If service is null getMetricCounters() will get counters
            // for all services
            mc = mm.getMetricCounters(service);
            if (service != null) {
                msgtype = "SERVICE";
            }
            replyobj = mc;
        }
    }
    // Send reply
    Packet reply = new Packet(con.useDirectBuffers());
    reply.setPacketType(PacketType.OBJECT_MESSAGE);
    Hashtable pr = new Hashtable();
    if (msgtype != null) {
        pr.put(MessageType.JMQ_BODY_TYPE, msgtype);
    }
    setProperties(reply, MessageType.GET_METRICS_REPLY, status, errMsg, pr);
    if (replyobj != null) {
        setBodyObject(reply, replyobj);
    }
    parent.sendReply(con, cmd_msg, reply);
    return true;
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) MetricManager(com.sun.messaging.jmq.jmsserver.service.MetricManager) ServiceManager(com.sun.messaging.jmq.jmsserver.service.ServiceManager) MetricCounters(com.sun.messaging.jmq.util.MetricCounters) Hashtable(java.util.Hashtable)

Example 25 with Destination

use of com.sun.messaging.jmq.jmsserver.core.Destination in project openmq by eclipse-ee4j.

the class DestinationListStore method clearAll.

/**
 * Clear all destinations
 */
void clearAll(boolean sync, boolean clearMessages) {
    if (Store.getDEBUG()) {
        logger.log(logger.DEBUGHIGH, "DestinationList.clearAll(" + clearMessages + ") called");
    }
    if (clearMessages) {
        Iterator itr = dstMap.values().iterator();
        while (itr.hasNext()) {
            Destination dst = (Destination) itr.next();
            DestinationUID dstuid = dst.getDestinationUID();
            try {
                parent.getMsgStore().releaseMessageDir(dstuid, sync);
            } catch (IOException | BrokerException e) {
                // log error and continue
                logger.log(logger.ERROR, br.X_RELEASE_MSGFILE_FAILED, parent.getMsgStore().getDirName(dstuid), dstuid, e);
            }
        }
    }
    dstMap.clear();
    if (sync) {
        try {
            sync();
        } catch (BrokerException e) {
            logger.log(logger.ERROR, "Got exception while synchronizing data to disk", e);
        }
    }
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID)

Aggregations

Destination (com.sun.messaging.jmq.jmsserver.core.Destination)76 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)39 Iterator (java.util.Iterator)29 DestinationUID (com.sun.messaging.jmq.jmsserver.core.DestinationUID)25 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)25 ConsumerUID (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)20 SelectorFormatException (com.sun.messaging.jmq.util.selector.SelectorFormatException)18 HashMap (java.util.HashMap)18 Consumer (com.sun.messaging.jmq.jmsserver.core.Consumer)17 IOException (java.io.IOException)16 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)15 ArrayList (java.util.ArrayList)12 List (java.util.List)11 Packet (com.sun.messaging.jmq.io.Packet)9 AckEntryNotFoundException (com.sun.messaging.jmq.jmsserver.util.AckEntryNotFoundException)9 Map (java.util.Map)9 DestinationList (com.sun.messaging.jmq.jmsserver.core.DestinationList)8 SizeString (com.sun.messaging.jmq.util.SizeString)8 PartitionedStore (com.sun.messaging.jmq.jmsserver.persist.api.PartitionedStore)7 ConsumerAlreadyAddedException (com.sun.messaging.jmq.jmsserver.util.ConsumerAlreadyAddedException)7