Package org.codehaus.activemq.message

Examples of org.codehaus.activemq.message.ActiveMQMessage


    /**
     * do some dispatching
     */
    public void run() {
        int count = 0;
        ActiveMQMessage message = null;
        while (started.get()) {
            try {
                message = (ActiveMQMessage) queue.dequeue(2000);
                if (message != null) {
                    if (!message.isExpired()) {
                        client.dispatch(message);
                        if (++count == 250) {
                            count = 0;
                            Thread.yield();
                        }
View Full Code Here


     *
     * @param id
     * @return the removed ActiveMQMessage with the associated id
     */
    public ActiveMQMessage acknowledgeMessage(String id) {
        ActiveMQMessage msg = (ActiveMQMessage) dispatchedQueue.remove(id);
        return msg;
    }
View Full Code Here

    /**
     * do some dispatching
     */
    public void run() {
        int count = 0;
        ActiveMQMessage message = null;
        while (started.get()) {
            try {
                message = (ActiveMQMessage) queue.dequeue(2000);
                if (message != null) {
                    if (!message.isExpired()) {
                        client.dispatch(message);
                        if (++count == 250) {
                            count = 0;
                            Thread.yield();
                        }
View Full Code Here

     * @throws JMSException
     */
    public void acknowledgeMessage(BrokerClient client, MessageAck ack) throws JMSException {
        TransientQueueSubscription ts = (TransientQueueSubscription) subscriptions.get(ack.getConsumerId());
        if (ts != null) {
            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

     * @throws JMSException
     */
    public void redeliverMessage(BrokerClient client, MessageAck ack) throws JMSException {
        TransientQueueSubscription ts = (TransientQueueSubscription) subscriptions.get(ack.getConsumerId());
        if (ts != null) {
            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

                }
            }
            //get unacknowledged messages and re-enqueue them
            List list = ts.getUndeliveredMessages();
            for (ListIterator i = list.listIterator(list.size());i.hasPrevious();) {
                ActiveMQMessage message = (ActiveMQMessage) i.previous();
                message.setJMSRedelivered(true);
                queue.enqueueFirstNoBlock(message);
            }
            list.clear();
            ts.close();
        }
View Full Code Here

     * do some dispatching
     */
    public void run() {
        boolean dispatched = false;
        boolean targeted = false;
        ActiveMQMessage message = null;
        try {
            while (started.get() && running.get()) {
                dispatched = false;
                targeted = false;
                if (!subscriptions.isEmpty()) {
                    message = (ActiveMQMessage) queue.dequeue(2000);
                    if (message != null) {
                        if (!message.isExpired()) {
                            QueueListEntry entry = subscriptions.getFirstEntry();
                            while (entry != null) {
                                TransientQueueSubscription ts = (TransientQueueSubscription) entry.getElement();
                                if (ts.isTarget(message)) {
                                    targeted = true;
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

     */
    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

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.