Package org.codehaus.activemq.message

Examples of org.codehaus.activemq.message.ActiveMQMessage


     */
    public Message receiveNoWait() throws JMSException {
        checkClosed();
        session.setSessionConsumerDispatchState(ActiveMQSession.CONSUMER_DISPATCH_SYNC);
        try {
            ActiveMQMessage message = (ActiveMQMessage) messageQueue.dequeueNoWait();
            if (message != null) {
                messageDelivered(message, true);
                return message.shallowCopy();
            }
        }
        catch (InterruptedException ioe) {
            throw new JMSException("Queue is interrupted: " + ioe.getMessage());
        }
View Full Code Here


        // Get a connection and pull the message out of the DB
        Connection c = null;
        try {
            c = persistenceAdapter.getConnection();           
            byte data[] = adapter.doGetMessage(c, id);
            ActiveMQMessage answer = (ActiveMQMessage) wireFormat.fromBytes(data);;
            answer.setJMSMessageIdentity(identity);
            return answer;           
        } catch (IOException e) {
            throw JMSExceptionHelper.newJMSException("Failed to broker message: " + identity.getMessageID() + " in container: " + e, e);
        } catch (SQLException e) {
            throw JMSExceptionHelper.newJMSException("Failed to broker message: " + identity.getMessageID() + " in container: " + e, e);
View Full Code Here

                                log.warn("Strange result when iterating to end of collection: " + status);
                            }
                            break;
                        }

                        ActiveMQMessage message = extractMessage(valueEntry);
                        subscription.addMessage(getContainer(), message);
                    }
                }
            }
        }
View Full Code Here

     */
    public void unregisterMessageInterest(MessageIdentity messageIdentity, MessageAck ack) {
    }

    public ActiveMQMessage poll() throws JMSException {
        ActiveMQMessage message = null;
        MessageIdentity messageIdentity=null;
      synchronized( this ) {
          messageIdentity = (MessageIdentity) messagesToBeDelivered.removeFirst();
          if (messageIdentity != null) {
              deliveredMessages.add(messageIdentity);
View Full Code Here

        }
        return message;
    }

    public ActiveMQMessage peekNext(MessageIdentity messageID) throws JMSException {
      ActiveMQMessage answer = null;
      MessageIdentity identity = null;
      synchronized( this ) {
            if (messageID == null) {
              identity = (MessageIdentity) messagesToBeDelivered.getFirst();
            }
View Full Code Here

        try {
            c = persistenceAdapter.getConnection();
            adapter.doRecoverSubscription(c, subscription.getPersistentKey(), destinationName, new MessageListResultHandler() {
                public void onMessage(long seq, String messageID) throws JMSException {
                    MessageIdentity messageIdentity = new MessageIdentity(messageID, new Long(seq));
                    ActiveMQMessage message = getMessage(messageIdentity);
                    subscription.addMessage(container, message);
                }
            });
        }
        catch (SQLException e) {
View Full Code Here

    private void doPeek(QueueMessageContainer container, QueueList browsers) throws JMSException {
        if (browsers != null && browsers.size() > 0) {
            for (int i = 0; i < browsers.size(); i++) {
                SubscriptionImpl sub = (SubscriptionImpl) browsers.get(i);
                int count = 0;
                ActiveMQMessage msg = null;
                do {
                    msg = container.peekNext(sub.getLastMessageIdentity());
                    if (msg != null) {
                        if (sub.isTarget(msg)) {
                            sub.addMessage(container, msg);
                            dispatcher.wakeup(sub);
                        }
                        else {
                            sub.setLastMessageIdentifier(msg.getJMSMessageIdentity());
                        }
                    }
                }
                while (msg != null && !sub.isAtPrefetchLimit() && count++ < MAX_MESSAGES_DISPATCHED_FROM_POLL);
            }
View Full Code Here

        }
    }

    private void doPoll(QueueMessageContainer container, QueueList subList) throws JMSException {
        int count = 0;
        ActiveMQMessage msg = null;
        if (subList != null && subList.size() > 0) {
            do {
                boolean dispatched = false;
                msg = container.poll();
                if (msg != null) {
                    QueueListEntry entry = subList.getFirstEntry();
                    boolean targeted = false;
                    while (entry != null) {
                        SubscriptionImpl sub = (SubscriptionImpl) entry.getElement();
                        if (sub.isTarget(msg)) {
                            targeted = true;
                            if (!sub.isAtPrefetchLimit()) {
                                sub.addMessage(container, msg);
                                dispatched = true;
                                dispatcher.wakeup(sub);
                                subList.rotate(); //round-robin the list
                                break;
                            }
                        }
                        entry = subList.getNextEntry(entry);
                    }
                    if (!dispatched) {
                        if (targeted) { //ie. it can be selected by current active consumers - but they are at
                            // pre-fectch
                            // limit
                            container.returnMessage(msg.getJMSMessageIdentity());
                        }
                        break;
                    }
                }
            }
View Full Code Here

            }
        });
    }

    protected void doAddMessage(int i) throws JMSException {
        final ActiveMQMessage message = getMessage(i);
        template.run(new Callback() {
            public void execute() throws Throwable {
                container.addMessage(message);
            }
        });
View Full Code Here

    }

    protected void dumpMessageIdentities(String text) throws JMSException {
        System.out.println("#### Dumping identities at: " + text);
        for (int i = 0; i < publishMessageCount; i++) {
            ActiveMQMessage message = getMessage(i);
            MessageIdentity identity = message.getJMSMessageIdentity();
            Object sequenceNo = identity.getSequenceNumber();
            String sequenceText = null;
            if (sequenceNo != null) {
                sequenceText = sequenceNo.toString();
                if (sequenceNo instanceof DatabaseEntry) {
View Full Code Here

TOP

Related Classes of org.codehaus.activemq.message.ActiveMQMessage

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.