Storing Objects in the Registry

February 12 2009

0 comments
motif
Note that this approach is no longer recommended if you are using Mule 3.0.0 or later. Instead you can use the ObjectStore. This allows use to store objects in memory, in a persistent store or across Mule HA clusters automatically. You can learn more about Mule 3.0 here and download it here.

Recently, there was a great question on one of the Mule mailing lists about where to store runtime data that can be used across the app. If you need to store runtime data that is available across your Mule application, you can store the data as objects in the Mule Registry. You can get a handle to the Registry from anywhere that you have access to the MuleContext, as in most Mule entities. For example, you could store the object as follows:

You could then update the object from somewhere else:

This approach is useful for storing objects such as routers that are needed by multiple components across your application.

I’ve added this info to the Mule User Guide for easy reference in the future. Thanks to Travis and Andrew for the info.


We'd love to hear your opinion on this post