Package org.codehaus.activemq.message

Examples of org.codehaus.activemq.message.ActiveMQMessage


            Filter filter = getFilterFactory().createFilter(consumer.getDestination(), consumer.getMessageSelector());
            if (consumer.isNoLocal()) {
                filter = new AndFilter(filter, new NoLocalFilter(clientID));
            }
            for (Iterator i = transientConsumedRedeliverCache.iterator(); i.hasNext();){
                ActiveMQMessage message = (ActiveMQMessage)i.next();
                if (filter.matches(message)){
                    transientConsumedRedeliverCache.remove(message);
                    message.setMessageAcknowledge(session);
                    message.setJMSRedelivered(true);
                    message.setConsumerNos(new int[]{consumer.getConsumerNumber()});
                    consumer.processMessage(message);
                }
            }
        }
    }
View Full Code Here


        try {
            c = persistenceAdapter.getConnection();
            adapter.doRecoverSubscription(c, destinationName, subscription.getPersistentKey(), 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

        }
    }

    public ActiveMQMessage getMessage(MessageIdentity identity) throws JMSException {
        checkClosed();
        ActiveMQMessage answer = null;
        String messageID = identity.getMessageID();
        try {
            DatabaseEntry key = createKey(messageID);
            DatabaseEntry value = new DatabaseEntry();
            if (database.get(null, key, value, null) == OperationStatus.SUCCESS) {
View Full Code Here

     * Receives the next message that arrives within the specified timeout interval.
     * @throws JMSException
     */
    public ActiveMQMessage receive(long timeout) throws JMSException {
        try {
            ActiveMQMessage message = (ActiveMQMessage) messageQueue.dequeue(timeout);
            return message;
        }
        catch (InterruptedException ioe) {
            return null;
        }
View Full Code Here

    protected void removeExpiredMessages() {
        long currentTime = System.currentTimeMillis();
        List list = queue.getContents();
        for (int i = 0;i < list.size();i++) {
            ActiveMQMessage msg = (ActiveMQMessage) list.get(i);
            if (msg.isExpired(currentTime)) {
                queue.remove(msg);
                if (log.isDebugEnabled()) {
                    log.debug("expired message: " + msg);
                }
            }
View Full Code Here

    /**
     * @param ack
     * @throws JMSException
     */
    private void doAcknowledgeMessage(TransientQueueSubscription ts, MessageAck ack) throws JMSException {
        ActiveMQMessage message = ts.acknowledgeMessage(ack.getMessageID());
        if (message != null && (!ack.isMessageRead() || ack.isExpired())) {
            message.setJMSRedelivered(true);
            if (message.incrementDeliveryCount() >= redeliveryPolicy.getMaximumRetryCount()) {
                if (log.isDebugEnabled()){
                    log.debug("Message: " + message + " has exceeded its retry count");
                }
                deadLetterPolicy.sendToDeadLetter(message);
            }
            else if (ack.isExpired()) {
                if (log.isDebugEnabled()){
                    log.debug("Message: " + message + " has expired");
                }
                deadLetterPolicy.sendToDeadLetter(message);
            }
            else {
                Set set = destinationMap.get(message.getJMSActiveMQDestination());
                for (Iterator i = set.iterator();i.hasNext();) {
                    TransientQueueBoundedMessageContainer container = (TransientQueueBoundedMessageContainer) i
                            .next();
                    container.enqueueFirst(message);
                    break;
View Full Code Here

     * @param client
     * @param ack
     * @throws JMSException
     */
    private void redeliverMessage(TransientQueueSubscription ts, MessageAck ack) throws JMSException {
        ActiveMQMessage message = ts.acknowledgeMessage(ack.getMessageID());
        if (message != null) {
            message.setJMSRedelivered(true);
            Set set = destinationMap.get(message.getJMSActiveMQDestination());
            for (Iterator i = set.iterator();i.hasNext();) {
                TransientQueueBoundedMessageContainer container = (TransientQueueBoundedMessageContainer) i.next();
                container.enqueueFirst(message);
                break;
            }
View Full Code Here

                TransactionManager.getContexTransaction().addPostCommitTask(new TransactionTask(){
                    public void execute() throws Throwable {
                        messagePtrs.remove(theEntry);
                        if ((ack.isExpired() || ack.isMessageRead()) && !browser) {
                            if (ack.isExpired() && !pointer.getContainer().isDeadLetterQueue()) {
                                ActiveMQMessage msg = pointer.getContainer().getMessage(pointer.getMessageIdentity());
                                if (msg != null) {
                                    deadLetterPolicy.sendToDeadLetter(msg);
                                }
                            }
                        }
View Full Code Here

        List tmpList = new ArrayList();
        QueueListEntry entry = messagePtrs.getFirstEntry();
        while (entry != null) {
            MessagePointer pointer = (MessagePointer) entry.getElement();
            if (!pointer.isDispatched()) {
                ActiveMQMessage msg = pointer.getContainer().getMessage(pointer.getMessageIdentity());
                if (msg != null) {
                    if (pointer.isDispatched() || pointer.isRedelivered()) {
                        //already dispatched - so mark as redelivered
                        msg.setJMSRedelivered(true);
                        if (redeliveryPolicy.isBackOffMode()
                                && msg.getDeliveryCount() < redeliveryPolicy.getMaximumRetryCount()) {
                            long sleepTime = redeliveryPolicy.getInitialRedeliveryTimeout();
                            sleepTime *= (msg.getDeliveryCount() * redeliveryPolicy.getBackOffIncreaseRate());
                            try {
                                Thread.sleep(sleepTime);
                            }
                            catch (InterruptedException e) {
                            }
                        }
                        //incremenent delivery count
                        msg.incrementDeliveryCount();
                    }
                    if (!pointer.getContainer().isDeadLetterQueue()
                            && (msg.isExpired() || msg.getDeliveryCount() >= redeliveryPolicy.getMaximumRetryCount())) {
                        if (msg.isExpired()) {
                            log.warn("Message: " + msg + " has expired");
                        }
                        else {
                            log.warn("Message: " + msg + " exceeded retry count: " + msg.getDeliveryCount());
                        }
                        deadLetterPolicy.sendToDeadLetter(msg);
                        QueueListEntry discarded = entry;
                        entry = messagePtrs.getPrevEntry(discarded);
                        messagePtrs.remove(discarded);
                    }
                    else {
                        pointer.setDispatched(true);
                        msg.setDispatchedFromDLQ(pointer.getContainer().isDeadLetterQueue());
                        tmpList.add(msg);
                    }
                }
                else {
                    //the message is probably expired
View Full Code Here

        int count = 0;
        int maxNumberToDispatch = prefetchLimit - unconsumedMessagesDispatched.get();
        while (entry != null && count < maxNumberToDispatch) {
            MessagePointer pointer = (MessagePointer) entry.getElement();
            if (!pointer.isDispatched()) {
                ActiveMQMessage msg = pointer.getContainer().getMessage(pointer.getMessageIdentity());
                if (msg != null && !msg.isExpired()) {
                    if (pointer.isDispatched() || pointer.isRedelivered()) {
                        //already dispatched - so mark as redelivered
                        msg.setJMSRedelivered(true);
                    }
                    pointer.setDispatched(true);
                    tmpList.add(msg);
                    unconsumedMessagesDispatched.increment();
                    count++;
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.