Package org.activemq.message

Examples of org.activemq.message.ActiveMQMessage


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

            }
        });
    }

    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 = toStringFromSequenceNumber(sequenceNo);
            }
View Full Code Here

                int count = lastIndex - startIndex;
                assertTrue("Not enough messages available to dispatch. Expected: " + count
                        + " messages but was: " + messagesToDispatch.length, messagesToDispatch.length >= count);

                for (int i = 0; i < count; i++) {
                    ActiveMQMessage expected = getMessage(i + startIndex);
                    ActiveMQMessage actual = messagesToDispatch[i];
                    assertMessagesEqual("Dispatched message at index: " + i, expected, actual);
                }
            }
        });
    }
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

                        destination = is.readUTF();
                        packet = wireFormat.readPacket(data);

                        // Try to replay the packet.
                        if (packet instanceof ActiveMQMessage) {
                            ActiveMQMessage msg = (ActiveMQMessage) packet;
                           
                            JournalMessageStore store = (JournalMessageStore) createMessageStore(destination, msg.getJMSActiveMQDestination().isQueue());
                            if( msg.getTransactionId()!=null ) {
                                transactionStore.addMessage(store, msg, pos);
                            } else {
                                store.replayAddMessage(msg);
                                transactionCounter++;
                            }
View Full Code Here

        return null;
    }


    protected void writeMessage(int i) throws JMSException {
        ActiveMQMessage message = createMessage(i);
        String id = idGenerator.generateId();
        messageIds[i] = id;
        message.setJMSMessageID(id);
        container.addMessage(message);
        messageIdenties[i] = message.getJMSMessageIdentity();
    }
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.