Package org.activemq.message

Examples of org.activemq.message.ActiveMQMessage


    /**
     * implementation of Runnable
     */
    public void run() {
        while (!closed && !dispatchedBySessionPool) {
            ActiveMQMessage message = null;
            try {
                message = (ActiveMQMessage) messageQueue.dequeue(100);
            }
            catch (InterruptedException ie) {
            }
View Full Code Here


        final TransientQueueSubscription ts = (TransientQueueSubscription) subscriptions.get(ack.getConsumerId());
        if (ts == null)
            return;

        final ActiveMQMessage message = ts.acknowledgeMessage(ack.getMessageID());
        if (message == null )
            return;
       
        if( ts.isBrowser() ) {
            ts.addAckedMessage(message);
            return;
        }

        if (!ack.isMessageRead() || ack.isExpired()) {
            redeliverMessage(ts, ack, message);
        } else if (TransactionManager.isCurrentTransaction()) {
            // Hook in a callbacks on first acked message
            if (!ts.hasAckedMessage()) {
                TransactionManager.getContexTransaction().addPostRollbackTask(new TransactionTask() {
                    public void execute() throws Throwable {
                       
                        List ackList = ts.listAckedMessages();
                        HashMap redeliverMap = new HashMap();
                        for (Iterator iter = ackList.iterator(); iter.hasNext();) {
                           
                            ActiveMQMessage message = (ActiveMQMessage) iter.next();
                            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 containers = destinationMap.get(message.getJMSActiveMQDestination());
                                for (Iterator i = containers.iterator();i.hasNext();) {
                                    TransientQueueBoundedMessageContainer container = (TransientQueueBoundedMessageContainer) i.next();
                                    LinkedList l = (LinkedList) redeliverMap.get(container);
                                    if( l==null ) {
                                        l = new LinkedList();
View Full Code Here

                        List ackList = ts.listAckedMessages();
                        HashMap redeliverMap = new HashMap();
                       //for (int x = ackList.size()-1; x >= 0 ; x--){   
                       for (int x = 0; x < ackList.size(); x++){   
                            DurableMessagePointer messagePointer = (DurableMessagePointer) ackList.get(x);
                            ActiveMQMessage message = messagePointer.getMessage();
                            message.setJMSRedelivered(true);
                            if (message.incrementDeliveryCount() >= redeliveryPolicy.getMaximumRetryCount()) {
                                if (log.isDebugEnabled()){
                                    log.debug("Message: " + message + " has exceeded its retry count");
                                }
                                // TODO: see if we can use the deadLetterPolicy of the container that dispatched the message.
                                deadLetterPolicy.sendToDeadLetter(message);
                            }
                            else if (ack.isExpired()) {
                                if (log.isDebugEnabled()){
                                    log.debug("Message: " + message + " has expired");
                                }
                                // TODO: see if we can use the deadLetterPolicy of the container that dispatched the message.
                                deadLetterPolicy.sendToDeadLetter(message);
                            }
                            else {
                                Set containers = destinationMap.get(message.getJMSActiveMQDestination());
                                for (Iterator i = containers.iterator();i.hasNext();) {
                                    DurableQueueBoundedMessageContainer container = (DurableQueueBoundedMessageContainer) i.next();
                                    LinkedList l = (LinkedList) redeliverMap.get(container);
                                    if( l==null ) {
                                        l = new LinkedList();
View Full Code Here

     * @return the first dequeued ActiveMQMessage or blocks until one is available
     * @throws JMSException
     * @throws InterruptedException
     */
    public ActiveMQMessage dequeue() throws JMSException, InterruptedException {
        ActiveMQMessage result = null;
        synchronized (outLock) {
            while ((result = dequeueNoWait()) == null) {
                outLock.wait(WAIT_TIMEOUT);
            }
        }
View Full Code Here

     * @param timeInMillis maximum time to wait to dequeue a ActiveMQMessage
     * @throws JMSException
     * @throws InterruptedException
     */
    public ActiveMQMessage dequeue(long timeInMillis) throws JMSException, InterruptedException {
        ActiveMQMessage result = dequeueNoWait();
        if (result == null) {
            synchronized (outLock) {
                outLock.wait(timeInMillis);
                result = dequeueNoWait();
            }
View Full Code Here

     * @return the ActiveMQMessage from the head of the Queue or null if the Queue is empty
     * @throws JMSException
     * @throws InterruptedException
     */
    public ActiveMQMessage dequeueNoWait() throws JMSException, InterruptedException {
        ActiveMQMessage result = null;
        if (stopped) {
            synchronized (outLock) {
                while (stopped && !closed) {
                    outLock.wait(WAIT_TIMEOUT);
                }
View Full Code Here

                    synchronized (subscriptionsMutex) {
                        if (!subscriptions.isEmpty()) {
                            messagePointer = (DurableMessagePointer) queue
                                    .dequeue(sleepTime);
                            if (messagePointer != null) {
                                ActiveMQMessage message = messagePointer
                                        .getMessage();
                                if (!message.isExpired()) {

                                    QueueListEntry entry = subscriptions
                                            .getFirstEntry();
                                    while (entry != null) {
                                        DurableQueueSubscription ts = (DurableQueueSubscription) entry
                                                .getElement();
                                        if (ts.isTarget(message)) {
                                            targeted = true;
                                            if (message.isMessagePart()) {
                                                DurableQueueSubscription sameTarget = (DurableQueueSubscription) messageParts
                                                        .get(message
                                                                .getParentMessageID());
                                                if (sameTarget == null) {
                                                    sameTarget = ts;
                                                    messageParts
                                                            .put(
                                                                    message
                                                                            .getParentMessageID(),
                                                                    sameTarget);
                                                }
                                                sameTarget
                                                        .doDispatch(messagePointer);
                                                if (message.isLastMessagePart()) {
                                                    messageParts
                                                            .remove(message
                                                                    .getParentMessageID());
                                                }
                                                messagePointer = null;
                                                dispatched = true;
                                                notDispatchedCount = 0;
View Full Code Here

    private void fillBuffer(int requiredLength) throws IOException {
        int len = 0;
        try {
            do {
                if (!closed) {
                    ActiveMQMessage msg = null;
                    if (len == 0 && requiredLength > 0) {
                        msg = (ActiveMQMessage) consumer.receive(2000);
                    }
                    else {
                        msg = (ActiveMQMessage) consumer.receiveNoWait();
                    }
                    if (msg != null) {
                        ByteArray ba = msg.getBodyAsBytes();
                        if (ba != null) {
                            len += ba.getLength();
                            process(ba);
                        }
                    }
View Full Code Here

   * @see org.activemq.message.PacketListener#consume(org.activemq.message.Packet)
   */
  public void consume(Packet packet) {
    if (!closed && packet != null) {
      if (packet.isJMSMessage()) {
        ActiveMQMessage message = (ActiveMQMessage) packet;
        message.setReadOnly(true);
        message.setConsumerIdentifer(clientID);

        // lets check for expired messages which is only relevant for
        // multicast based stuff
        // as a pointcast based network should filter out this stuff
        if (transportChannel.isMulticast()) {
          long expiration = message.getJMSExpiration();
          if (expiration > 0) {
            long timeStamp = System.currentTimeMillis();
            if (timeStamp > expiration) {
              if (log.isDebugEnabled()) {
                log.debug("Discarding expired message: "
                    + message);
              }
              return;
            }
          }
        }

        try {
          int count = 0;
          for (Iterator i = this.messageDispatchers.iterator(); i
              .hasNext();) {
            ActiveMQMessageDispatcher dispatcher = (ActiveMQMessageDispatcher) i
                .next();
            if (dispatcher.isTarget(message)) {
              if (count > 0) {
                // separate message for each Session etc.
                message = message.deepCopy();
              }
              dispatcher.dispatch(message);
              count++;
            }
          }
View Full Code Here

      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

TOP

Related Classes of org.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.