Package org.exolab.jms.client

Examples of org.exolab.jms.client.JmsDestination


    private void add(Consumer consumer, Subscription subscription)
            throws JMSException, PersistenceException {

        String name = consumer.getName();
        JmsDestination destination = subscription.getDestination();
        Iterator iterator = subscription.getMessages().iterator();
        PersistenceAdapter adapter = _database.getAdapter();
        Connection connection = _database.getConnection();

        if (!consumer.isQueueConsumer()) {
            adapter.addDurableConsumer(connection, destination.getName(), name);

        }

        while (iterator.hasNext()) {
            MessageState state = (MessageState) iterator.next();
View Full Code Here


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

        for (Iterator i = destinations.iterator(); i.hasNext();) {
            JmsDestination destination = (JmsDestination) i.next();
            if (destination.getPersistent()) {
                try {
                    ContextHelper.rebind(context, destination.getName(),
                                         destination);
                } catch (NamingException exception) {
                    throw new ServiceException("Failed to add destination "
                                               + destination.getName()
                                               + " to JNDI", exception);
                }
            }
        }
View Full Code Here

    // implementation of PersistenceAdapter.addDestination
    public void addDestination(Connection connection, String name,
                               boolean queue)
            throws PersistenceException {

        JmsDestination destination = (queue)
                ? (JmsDestination) new JmsQueue(name)
                : (JmsDestination) new JmsTopic(name);

        // create the destination. If the destination is also
        // a queue create a special consumer for it.
View Full Code Here

    // implementation of PersistenceAdapter.removeDestination
    public void removeDestination(Connection connection, String name)
            throws PersistenceException {

        JmsDestination destination = _destinations.get(name);
        if (destination != null) {
            try {
                _destinationLock.writeLock().acquire();
                _destinations.remove(connection, destination);
            } catch (InterruptedException exception) {
View Full Code Here

     */
    public void importCollection(StoreIterator iterator) throws JMSException,
            PersistenceException {
        Connection connection = _database.getConnection();
        while (iterator.hasNext()) {
            JmsDestination destination = (JmsDestination) iterator.next();
            String name = destination.getName();
            boolean queue = false;
            if (destination instanceof JmsQueue) {
                queue = true;
            }

View Full Code Here

     */
    public synchronized void add(Connection connection, String dest,
                                 String consumer)
            throws PersistenceException {

        JmsDestination destination = null;
        long destinationId = 0;

        synchronized (_destinations) {
            destination = _destinations.get(dest);
            if (destination == null) {
View Full Code Here

        HashMap result = new HashMap();

        Iterator iter = _consumers.values().iterator();
        while (iter.hasNext()) {
            Consumer map = (Consumer) iter.next();
            JmsDestination dest = _destinations.get(map.destinationId);

            if (dest instanceof JmsTopic) {
                result.put(map.name, dest.getName());
            }
        }

        return result;
    }
View Full Code Here

            // iterate through the result set and construct the corresponding
            // MessageHandles
            set = select.executeQuery();
            while (set.next()) {
                // Attempt to retrieve the corresponding destination
                JmsDestination dest = _destinations.get(set.getLong(2));
                if (dest == null) {
                    throw new PersistenceException(
                        "Cannot create persistent handle, because " +
                        "destination mapping failed for " + set.getLong(2));
                }
View Full Code Here

        destinations = _database.getAdapter().getAllDestinations(connection);

        HashMap consumers = new HashMap();

        while (destinations.hasMoreElements()) {
            JmsDestination destination =
                    (JmsDestination) destinations.nextElement();
            if (destination instanceof JmsTopic) {
                Enumeration names = _database.getAdapter().getDurableConsumers(
                        connection, destination.getName());
                while (names.hasMoreElements()) {
                    String name = (String) names.nextElement();
                    Consumer consumer = (Consumer) consumers.get(name);
                    if (consumer == null) {
                        consumer = new Consumer(name, null);
                        consumers.put(name, consumer);
                    }
                    Subscription subscription = getSubscription(name,
                                                                destination);
                    consumer.addSubscription(subscription);
                }
            } else {
                final String name = destination.getName();
                Consumer consumer = (Consumer) consumers.get(name);
                if (consumer == null) {
                    consumer = new Consumer((JmsQueue) destination);
                    consumers.put(name, consumer);
                }
View Full Code Here

                    "select name, isqueue, destinationid from destinations");

            set = select.executeQuery();
            String name = null;
            boolean isQueue = false;
            JmsDestination destination = null;
            long Id = 0;
            while (set.next()) {
                name = set.getString(1);
                isQueue = set.getBoolean(2);
                destination = (isQueue)
                        ? (JmsDestination) new JmsQueue(name)
                        : (JmsDestination) new JmsTopic(name);
                Id = set.getLong(3);
                destination.setPersistent(true);
                cache(destination, Id);
            }
        } catch (Exception exception) {
            throw new PersistenceException("Failed to load destinations",
                                           exception);
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.