Package org.activemq.message

Examples of org.activemq.message.ActiveMQMessage


        }
    }

    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

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

        return res;
    }

    public void onMessage(Message message) {
        try {
            ActiveMQMessage amsg = (ActiveMQMessage) message;
            TextMessage textMessage = (TextMessage) message;

            StringBuffer sb = new StringBuffer();
            sb.append(textMessage.getText());
            sb.append("#");
            sb.append(amsg.getConsumerIdentifer());

            addToMap(sb.toString());

        } catch (JMSException e) {
            log.error("Unable to force deserialize the content", e);
View Full Code Here

        synchronized (messageListenerGuard) {
            this.messageListener = listener;
            if (listener != null) {
                session.setSessionConsumerDispatchState(ActiveMQSession.CONSUMER_DISPATCH_ASYNC);
                //messages may already be enqueued
                ActiveMQMessage msg = null;
                try {
                    while ((msg = (ActiveMQMessage)messageQueue.dequeueNoWait()) != null) {
                        processMessage(msg);
                    }
                }
View Full Code Here

    public Message receive() throws JMSException {
        checkClosed();
        session.setSessionConsumerDispatchState(ActiveMQSession.CONSUMER_DISPATCH_SYNC);
        try {
            this.accessThread = Thread.currentThread();
            ActiveMQMessage message = (ActiveMQMessage) messageQueue.dequeue();
            this.accessThread = null;
            if (message != null) {
                boolean expired = message.isExpired();
                messageDelivered(message, true, expired);
                if (!expired) {
                    message = message.shallowCopy();
                }
                else {
                    message = (ActiveMQMessage) receiveNoWait(); //this will remove any other expired messages held in the queue
                }
            }
View Full Code Here

        try {
            if (timeout == 0) {
                return this.receive();
            }
            this.accessThread = Thread.currentThread();
            ActiveMQMessage message = (ActiveMQMessage) messageQueue.dequeue(timeout);
            this.accessThread = null;
            if (message != null) {
                boolean expired = message.isExpired();
                messageDelivered(message, true, expired);
                if (!expired) {
                    message = message.shallowCopy();
                }
                else {
                    message = (ActiveMQMessage) receiveNoWait(); //this will remove any other expired messages held in the queue
                }
            }
View Full Code Here

     *
     * @param message - message received by the listener.
     */
    public void onMessage(Message message) {
        try {
            ActiveMQMessage amsg = (ActiveMQMessage) message;
            TextMessage textMessage = (TextMessage) message;

            StringBuffer sb = new StringBuffer();
            sb.append(textMessage.getText());
            sb.append("#");
            sb.append(amsg.getConsumerIdentifer());

            msgCounter++;
            String strMsgCounter = String.valueOf(msgCounter);
            ProducerMap.put(strMsgCounter, sb.toString());

View Full Code Here

     */
    public Message receiveNoWait() throws JMSException {
        checkClosed();
        session.setSessionConsumerDispatchState(ActiveMQSession.CONSUMER_DISPATCH_SYNC);
        try {
            ActiveMQMessage message = null;
            //iterate through an scrub delivered but expired messages
            while ((message = (ActiveMQMessage) messageQueue.dequeueNoWait()) != null) {
                boolean expired = message.isExpired();
                messageDelivered(message, true, expired);
                if (!expired) {
                    if( message!=null && log.isDebugEnabled() ) {
                        log.debug("Message received: "+message);
                    }           
                    return message.shallowCopy();
                }
            }
        }
        catch (InterruptedException ioe) {
            throw new JMSException("Queue is interrupted: " + ioe.getMessage());
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.