cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mgwmapp.exe process still running after MegaRoot.close()

jschneider
Contributor

Hello,

 

Attached class get all users with opened transactions.

 

No exception is throwed but mgwmapp.exe process still running after MegaRoot.close().

 

Does somebody knows were i made a mistake ?

 

Regards,

 

--

Julien Schneider

--
Julien Schneider
4 Replies

Hello,

 

Proposed solution did not solve the problem fo multiple MegaRoot opened on one MegaApplication instance. (so i use my task killing method).

But proposed solution solved the issue of my first post.

 

Thanks and regards,

 

 

--
Julien Schneider

OK, i'll try.

Note that this problem append only when i get data from MegaEnvironnements or when i open more than one MegaRoot.

Before Hopex this batch ran on MEGA 2009 and did not have this issue.

All by other batchs which open only one MegaRoot on a MegaDatabase do not have this issue.

 

 

Thanks and regards,

--
Julien Schneider

Hello,

This is a know issue when calling Mega from outside Java programs. The workaround will work indeed, but you can do it more properly by releasing all java objects that belong to Mega : MegaApplication, MegaEnvironments, MegaTransaction...etc. before your program terminates

All these objects should be released by calling the java method .release() when the object is no more used.

 

Thus, the process should be killed implicitly.

Custo Guru

jschneider
Contributor

Workaround, kill the process "manually" :

 

 

	    /**
     * Not really clean, but if MEGA is not closed automatically then use this method...
     *
     * @param ma MegaApplication
     * @throws IOException
     * @throws InterruptedException
     */
    private void killMegaApplication(MegaApplication ma) throws IOException,InterruptedException{
        logger.debug("START killMegaApplication(MegaApplication ma)");
        if(ma==null) return;
        String megaprocessid = ma.processID();
        logger.debug("Application process ID from MEGA : "+megaprocessid);
        megaprocessid = megaprocessid.toUpperCase();
        String digits = "0123456789ABCDEF";
        int i=0;
        String finalMegaProcessId = "";
        while(i<megaprocessid.length()){
            if(digits.contains(new String(""+megaprocessid.charAt(i)))){
                finalMegaProcessId += megaprocessid.charAt(i);
            }
            i++;
        }
        logger.debug("Final application process ID after removing non correct char : "+finalMegaProcessId);
        int decimal = Integer.parseInt(finalMegaProcessId, 16);
        String commandLine = "taskkill /PID "+decimal+" /T /F";
        logger.info("Killing MEGA process : "+commandLine);
        Runtime.getRuntime().exec(commandLine);
        Thread.sleep(1000);
        logger.debug("END killMegaApplication(MegaApplication ma)");
    }

FYI : my version is HOPEX V1R3 CP12

 

--
Julien Schneider