Package org.activemq.message

Examples of org.activemq.message.MessageAck


            }
            return rc;
        }

        public MessageAck[] getAcks() {
            MessageAck rc[] = new MessageAck[acks.size()];
            int count=0;
            for (Iterator iter = acks.iterator(); iter.hasNext();) {
                RemoveMessageCommand cmd = (RemoveMessageCommand) iter.next();
                rc[count++] = cmd.getMessageAck();
            }
View Full Code Here


        message = new ActiveMQBytesMessage();
        message.writeBytes(new byte[1024]);
        message.setJMSDestination(new ActiveMQQueue("TEST"));
       
        ack = new MessageAck();
        ack.setDestination(message.getJMSActiveMQDestination());
    }
View Full Code Here

            ActiveMQMessage messageCopy;
              synchronized(message) {
          messageCopy = message.deepCopy();
              }
              messageCopy.setReceiptRequired(false);
            MessageAck ack = new MessageAck();
            ack.setReceiptRequired(false);
            ack.setDestination(messageCopy.getJMSActiveMQDestination());
           
                messageCopy.setReceiptRequired(false);
                int count = MESSAGE_COUNT/workers;
               
                String id = "id:"+Thread.currentThread().getName()+":";
                for (int i = 0; i < count; i++) {
                    pp.increment();
                    messageCopy.setJMSMessageID(id+i);
                    store.addMessage(messageCopy);
                    ack.setMessageID(message.getJMSMessageID());
                    store.removeMessage(ack);
                }               
                return null;
            }
        };
View Full Code Here

    protected void recover() throws JMSException {
    }

    protected MessageAck createMessageAck(MessageIdentity messageIdentity, Destination destination) {
        MessageAck answer = new MessageAck();
        answer.setConsumerId("James");
        answer.setMessageID(messageIdentity.getMessageID());
        answer.setMessageRead(true);
        answer.setDestination(this.destination);
        return answer;
    }
View Full Code Here

                    consumeActiveMQMessage(message);
                }
                else {
                    switch (packet.getPacketType()) {
                        case Packet.ACTIVEMQ_MSG_ACK : {
                            MessageAck ack = (MessageAck) packet;
                            consumeMessageAck(ack);
                            break;
                        }
                        case Packet.XA_TRANSACTION_INFO : {
                            XATransactionInfo info = (XATransactionInfo) packet;
View Full Code Here

        assertEquals("Message text should be equal", messageTexts[i], text);
        assertEquals(messageIds[i], message.getJMSMessageID());
    }

    protected MessageAck createMessageAck(MessageIdentity messageIdentity) {
        MessageAck answer = new MessageAck();
        answer.setConsumerId(idGenerator.generateId());
        answer.setMessageID(messageIdentity.getMessageID());
        answer.setMessageRead(true);
        return answer;
    }
View Full Code Here

                            catch (Throwable e) {
                                log.error("Recovery Failure: Could not add message: " + msg.getJMSMessageIdentity().getMessageID() + ", reason: " + e, e);
                            }
                        }
                        else if (packet instanceof MessageAck) {
                            MessageAck ack = (MessageAck) packet;
                            JournalMessageStore store = (JournalMessageStore) createMessageStore(destination, ack.getDestination().isQueue());
                            try {
                                // Only remove the message if it has not allready been removed.
                                ActiveMQMessage t = store.getLongTermMessageStore().getMessage(ack.getMessageIdentity());
                                if( t!=null ) {
                                    store.getLongTermMessageStore().removeMessage(ack);
                                    transactionCounter++;
                                }
                            }
                            catch (Throwable e) {
                                log.error("Recovery Failure: Could not remove message: " + ack.getMessageIdentity().getMessageID() + ", reason: " + e, e);
                            }
                        }
                        else {
                            log.error("Unknown type of packet in transaction log which will be discarded: " + packet);
                        }
View Full Code Here

                // Checkpoint the removed messages.
                iterator = cpRemovedMessageLocations.iterator();
                while (iterator.hasNext()) {
                    try {
                        MessageAck ack = (MessageAck) iterator.next();
                        longTermStore.removeMessage(ack);
                    } catch (Throwable e) {
                        log.debug("Message could not be removed from long term store: " + e.getMessage(), e);
                    }
                }
View Full Code Here

     * @param dataOut the output stream
     * @throws IOException thrown if an error occurs
     */

    public void writePacket(Packet packet, DataOutput dataOut) throws IOException {
        MessageAck ack = (MessageAck) packet;
       
        boolean cachingEnabled = wireFormat != null ? wireFormat.isCachingEnabled() : false;
        boolean longSequence = ack.getSequenceNumber() > Integer.MAX_VALUE;
       
      
        Object[] visited = ack.getBrokersVisited();
        boolean writeVisited = visited != null && visited.length > 0;
        BitArray ba = ack.getBitArray();
        ba.reset();
        ba.set(AbstractPacket.RECEIPT_REQUIRED_INDEX, ack.isReceiptRequired());
        ba.set(AbstractPacket.BROKERS_VISITED_INDEX,writeVisited);
        ba.set(MessageAck.MESSAGE_READ_INDEX, ack.isMessageRead());
        ba.set(MessageAck.TRANSACTION_ID_INDEX, ack.isPartOfTransaction());
        ba.set(MessageAck.XA_TRANS_INDEX, ack.isXaTransacted());
        ba.set(MessageAck.PERSISTENT_INDEX,ack.isPersistent());
        ba.set(MessageAck.EXPIRED_INDEX,ack.isExpired());
        ba.set(MessageAck.EXTERNAL_MESSAGE_ID_INDEX, ack.isExternalMessageId());
        ba.set(MessageAck.CACHED_VALUES_INDEX,cachingEnabled);
        ba.set(MessageAck.LONG_SEQUENCE_INDEX, longSequence);
        ba.writeToStream(dataOut);
       
        if (ack.isReceiptRequired()){
            dataOut.writeShort(ack.getId());
        }
        if (ack.isExternalMessageId()){
            writeUTF(ack.getMessageID(),dataOut);
        }else {
            if (cachingEnabled){
                dataOut.writeShort(wireFormat.getWriteCachedKey(ack.getProducerKey()));
            }else{
                writeUTF(ack.getProducerKey(),dataOut);
            }
            if (longSequence){
                dataOut.writeLong(ack.getSequenceNumber());
            }else {
                dataOut.writeInt((int)ack.getSequenceNumber());
            }
        }
        if (writeVisited){
            dataOut.writeShort(visited.length);
            for(int i =0; i < visited.length; i++){
                final String brokerName = visited[i].toString();
                if (brokerName != null) {
                    dataOut.writeUTF(brokerName);
                }
            }
        }
        
        if (ack.isPartOfTransaction()) {
            if (cachingEnabled){
                dataOut.writeShort(wireFormat.getWriteCachedKey(ack.getTransactionId()));
            } else {
                if( ack.isXaTransacted()) {
                    ActiveMQXid xid = (ActiveMQXid) ack.getTransactionId();
                    xid.write(dataOut);
                } else {
                    super.writeUTF((String) ack.getTransactionId(), dataOut);
                }           
            }
        }

        if (cachingEnabled){
            dataOut.writeShort(wireFormat.getWriteCachedKey(ack.getConsumerId()));
            dataOut.writeShort(wireFormat.getWriteCachedKey(ack.getDestination()));
        }else {
            super.writeUTF(ack.getConsumerId(), dataOut);
            ActiveMQDestination.writeToStream((ActiveMQDestination) ack.getDestination(), dataOut);
        }
    }
View Full Code Here

TOP

Related Classes of org.activemq.message.MessageAck

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.