Warning: A non-numeric value encountered in /home/ricston2/public_html/blogarchive/wp-content/themes/Divi/functions.php on line 5766

When you run Mule, your services (and their components) are initialised and ready to process inbound messages. Mule will create a new object instance for each request but this may not be what you want to happen.

Mule does this behind-the-scenes cloning of your component purely because it can. Doing so means that it can handle more inbound requests simultaneously and that is a good thing, of course. There are cases when you need (or must have) a singleton.

Firstly, if the component you’re using is declared using Spring:

    
    

    ...

    
         
    

then your component will be a singleton. Spring components are singletons by default.

Secondly, you can declare a component inside a service and insist that it should be a singleton using the element: