Package org.exolab.jms.message

Examples of org.exolab.jms.message.MessageImpl


     * @return the associated message, or <code>null</code> if none exists
     * @throws JMSException for any error
     */
    public synchronized MessageImpl getMessage(MessageRef reference)
            throws JMSException {
        MessageImpl message;
        final String messageId = reference.getMessageId();

        if (reference.isPersistent()) {
            message = (MessageImpl) _persistent.get(messageId);

            // if the message is not cached then try and retrieve it from the
            // database and cache it.
            if (message == null) {
                // fault in at least the next message from the database
                try {
                    DatabaseService service = DatabaseService.getInstance();
                    PersistenceAdapter adapter = service.getAdapter();
                    Connection connection = service.getConnection();
                    message = adapter.getMessage(connection, messageId);
                } catch (PersistenceException exception) {
                    final String msg = "Failed to retrieve message";
                    _log.error(msg, exception);
                    throw new JMSException(msg + ": " + exception.getMessage());
                }
                // add the message to the persistent cache once it has been
                // retrieved from the datastore
                if (message != null) {
                    _persistent.put(messageId, message);
                }
            }
        } else {
            message = (MessageImpl) _transient.get(messageId);
        }

        if (message != null && !message.getReadOnly()) {
            // mark the message as read-only
            message.setReadOnly(true);
        }

        return message;
    }
View Full Code Here


        } else {
            // for non null selector we must find the first matching
            MessageHandle[] handles = _handles.toArray();
            for (int i = 0; i < handles.length && !cancel.get(); ++i) {
                MessageHandle hdl = handles[i];
                MessageImpl message = hdl.getMessage();
                if (message != null && selector.selects(message)) {
                    handle = (QueueConsumerMessageHandle) hdl;
                    _handles.remove(handle);
                    break;
                }
View Full Code Here

    public void playbackMessages(QueueBrowserEndpoint browser)
            throws JMSException {
        MessageHandle[] handles = _handles.toArray();
        for (int i = 0; i < handles.length; ++i) {
            MessageHandle handle = handles[i];
            MessageImpl message = handle.getMessage();
            if (message != null) {
                browser.messageAdded(handle, message);
            }
        }
    }
View Full Code Here

     */
    public void returnMessageHandle(MessageHandle handle) {
        // add the message to the destination cache
        _handles.add(handle);
        try {
            MessageImpl message = handle.getMessage();
            if (message != null) {
                // if there are any registered consumers, notify one of them
                // that a message has arrived
                ConsumerEndpoint consumer = getConsumerForMessage(message);
                if (consumer != null) {
View Full Code Here

    protected MessageHandle doReceive(Condition cancel) throws JMSException {
        MessageHandle result = null;
        MessageHandle handle;
        while (!cancel.get() && (handle = _handles.removeFirst()) != null) {
            // ensure the message still exists
            MessageImpl message = handle.getMessage();
            if (message != null) {
                if (selects(message)) {
                    result = handle;
                    // got a message which is applicable for the endpoint
                    break;
View Full Code Here

     *
     * @return a new message
     * @throws JMSException for any JMS error
     */
    protected Message newMessage() throws JMSException {
        return new MessageImpl();
    }
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.