Over a million developers have joined DZone.

How To Delete Old Applications From MMC's Repository

DZone's Guide to

How To Delete Old Applications From MMC's Repository

Learn how to automatically delete old applications, which are not associated with a current deployment, from MMC's repository with this quick tutorial.

· Integration Zone
Free Resource

Share, secure, distribute, control, and monetize your APIs with the platform built with performance, time-to-value, and growth in mind. Free 90-day trial of 3Scale by Red Hat


Automatically delete old applications from the MMC's repository. This means applications/versions that are no longer associated with an existing deployment.


Please only do this when there are not operations taking place on MMC (like deployments, application uploads, etc.) and do a backup before following these steps.

  1. Log into MMC as an administrator user.
  2. Go to the Administration Tab.
  3. Click on 'Admin Shell' in the panel on the left.
  4. Paste the contents of the attached script in the text box.
  5. Click 'Evaluate.'

When finish, you will see an 'OK' message above the 'Evaluate' button.

Check your application container's logs (E.g.: Tomcat's logs) to see all the applications the script will delete (Look for "<applicantion_name> deleted" entries). If you agree with the applications it will delete, remove the '//' from the line '//applicationDao.delete(it.id);' to allow the deletion of the apps and run the script again by clicking 'Evaluate.' This last run will remove all the applications permanently.

Check the applications that will get deleted in 'catalina.out' using:

 tail -500f /ESB/apps/apache_tomcat/apache-tomcat-7.0.70/logs/catalina.out 

import com.mulesoft.mmc.deployment.ApplicationDAO;
import com.mulesoft.mmc.deployment.DeploymentDAO;

// Copy into a local var, referenced in closure.
DeploymentDAO deploymentDao = applicationContext.getBean("deploymentDAO")
ApplicationDAO applicationDao = applicationContext.getBean("applicationDAO")

int deleted = 0;
println "Purging old versions of applications ..."

applicationDao.list().each {

    if(it.getDeployments() == null || it.getDeployments().empty ){
      if (deploymentDao.getDeploymentsReferencingApplicationById(it.getId()).isEmpty()){
           println it.toString() + " deleted";


println "${deleted} applications have been removed from the Repository."
return "COMPLETED"

Thanks for reading!

Explore the core elements of owning an API strategy and best practices for effective API programs. Download the API Owner's Manual, brought to you by 3Scale by Red Hat

mulesoft ,mmc ,mule esb ,mule ,integration ,tutorial ,apache

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}