ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Java Compute Node Multi Propagage not releasing memory

Post new topic  Reply to topic
 Java Compute Node Multi Propagage not releasing memory « View previous topic :: View next topic » 
Author Message
matuwe
PostPosted: Thu Aug 04, 2011 12:25 pm    Post subject: Java Compute Node Multi Propagage not releasing memory Reply with quote

Master

Joined: 05 Dec 2007
Posts: 296

Hi

I am having big issues with my Java Compute node. I have to read a message, goes into my java compute node and propagate multiple messages out. I have set the message.finilaze set all my variables to null, tried to do the outputmessage.clearmessage.. And everytime I get more messages coming into my java node, then the memory increases. I even tried the System.gc..

What can I do to make sure my java compute node cleans after it's self

I have one String Buffer which I keep on appending too, then put it in the outputBody, then propagate. I have about 4 /6 messages being propagated 3MB each

I am using AIX and Broker 7.0.0.2
Back to top
View user's profile Send private message
Vitor
PostPosted: Thu Aug 04, 2011 12:30 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Is this relevant?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
matuwe
PostPosted: Thu Aug 04, 2011 1:19 pm    Post subject: Reply with quote

Master

Joined: 05 Dec 2007
Posts: 296

Oww yes. so sorry I am still trying to remove business logic from my code so I can post the java compute node..

I need to do Xpath valuation and calculations, this is why I need the Java ..
Code:


public void evaluate(MbMessageAssembly contact admin) throws MbException{

      MbMessage inMessage = contact admin.getMessage();
      MbMessage outMessage = new MbMessage();
      MbMessage exceptionMessage = contact admin.getExceptionList();
      MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin,
            outMessage);

      copyMessageHeaders(inMessage, outMessage); // copy headers from the
      // input message

      MbElement inRoot = inMessage.getRootElement();
      MbElement exceptionRoot = exceptionMessage.getRootElement();
      MbElement outRoot = null;
      FileReader fileReader = null;

      MbOutputTerminal out = getOutputTerminal("out");
      MbOutputTerminal catchTerminal = getOutputTerminal("failure");

try {
      int filePointer = 1;
      int batchSequenceNo = 1;
      outRoot = outMessage.getRootElement();
      MbElement outBody = outRoot.createElementAsLastChild("XMLNSC");
      clearOutputElement();
      setOutputElement(outBody);
      SimpleDateFormat dateFormat = new SimpleDateFormat(BATCHDATEFORMAT);
      String currentTime = dateFormat.format(new Date());
      MbElement statementData = getOutputHeaders(outBody,
                        'QNAME', mechDir, length());

      StringBuffer content = new StringBuffer();
                  statementData.createElementAsLastChild(MbXMLNSC.FIELD,BATCHSEQENCENO, batchSequenceNo);
                  statementData.createElementAsLastChild(MbXMLNSC.FIELD,
                        BATCHTIMESTAMP, currentTime);
   String batchNo = 'QNAME'   + new Date().getTime();
   string lineNo = 'Some data from Q';
         int noOfGoups  =7;
                  String line = '' some xpath calculations ;
                  if (line != null) {

                  while (noOfGoups != null) {
                     content.append(line);

                     //
                     line = 'get more data';
                     if (something Done) {
                     outAssembly.getMessage();
                        statementData.createElementAsLastChild(   MbXMLNSC.FIELD, BATCHDATA,   "BATCH Append");
                        statementData.createElementAsLastChild(   MbXMLNSC.FIELD, BATCHNO, batchNo);
                        statementData.createElementAsLastChild(MbXMLNSC.FIELD, BATCHSEQENCENO,batchSequenceNo++);
                        statementData.createElementAsLastChild(   MbXMLNSC.FIELD, BATCHSIZE, content.length());
                        statementData.createElementAsLastChild(   MbXMLNSC.FIELD, BATCHTIMESTAMP,   currentTime);
                        statementData.createElementAsLastChild(   MbXMLNSC.FIELD, "moreFiles", "FALSE");
                        statementData.createElementAsLastChild(MbXMLNSC.FIELD, "Data",content.toString());
                        outAssembly.getMessage();
                        outMessage.finalizeMessage(MbMessage.FINALIZE_NONE);
                        getOutputTerminal("out").propagate(outAssembly); // Send
                                                               
                        // outMessage.clearMessage();
                        // Create New message
                        content = new StringBuffer("");
                        outBody.getLastChild().detach();
                        statementData = getOutputHeaders(outBody,
                              currentFile.getName(), mechDir,
                              currentFile.length());
                        filePointer = 1;
                     } else if (line != null) {
                        content.append("\r\n");
                     }

                     filePointer++;
                     lineNo++;

                  }

                  outAssembly.getMessage().clearMessage();
                  outRoot.getLastChild().detach(); // clear XMNSC

               }
            }

         }

      } catch (Throwable e) {
   
      }
      finally{
         try {
            outAssembly.getMessage().clearMessage();
            outRoot.getLastChild().detach(); // clear XMNSC
         } catch (Exception ee) {
            System.err.println("Unable to close file. Error = " + ee.getMessage() + ". Stacktrace follows:");
            ee.printStackTrace();
         }

      }
   }



   /**
    * Recreate Output Body
    *
    * @param outBody
    * @param Filename
    * @param fileDir
    * @return
    */
   public MbElement getOutputHeaders(MbElement outBody, String Filename,
         String fileDir, long fileSize) throws Exception {
      MbElement statementData = null;
      try {
         statementData = outBody.createElementAsLastChild(MbXMLNSC.FOLDER,
               "INTERNAL", null);
         statementData = statementData.createElementAsLastChild(
               MbXMLNSC.FOLDER, "INPUTS", null);
         statementData.createElementAsLastChild(MbXMLNSC.FIELD, DataSIZE,
               fileSize);

      } catch (Exception e) {
         throw e;
      }
      return statementData;
   }

   /**
    * Allows the user to access the output tree in the forEachElement() method
    */
   public MbElement getOutputElement() {
      return outputElement;
   }

   public void copyMessageHeaders(MbMessage inMessage, MbMessage outMessage)
         throws MbException {
      MbElement outRoot = outMessage.getRootElement();
      MbElement header = inMessage.getRootElement().getFirstChild();

      while (header != null && header.getNextSibling() != null) {
         outRoot.addAsLastChild(header.copy());
         header = header.getNextSibling();
      }
   }

   public void setOutputElement(MbElement out) {
      outputElement = out;
   }

   public void clearOutputElement() {
      outputElement = null;
   }

}
Back to top
View user's profile Send private message
rekarm01
PostPosted: Sat Aug 06, 2011 12:17 pm    Post subject: Re: Java Compute Node Multi Propagate not releasing memory Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

matuwe wrote:
Oww yes. so sorry I am still trying to remove business logic from my code so I can post the java compute node..

If the posted code reproduces the problem, the smaller the better. But do try not to introduce any more errors in the process.

The general sequence of events for propagating multiple messages is: create new message, finalize message, propagate message, clear message, repeat.

Don't attempt to modify a finalized message, and don't attempt to access a cleared message at all.

matuwe wrote:
Code:
outAssembly.getMessage();

This statement doesn't do anything.

matuwe wrote:
Code:
outMessage.finalizeMessage(MbMessage.FINALIZE_NONE);
getOutputTerminal("out").propagate(outAssembly); // Send
...
outBody.getLastChild().detach();
statementData = getOutputHeaders(outBody, currentFile.getName(), mechDir, currentFile.length());

Don't modify a finalized message. Don't detach the message body; clear the old message, and create a new message instead.

matuwe wrote:
Code:
outAssembly.getMessage().clearMessage();
outRoot.getLastChild().detach();

Don't attempt to access a cleared message.

matuwe wrote:
Code:
public MbElement getOutputElement() {
    return outputElement;
}

public void setOutputElement(MbElement out) {
    outputElement = out;
}

public void clearOutputElement() {
    outputElement = null;
}

What is 'outputElement'? It's not declared.

There's no good reason to provide public access to message tree elements. Simple statements might work better here.

matuwe wrote:
Code:
public MbElement getOutputHeaders( ...

public void copyMessageHeaders(...

These shouldn't be public either.
Back to top
View user's profile Send private message
matuwe
PostPosted: Mon Aug 08, 2011 2:22 am    Post subject: Reply with quote

Master

Joined: 05 Dec 2007
Posts: 296

just to be 100% sure I do understand.. Code for multiple propagate will be.. create message >> Finalize >> Propagate >> clear

Code:


outMessage.finalizeMessage(MbMessage.FINALIZE_NONE);
out.propagate(outAssembly);
outAssembly.getMessage().clearMessage();
                        
// Create New message
content = null;
content = new StringBuffer("");
outMessage = new MbMessage();
outAssembly = new MbMessageAssembly(contact admin,outMessage);
copyMessageHeaders(inMessage, outMessage); // copy headers from the
outRoot = outMessage.getRootElement()).createElementAsLastChild("XMLNSC");

statementData = null;
statementData = getOutputHeaders(outRoot ,currentFile.getName());

Back to top
View user's profile Send private message
rekarm01
PostPosted: Wed Aug 17, 2011 2:39 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

matuwe wrote:
just to be 100% sure I do understand.. Code for multiple propagate will be.. create message >> Finalize >> Propagate >> clear

Yes.

matuwe wrote:
Code:
// Create New message
content = null;
content = new StringBuffer("");
outMessage = new MbMessage();
outAssembly = new MbMessageAssembly(contact admin,outMessage);
copyMessageHeaders(inMessage, outMessage); // copy headers from the
outRoot = outMessage.getRootElement()).createElementAsLastChild("XMLNSC");

statementData = null;
statementData = getOutputHeaders(outRoot ,currentFile.getName());
Code:
outMessage.finalizeMessage(MbMessage.FINALIZE_NONE);
out.propagate(outAssembly);
outAssembly.getMessage().clearMessage();

More like that.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Java Compute Node Multi Propagage not releasing memory
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.