Package org.codehaus.activemq.service

Examples of org.codehaus.activemq.service.MessageIdentity


            Transaction transaction = BDbHelper.getTransaction();
            DatabaseEntry key = createKey(messageID);
            DatabaseEntry value = new DatabaseEntry(asBytes(message));
            database.put(transaction, key, value);

            MessageIdentity answer = message.getJMSMessageIdentity();
            answer.setSequenceNumber(sequenceNumberCreator.getLastKey());
        }
        catch (DatabaseException e) {
            throw JMSExceptionHelper.newJMSException("Failed to broker message: " + messageID + " in container: " + e, e);
        }
        catch (IOException e) {
View Full Code Here


        }
    }

    public void removeMessage(MessageAck ack) throws JMSException {
        checkClosed();
        MessageIdentity identity = ack.getMessageIdentity();
        String messageID = identity.getMessageID();
        try {
            Transaction transaction = BDbHelper.getTransaction();

            // we need to find the alternative primary key for the given messageID
            DatabaseEntry sequenceNumber = getSequenceNumberKey(identity);
View Full Code Here

            DatabaseEntry keyEntry = new DatabaseEntry();
            DatabaseEntry valueEntry = new DatabaseEntry();
            OperationStatus status = cursor.getFirst(sequenceNumberEntry, keyEntry, valueEntry, LockMode.DEFAULT);
            while (status == OperationStatus.SUCCESS) {
                String messageID = extractString(keyEntry);
                container.recoverMessageToBeDelivered(new MessageIdentity(messageID, sequenceNumberEntry));
                status = cursor.getNext(sequenceNumberEntry, keyEntry, valueEntry, LockMode.DEFAULT);
            }
            if (status != OperationStatus.NOTFOUND) {
                log.warn("Unexpected status code while recovering: " + status);
            }
View Full Code Here

            OperationStatus status = cursor.getLast(keyEntry, valueEntry, LockMode.DEFAULT);
            if (status == OperationStatus.SUCCESS) {
                if (log.isDebugEnabled()) {
                    log.debug("Loaded last sequence number of: " + BDbHelper.longFromBytes(keyEntry.getData()));
                }
                return new MessageIdentity(null, keyEntry);
            }
            else if (status != OperationStatus.NOTFOUND) {
                log.error("Could not find the last sequence number. Status: " + status);
            }
            return null;
View Full Code Here

     * @return the message identity, which contains the String messageID
     *         and the lazily populated sequence number
     */
    public MessageIdentity getJMSMessageIdentity() {
        if (jmsMessageIdentity == null) {
            jmsMessageIdentity = new MessageIdentity(this.getJMSMessageID());
        }
        return jmsMessageIdentity;
    }
View Full Code Here

      public void execute() throws Throwable {
       
        // Checkpoint the added messages.
        Iterator iterator = addedMessageIds.keySet().iterator();
        while (iterator.hasNext()) {         
          MessageIdentity identity = (MessageIdentity) iterator.next();         
          ActiveMQMessage msg = getCacheMessage(identity);
          // Pull it out of the journal if we have to.
          if( msg==null ) {
              RecordLocation location = (RecordLocation) addedMessageIds.get(identity);
            msg = (ActiveMQMessage) peristenceAdapter.readPacket((RecordLocation)location);
View Full Code Here

        }
        try {
            String messageID = message.getJMSMessageID();
            getMessageTable().insert(messageID, entry, true);
            getOrderedIndex().insert(sequenceNumber, messageID, true);
            MessageIdentity answer = message.getJMSMessageIdentity();
            answer.setSequenceNumber(sequenceNumber);
        }
        catch (IOException e) {
            throw JMSExceptionHelper.newJMSException("Failed to add message: " + message + " in container: " + e, e);
        }
    }
View Full Code Here

        try {
            Tuple tuple = new Tuple();
            TupleBrowser iter = getOrderedIndex().browse();
            while (iter.getNext(tuple)) {
                Long key = (Long) tuple.getKey();
                MessageIdentity messageIdentity = null;
                if (key != null) {
                    String messageID = (String) tuple.getValue();
                    if (messageID != null) {
                        messageIdentity = new MessageIdentity(messageID, key);
                    }
                }
                if (messageIdentity != null) {
                    container.recoverMessageToBeDelivered(messageIdentity);
                }
View Full Code Here

     */
    protected ActiveMQMessage getMessageBySequenceNumber(Long sequenceNumber) throws IOException, JMSException {
        ActiveMQMessage message = null;
        String messageID = (String) getOrderedIndex().find(sequenceNumber);
        if (messageID != null) {
            message = getMessage(new MessageIdentity(messageID, sequenceNumber));
        }
        return 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);
            }
            System.out.println("item: " + i + " is: " + sequenceText);
View Full Code Here

TOP

Related Classes of org.codehaus.activemq.service.MessageIdentity

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.