• Subscription Options

  • What I write about

  • RSS Latest News From MuleSoft

  • Archives

  • Technical Features

  • Visitors Online

  • Persisting items on a (VM) queue

    When using the VM transport asynchronously, you might want to persist any pending messages before Mule is properly shut down. We talk about this in our Mule ESB Developer Training course and explain how to configure it. Last week, while lecturing, I got a question that I had not heard before.

    I was asked what format is used to persist the messages to disk if I had to use the FilePersistenceStrategy. I had never looked into this so I opened the code and dived in.

    The FilePersistenceStrategy allows you to save pending messages on a VM queue to disk and to therefore persist messages between Mule reboots. It does not store the information in XML but rather streams the item to disk directly.

    The store () method for this class accepts an Object and will stream this out to disk:

    public Object store(String queue, Object obj) throws IOException
        {
            ...
            ObjectOutputStream oos = new ObjectOutputStream(new
              FileOutputStream(file));
            oos.writeObject(obj);
            ...
        }

    If you enjoyed this post, make sure you subscribe to my RSS feed!

    Tags: , , , ,

    Leave a Reply

    Add video comment
    © Copyright 2005-2008 Ricston, All Rights Reserved
     Sitemap   Privacy Policy    Legal