4 Replies Latest reply on Feb 28, 2006 1:50 PM by Tim Fox

    DestinationManagement - RemoveAllMessages()

    Alex Fu Newbie

      From a ChannelSupport's point of view, MessageReference could be in the following states:

      (1) non-tx:
      (1.1) received. In MsgRefs;
      (1.2) delivered but not ack yet. In Deliveries;

      (2) tx:
      (2.1) not yet in MsgRefs (but already indexed in message store and registered in txToAddReferenceCallbacks)
      (2.2) after tx committed. In MsgRefs;
      (2.3) In Deliveries; Also in txToRemoveDeliveryCallbacks;

      If RemoveAllMessages() applies to all messages, then
      For (1)non-tx msg, I should release the ref from MessageStore, and clear MsgRefs & Deliveries. If it's reliable, then I also remove it from TransactionLog;
      For (2)tx msg, I will ignore (2.1) because it's not received by the channel yet; (2.3) needs to set tx to RollBackOnly. Then do the same as (1) does.

      If RemoveAllMessages() doesn't apply to tx messages, as Ovidiu told me so, then
      there is a question: How do I know if a msg in MsgRefs is part of tx or not?
      e.g. 3 msgs are in a tx and 2 of them are already delivered (so the 2 will be in Deliveries & registered in txToRemoveDeliveryCallbacks. But how would I know if there are another message in MsgRefs will be in the tx of the 2?

      Thanks!

        • 1. Re: DestinationManagement - RemoveAllMessages()
          Tim Fox Master

          Add a method acknowledgeAll to the state.

          For nonRecoverableState this removes from memory, for persistent state this removes from persistent storage, also needs to release refs as you have mentioned.

          Don't worry about transactional state.

          If a ref has been removed and a tx subsequently tries to ack it then it will just be ignored. Alternatively we could throw an exception at this point but I don't really see the need for that.

          • 2. Re: DestinationManagement - RemoveAllMessages()
            Tim Fox Master

            Also need to lock the channel exclusively for the duration of the operation.

            • 3. Re: DestinationManagement - RemoveAllMessages()
              Alex Fu Newbie

              For Topics, there is a problem with removeAllMessages() because multiple subscriptions may have different states.

              e.g. There are two subscriptions for a Topic and one of them is durable but offline; another is online. Messages sent to the Topic are successfully delivered to the online subscription's receiver but are still held in the offline subscription. And if now removeAllMessages() is applied, then all held messages in the offline subscription will disappear. From the Topic's point of view, different messages are removed from different subscriptions. This makes removeAllMessages() an undefined operation.

              • 4. Re: DestinationManagement - RemoveAllMessages()
                Tim Fox Master

                This can be done by locking all the channels corresponding to subscriptions for the topic and removing first their in memory state, then removing the state of any surable subs for the topic directly in the db.