Package org.exolab.jms.messagemgr

Examples of org.exolab.jms.messagemgr.MessageHandle


        Vector handles = _database.getAdapter().getMessageHandles(connection,
                                                                  destination,
                                                                  name);
        Iterator iterator = handles.iterator();
        while (iterator.hasNext()) {
            MessageHandle handle = (MessageHandle) iterator.next();
            String id = handle.getMessageId();
            result.addMessage(id, handle.getDelivered());
        }
        return result;
    }
View Full Code Here


        // first check that the message exists in the list of unacked
        // messages
        boolean exists = false;
        Iterator iterator = _unackedMessages.iterator();
        while (iterator.hasNext()) {
            MessageHandle handle = (MessageHandle) iterator.next();
            if (handle.getConsumerId() == consumerId
                    && handle.getMessageId().equals(messageId)) {
                exists = true;
                break;
            }
        }

        if (exists) {
            // start from the top of the cache and remove each
            // message and then call destroy on it.
            while (!_unackedMessages.isEmpty()) {
                MessageHandle handle
                        = (MessageHandle) _unackedMessages.remove(0);
                handle.destroy();

                // if the handle is equal to the source handle then
                // break the loop
                if (handle.getConsumerId() == consumerId
                    && handle.getMessageId().equals(messageId)) {
                    break;
                }
            }
        }
    }
View Full Code Here

     */
    public void acknowledgeAll() throws JMSException {
        // start from the top of the cache and remove each
        // message and then call destroy on it.
        while (!_unackedMessages.isEmpty()) {
            MessageHandle handle = (MessageHandle) _unackedMessages.remove(0);
            handle.destroy();
        }
    }
View Full Code Here

                    = (MessageHandle[]) _unackedMessages.toArray(
                            new MessageHandle[0]);
            _unackedMessages.clear();

            for (int i = 0; i < handles.length; ++i) {
                MessageHandle handle = handles[i];
                handle.release();
            }
        }
    }
View Full Code Here

                int priority = set.getInt(4);
                long acceptedTime = set.getLong(5);
                long sequenceNumber = set.getLong(6);
                long expiryTime = set.getLong(7);
                boolean delivered = (set.getInt(8) == 0) ? false : true;
                MessageHandle handle = new PersistentMessageHandle(
                        messageId, priority, acceptedTime, sequenceNumber,
                        expiryTime, dest, consumer);
                handle.setDelivered(delivered);
                result.add(handle);
            }
        } catch (SQLException exception) {
            throw new PersistenceException(
                "Failed to get message handles for destination=" +
View Full Code Here

        List messages = new ArrayList(count);

        try {
            _database.begin();
            for (int i = 0; i < count && !_stop.get();) {
                MessageHandle handle = consumer.receive(_stop);
                if (handle == null) {
                    break;
                }
                MessageImpl orig = handle.getMessage();
                if (orig != null) {
                    messages.add(copy(orig, handle));
                    ++i;
                }
            }
View Full Code Here

        return queued;
    }

    private boolean send(ConsumerEndpoint consumer, Condition cancel) {
        boolean sent = false;
        MessageHandle handle = null;
        try {
            _database.begin();
            try {
                synchronized (_removeLock) {
                    _consumerId = consumer.getId();
                }
                handle = consumer.receive(cancel);
                if (handle != null) {
                    MessageImpl message = handle.getMessage();
                    if (message != null) {
                        // send the client a copy.
                        message = copy(message, handle);

                        // clear any wait condition
                        // @todo - possible race condition? Could
                        // syncbronous client timeout and request again,
                        // and this trash subsequent wait?
                        consumer.setWaitingForMessage(null);

                        _sent.preSend(handle);
                        _database.commit();

                        // send the message
                        sent = send(message);

                        if (sent) {
                            _database.begin();
                            _sent.postSend(handle);
                            _database.commit();
                        }
                    }
                } else {
                    _database.commit();
                }
            } finally {
                synchronized (_removeLock) {
                    _consumerId = -1;
                    _removeLock.notify();
                }
            }
        } catch (Exception exception) {
            cleanup(exception.getMessage(), exception);
        }
        if (!sent && handle != null) {
            try {
                _database.begin();
                handle.release();
                _database.commit();
            } catch (Exception exception) {
                cleanup("Failed to release unsent message", exception);
            }
        }
View Full Code Here

        }

        MessageImpl message = null;
        try {
            _database.begin();
            MessageHandle handle = consumer.receive(cancel);

            if (handle != null) {
                // retrieve the message and copy it
                message = handle.getMessage();
                if (message != null) {
                    message = copy(message, handle);
                }
            }
            if (message == null) {
View Full Code Here


        for (int i = 0; i < messages.length; ++i) {
            MessageImpl msg = messages[i];
            addMessage(msg, _queue1);
            MessageHandle handle = new PersistentMessageHandle(msg,
                                                               _queue1.getName());
            _adapter.addMessageHandle(_connection, handle);

            addMessage(msg, _topic1);
            handle = new PersistentMessageHandle(msg, "sub1");
View Full Code Here

TOP

Related Classes of org.exolab.jms.messagemgr.MessageHandle

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.