Package org.codehaus.activemq.message

Examples of org.codehaus.activemq.message.ActiveMQMessage


     * @see org.codehaus.activemq.message.PacketListener#consume(org.codehaus.activemq.message.Packet)
     */
    public void consume(Packet packet) {
        if (!closed.get() && packet != null) {
            if (packet.isJMSMessage()) {
                ActiveMQMessage message = (ActiveMQMessage) packet;
                message.setReadOnly(true);
                message.setProducerID(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


     * @return an ActiveMQMessage
     * @throws JMSException if the JMS provider fails to create this message due to some internal error.
     */
    public Message createMessage() throws JMSException {
        checkClosed();
        return new ActiveMQMessage();
    }
View Full Code Here

     * Optional operation, intended to be used only by Application Servers, not by ordinary JMS clients.
     *
     * @see javax.jms.ServerSession
     */
    public void run() {
        ActiveMQMessage message;
        while ((message = messageExecutor.dequeueNoWait()) != null) {
            this.beforeMessageDelivered(message);
            preDeliveryHook(messageListener, message);
            deliver(message);
            postDeliveryHook(messageListener, message);
View Full Code Here

    }

    protected void doAcknowledge(boolean isClosing) throws JMSException {
        checkClosed();
        if (this.acknowledgeMode == Session.CLIENT_ACKNOWLEDGE) {
            ActiveMQMessage msg = null;
            while ((msg = (ActiveMQMessage) deliveredMessages.removeFirst()) != null) {
                MessageAck ack = new MessageAck();
                ack.setConsumerId(msg.getConsumerId());
                ack.setMessageID(msg.getJMSMessageID());
                if (!isClosing) {
                    ack.setMessageRead(msg.isMessageConsumed());
                }
                ack.setId(packetIdGenerator.generateId());
                ack.setDestination(msg.getJMSActiveMQDestination());
                ack.setPersistent(msg.getJMSDeliveryMode() == DeliveryMode.PERSISTENT);
                this.connection.asyncSendPacket(ack, false);
            }
            deliveredMessages.clear();
        }
    }
View Full Code Here

        long sequenceNumber = producer.getNextSequenceNumber();
        if ((id == null || id.length() == 0) || !producer.getDisableMessageID() && !reuseMessageId) {
            message.setJMSMessageID(producerId + sequenceNumber);
        }
        //transform to our own message format here
        ActiveMQMessage msg = ActiveMQMessageTransformation.transformMessage(message);
        msg.prepareMessageBody();
        msg.setProducerID(producerId);
        msg.setSequenceNumber(sequenceNumber);
        msg.setTransactionId(currentTransactionId);
        msg.setXaTransacted(isXaTransacted());
        msg.setJMSClientID(this.connection.clientID);
        msg.setJMSRedelivered(false);//could be forwarding this message on
        if (log.isDebugEnabled()) {
            log.debug("Sending message: " + msg);
        }
        // Should we use an async send?
        if (this.connection.isUseAsyncSend()) {
View Full Code Here

            replay.add(obj);
        }
        deliveredMessages.clear();
        if (!replay.isEmpty()) {
            for (ListIterator i = replay.listIterator(replay.size());i.hasPrevious();) {
                ActiveMQMessage msg = (ActiveMQMessage) i.previous();
                if (!onlyDeliverTransientConsumed || msg.isTransientConsumed()) {
                    msg.setJMSRedelivered(true);
                    msg.incrementDeliveryCount();
                    messageExecutor.executeFirst(msg);
                }
            }
        }
        replay.clear();
View Full Code Here

                    packet.addBrokerVisited(remoteBrokerName); //got from the remote broker
                    packet.addBrokerVisited(brokerName);
                }
              
                if (packet.isJMSMessage()) {
                    ActiveMQMessage message = (ActiveMQMessage) packet;
                    // lets mark all messages from where they came from so that NoLocal can filter out loops
                    // e.g. when receiving messages over multicast, we don't want to publish them back out again
                    if (connectionInfo != null) {
                        message.setProducerID(connectionInfo.getClientId());
                    }
                    else {
                        log.warn("No connection info available! Maybe the client forgot to start() the Connection?");
                    }
                    if (!brokerConnection){
                        message.setEntryBrokerName(brokerName);
                        message.setEntryClusterName(clusterName);
                    }
                    consumeActiveMQMessage(message);
                }
                else {
                    switch (packet.getPacketType()) {
View Full Code Here

                      ProducerInfo pi = (ProducerInfo) i.next();
                      pi.setClientId(info.getClientId());
                  }
                 
                  for( int i=0; i < dispatchQueue.size(); i++ ) {
                    ActiveMQMessage msg = (ActiveMQMessage) dispatchQueue.get(i);
                    dispatch(msg);
                  }
                  dispatchQueue.clear();
              }
             
View Full Code Here

    public void run() {
        started.set(true);
        try {

            while (!stopping.get()) {
                ActiveMQMessage message = consumer.receive(500);
                if (message != null) {
                    InboundEndpointWork worker = (InboundEndpointWork) workers.get();
                    // Did we get stopped?
                    if (worker == null) {
                        break;
View Full Code Here

     * @see org.codehaus.activemq.message.PacketListener#consume(org.codehaus.activemq.message.Packet)
     */
    public void consume(Packet packet) {
        if (!closed.get() && packet != null) {
            if (packet.isJMSMessage()) {
                ActiveMQMessage message = (ActiveMQMessage) packet;
                message.setReadOnly(true);
                message.setProducerID(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

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.