Package org.exolab.jms.client

Examples of org.exolab.jms.client.JmsDestination


     */
    public int getDurableConsumerMessageCount(String topic, String name) {
        int count = -1;
        try {
            // first see if the cache is loaded in memory
            JmsDestination dest = _destinations.getDestination(topic);
            ConsumerEndpoint endpoint = null;
            if ((dest != null)
                    && ((name != null)
                    || (name.length() > 0))) {

                endpoint = _consumers.getConsumerEndpoint(name);
                if ((endpoint != null)
                        && (endpoint.getDestination().equals(dest))) {
                    // retrieve the number of handles for the endpoint, which
                    // reflects the number of messages
                    count = endpoint.getMessageCount();
                } else {
                    // there is no cache with this name stored in memory. If
                    // this is an administered destination then read the count
                    //  directly from the database.
                    if (dest.getPersistent()) {
                        try {
                            _database.begin();
                            Connection connection = _database.getConnection();
                            count = _database.getAdapter().
                                    getDurableConsumerMessageCount(connection, topic,
View Full Code Here


    public int getQueueMessageCount(String queue) {
        int count = -1;

        try {
            // first see if the cache is loaded in memory
            JmsDestination dest = _destinations.getDestination(queue);
            DestinationCache cache = null;
            if (dest != null) {
                _database.begin();
                cache = _destinations.getDestinationCache(dest);
                // retrieve the number of handles for the cache, which
View Full Code Here

    public boolean addDestination(String name, Boolean queue) {

        boolean success = false;

        // create the appropriate destination object
        JmsDestination destination = (queue.booleanValue())
                ? (JmsDestination) new JmsQueue(name)
                : (JmsDestination) new JmsTopic(name);
        destination.setPersistent(true);

        // create the administered destination
        try {
            if (_destinations.getDestination(name) == null) {
                _destinations.createDestination(destination);
View Full Code Here

     * @return boolean             true if successful
     */
    public boolean removeDestination(String name) {

        boolean success = false;
        JmsDestination dest = _destinations.getDestination(name);

        // ensure that the destination actually translates to a valid
        // object.
        if (dest != null) {
            try {
View Full Code Here

     * @param name - the name of the destination to check
     * @return boolean - true if it does and false otherwise
     */
    public boolean destinationExists(String name) {

        JmsDestination dest = _destinations.getDestination(name);
        return (dest != null);
    }
View Full Code Here

     *         <code>false</code>
     */
    public boolean canDestroy() {
        boolean destroy = false;
        if (!hasConsumers()) {
            JmsDestination queue = getDestination();
            if (queue.getPersistent() && getMessageCount() == 0) {
                destroy = true;
            } else if (queue.isTemporaryDestination()) {
                // check if there is a corresponding connection. If
                // not, it has been closed, and the cache can be removed
                long connectionId =
                        ((JmsTemporaryDestination) queue).getConnectionId();
                if (_connections.getConnection(connectionId) == null) {
View Full Code Here

     * locally.
     *
     * @throws JMSException if the cache can't be initialised
     */
    protected void init() throws JMSException {
        JmsDestination queue = getDestination();

        List handles;
        DatabaseService service = null;
        try {
            service = DatabaseService.getInstance();
            Connection connection = service.getConnection();
            service.getAdapter().removeExpiredMessageHandles(connection,
                    queue.getName());
            handles = service.getAdapter().getMessageHandles(connection, queue,
                    queue.getName());
        } catch (PersistenceException exception) {
            _log.error(exception, exception);
            try {
                if (service != null) {
                    service.rollback();
View Full Code Here

        HashMap result = new HashMap();

        synchronized (_lock) {
            Iterator iter = _caches.keySet().iterator();
            while (iter.hasNext()) {
                JmsDestination dest = (JmsDestination) iter.next();
                if ((dest instanceof JmsTopic) &&
                        (topic.match((JmsTopic) dest))) {
                    result.put(dest, _caches.get(dest));
                }
            }
View Full Code Here

        synchronized (_lock) {
            JmsDestination[] destinations
                    = (JmsDestination[]) _destinations.values().toArray(
                            new JmsDestination[0]);
            for (int i = 0; i < destinations.length; ++i) {
                JmsDestination dest = destinations[i];
                if (!dest.getPersistent() && !_caches.containsKey(dest)) {
                    gcDestinations++;
                    _destinations.remove(dest.getName());
                }
            }

            // log the information
            _log.info("DMGC Collected " + gcCaches + " caches, "
View Full Code Here

            throw new ServiceException("Failed to get destinations", exception);
        }

        while (iter.hasMoreElements()) {
            // add each destination to the cache
            JmsDestination dest = (JmsDestination) iter.nextElement();
            addToDestinations(dest);
        }
    }
View Full Code Here

TOP

Related Classes of org.exolab.jms.client.JmsDestination

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.