Package org.activemq.service

Examples of org.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);
                listener.recoverMessage(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

       
        // Checkpoint the acknowledged messages.
        Iterator iterator = cpAckedLastAckLocations.keySet().iterator();
        while (iterator.hasNext()) {         
            String subscription = (String) iterator.next();
            MessageIdentity identity = (MessageIdentity) cpAckedLastAckLocations.get(subscription);           
          longTermStore.setLastAcknowledgedMessageIdentity(subscription, identity);
        }       
       
      }
View Full Code Here

     * @param location
     */
    private void addMessage(final ActiveMQMessage message, final RecordLocation location) {
        synchronized (this) {
            lastLocation=location;
            MessageIdentity id = message.getJMSMessageIdentity();
            addedMessageIds.put(id, location);
        }
    }
View Full Code Here

     * @param location
     */
    private void removeMessage(final MessageAck ack, final RecordLocation location) {
        synchronized (this) {
            lastLocation=location;
            MessageIdentity id = ack.getMessageIdentity();
            RecordLocation msgLocation = (RecordLocation) addedMessageIds.remove(id);
            if (msgLocation == null) {
                removedMessageLocations.add(ack);
            } else {
                removedFromJournal++;
View Full Code Here

            public void execute() throws Throwable {

                // Checkpoint the added messages.
                Iterator iterator = cpAddedMessageIds.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) cpAddedMessageIds.get(identity);
                        msg = (ActiveMQMessage) peristenceAdapter.readPacket((RecordLocation) location);
View Full Code Here

       
        // Checkpoint the acked messages.
        Iterator iterator = cpAckedLastAckLocations.keySet().iterator();
        while (iterator.hasNext()) {         
            String subscription = (String) iterator.next();
            MessageIdentity identity = (MessageIdentity) cpAckedLastAckLocations.get(subscription);           
          longTermStore.setLastAcknowledgedMessageIdentity(subscription, identity);
        }       
       
      }
View Full Code Here

                                      if( op.operationType == TxOperation.REMOVE_OPERATION_TYPE) {
                                          op.store.replayRemoveMessage((MessageAck) op.data);
                                      }
                                      if( op.operationType == TxOperation.ACK_OPERATION_TYPE) {
                                          JournalAck ack = (JournalAck) op.data;
                                          ((JournalTopicMessageStore)op.store).replayAcknowledge(ack.getSubscription(), new MessageIdentity(ack.getMessageId()));
                                      }
                                  }
                                  transactionCounter++;
                              }
                              break;
                          case TxCommand.LOCAL_ROLLBACK:
                          case TxCommand.XA_ROLLBACK:
                              transactionStore.replayRollback(command.getTransactionId());
                              break;
                        }
                       
                        break;
                       
                    case ACK_RECORD_TYPE:
                       
                        destination = is.readUTF();
                        String subscription = is.readUTF();
                        String messageId = is.readUTF();
                        Object transactionId=null;
                       
                        JournalTopicMessageStore store = (JournalTopicMessageStore) createMessageStore(destination, false);
                        if( transactionId!=null ) {
                            JournalAck ack = new JournalAck(destination, subscription, messageId, transactionId);
                            transactionStore.acknowledge(store, ack, pos);
                        } else {
                            store.replayAcknowledge(subscription, new MessageIdentity(messageId));
                            transactionCounter++;
                        }
                       
                    case COMMAND_RECORD_TYPE:
View Full Code Here

        return destinationName;
    }

    public void addMessage(ActiveMQMessage message) throws JMSException {
        messageStore.addMessage(message);
        final MessageIdentity answer = message.getJMSMessageIdentity();
       
        // If there is no transaction.. then this executes directly.
        TransactionManager.getContexTransaction().addPostCommitTask(new TransactionTask(){
            public void execute() throws Throwable {
                synchronized( this ) {
View Full Code Here

TOP

Related Classes of org.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.