Package org.exolab.jms.message

Examples of org.exolab.jms.message.MessageImpl


        }

        while (iterator.hasNext()) {
            MessageState state = (MessageState) iterator.next();
            MessageImpl message = adapter.getMessage(connection,
                                                     state.getMessageId());
            PersistentMessageHandle handle =
                    new PersistentMessageHandle(message.getJMSMessageID(),
                                                message.getJMSPriority(),
                                                message.getAcceptedTime(),
                                                message.getSequenceNumber(),
                                                message.getJMSExpiration(),
                                                destination,
                                                name);
            handle.setDelivered(state.getDelivered());
            handle.add();
        }
View Full Code Here


     */
    public void importCollection(StoreIterator iterator)
            throws JMSException, PersistenceException {
        Connection connection = _database.getConnection();
        while (iterator.hasNext()) {
            MessageImpl message = (MessageImpl) iterator.next();
            _database.getAdapter().addMessage(connection, message);
        }
        _database.commit();
    }
View Full Code Here

        public boolean hasNext() {
            return _iterator.hasNext();
        }

        public Object next() throws PersistenceException {
            MessageImpl result = null;

            String id = (String) _iterator.next();

            Connection connection = _database.getConnection();
            result = _database.getAdapter().getMessage(connection, id);
View Full Code Here

     * @param consumerId the consumer identifier
     * @return the next message or <code>null</code> if none is available
     * @throws JMSException for any JMS error
     */
    public MessageImpl receiveNoWait(long consumerId) throws JMSException {
        MessageImpl result = null;
        if (!_stop.get()) {
            result = doReceive(consumerId, null);
        }
        return result;
    }
View Full Code Here

     *                   </code> indicates to wait indefinitely
     * @return the next message or <code>null</code> if none is available
     * @throws JMSException for any JMS error
     */
    public MessageImpl receive(long consumerId, long wait) throws JMSException {
        MessageImpl result = null;
        Condition condition;
        if (wait > 0) {
            condition = TimedCondition.before(wait);
        } else {
            condition = new Flag(true);
View Full Code Here

            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

                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
View Full Code Here

            };
        } else {
            cancel = _stop;
        }

        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) {
                // no message available. Mark the consumer as (possibly) waiting
                // for a message.
                consumer.setWaitingForMessage(wait);
            } else {
                // clear any wait condition
                consumer.setWaitingForMessage(null);

                // if we have a non-null message then add it to the sent message
                // cache. Additionally, if we are part of a global transaction
                // then we must also send it to the ResourceManager for recovery.
                _sent.preSend(handle);
            }
            _database.commit();
        } catch (Exception exception) {
            rethrow(exception.getMessage(), exception);
        }
        if (_log.isDebugEnabled()) {
            if (message != null) {
                _log.debug("doReceive(consumerId=" + consumerId +
                        ") -> JMSMesssageID=" + message.getMessageId());
            }
        }

        return message;
    }
View Full Code Here

     * @return a copy of the message
     * @throws JMSException if the copy fails
     */
    private MessageImpl copy(MessageImpl message, MessageHandle handle)
            throws JMSException {
        MessageImpl result;
        try {
            result = (MessageImpl) message.clone();
            result.setJMSRedelivered(handle.getDelivered());
            result.setConsumerId(handle.getConsumerId());
        } catch (JMSException exception) {
            throw exception;
        } catch (CloneNotSupportedException exception) {
            _log.error(exception, exception);
            throw new JMSException(exception.getMessage());
View Full Code Here

            throw new JMSException("Argument 'messages' is null");
        }

        Iterator iterator = messages.iterator();
        while (iterator.hasNext()) {
            MessageImpl message = (MessageImpl) iterator.next();
            send(message);
        }
    }
View Full Code Here

TOP

Related Classes of org.exolab.jms.message.MessageImpl

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.