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 » delete all under execution group using CMP api

Post new topic  Reply to topic
 delete all under execution group using CMP api « View previous topic :: View next topic » 
Author Message
paustin_ours
PostPosted: Fri Aug 14, 2015 11:57 am    Post subject: delete all under execution group using CMP api Reply with quote

Yatiri

Joined: 19 May 2004
Posts: 667
Location: columbus,oh

I cant seem to be able to get this to work. Please help.

Say I have 4 flows deployed under an EG, There is a jar file called common.jar that gets deployed with each of the 4 flows. Each deploy overwrites the jar I would think.

Now when I want to remove a flow, I don't want to remove the jar unless this is the last flow under the EG in which case I want to wipe it clean.

I am trying to get this to work using CMP API.

This is what I have I have tried

First I get a list of all deployed objects
Code:

Enumeration<DeployedObject> depObjs = null;
depObjs = eg.getDeployedObjects();



Then I get a count to initialize a DeployedObjects array

Code:

while(depObjs.hasMoreElements()){
DeployedObject depO =depObjs.nextElement();
depCnt = depCnt +1;
}


depCnt holds the count
Now I initialize a DeployedObject Array
Code:

DeployedObject[] depObjArray = new DeployedObject[depCnt];


Then I loop through the deployed objs enumeration again to populate the array
Code:

while (depObjs.hasMoreElements()){
DeployedObject depO =depObjs.nextElement();
depObjArray[arrayCnt] = depO;
arrayCnt = arrayCnt +1;
}


Now when I have just one flow and one jar left, I see them in the array that I just populated, I see one object as messageflowProxy and another one as messageDependant..something like that

Anyway, now when I try to use this array to remove everything under the EG using the below

Code:

 deployResult = eg.deleteDeployedObjects(depObjArray, DeployVariables.deployTimeOutSecs);


It fails deploy. All I see in the deployresult is the failure to deploy message nothing more. Not sure what I am doing wrong here.
Back to top
View user's profile Send private message Yahoo Messenger
mqjeff
PostPosted: Fri Aug 14, 2015 12:27 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Shouldn't you be able to get the array to tell you how many elements it has...

?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Aug 14, 2015 12:58 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Have you checked the content of your array and any of the sublevels.
I have not played with delete yet, but there are many levels below the eg and you need to check what you can delete, and you need to delete it, like if you were doing it through the broker explorer (or the web proxy).

  • eg
    • applications
      • flows
      • libraries
        • flows
        • message models
        • message sets

      • message models
      • message sets

    • flows
    • message models
    • message sets


Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
paustin_ours
PostPosted: Fri Aug 14, 2015 1:59 pm    Post subject: Reply with quote

Yatiri

Joined: 19 May 2004
Posts: 667
Location: columbus,oh

I think I understand what you are saying.

The EG currently has one flow (.cmf) and one jar(common.jar)

when I do the eg.getDeployedObjects(); I see only these two.

then I build my depObjArray array which also only has two entires.
both are of type deployedObject. Like I had mentioned one is of type messageflowproxy(.cmf file) and the other one for the java jar.

Now as per the API documentation I just need to pass this array to the delete command. that is what I did but doesn't work.
Back to top
View user's profile Send private message Yahoo Messenger
mqjeff
PostPosted: Mon Aug 17, 2015 4:31 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Is there a specific reason you don't want to simply delete and recreate the EG itself?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Aug 17, 2015 4:53 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

paustin_ours wrote:
I think I understand what you are saying.

The EG currently has one flow (.cmf) and one jar(common.jar)

when I do the eg.getDeployedObjects(); I see only these two.

then I build my depObjArray array which also only has two entires.
both are of type deployedObject. Like I had mentioned one is of type messageflowproxy(.cmf file) and the other one for the java jar.

Now as per the API documentation I just need to pass this array to the delete command. that is what I did but doesn't work.

Care to share some code?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
paustin_ours
PostPosted: Mon Aug 17, 2015 5:26 am    Post subject: Reply with quote

Yatiri

Joined: 19 May 2004
Posts: 667
Location: columbus,oh

Code:


   try {
         if (b == null){
         b = BrokerProxy.getLocalInstance(brokerName);
         }
         if (!b.hasBeenPopulatedByBroker(true)) {
            LogDeployMessage.deployLog("ERROR", "Broker not responding");
            LogDeployMessage.deployLog("ERROR", "Quitting deploy step");
            System.exit(-1);
         }

                if (request == "remove") {
                  String egName = removeProperties.getProperty(barName);
                  String[] flowName = { barName.replace("bar", "cmf") };
                  LogDeployMessage.deployLog("INFO",
                        "About to remove message flow " + flowName);
                  if (prevEgName == egName) {
                  } else {
                     eg = b.getExecutionGroupByName(egName);
                     prevEgName = egName;
                  }
                  if (eg == null) {
                     LogDeployMessage.deployLog("ERROR",
                           "Execution group " + egName
                                 + " not found to remove the flow"
                                 + flowName);
                     try {
                        if (bwremove == null) {
                           bwremove = new BufferedWriter(new FileWriter(
                                 removeRetryFile, true));
                        }
                        bwremove.write(barName + "=" + egName);
                        bwremove.newLine();
                     } catch (IOException e) {
                        LogDeployMessage.deployLog("ERROR",
                              "Unable to include flow name to remove retry list "
                                    + barName + " " + egName);
                        LogDeployMessage.deployLog("ERROR", "Reason: "
                              + e.toString());
                     }
                  } else {
                     // Deploy the BAR file and display the result
                     LogDeployMessage.deployLog("INFO", "Removing "
                           + flowName + " from Execution group "
                           + egName);
                     Integer arrayCnt = 0;
                     Integer cmfCount = 0;
                     Integer depCnt = 0;
                     Enumeration<DeployedObject> depObjs = null;
                        depObjs = eg.getDeployedObjects();
                     //DeployedObject[] depObjArray = new DeployedObject[10];
                     Boolean flowFound = false;
                     while(depObjs.hasMoreElements()){
                        DeployedObject depO =depObjs.nextElement();
                        //depObjArray[arrayCnt] = depO;
                        //arrayCnt = arrayCnt +1;
                        depCnt = depCnt +1;
                        System.out.println(depO.getFullName());
                        if (depO.getFullName().equals(flowName[0])){
                           flowFound = true;
                        }
                        if (depO.getFullName().contains("cmf")){
                        cmfCount = cmfCount +1;
                        }
                     }
                     DeployedObject[] depObjArray = new DeployedObject[depCnt];
                     depObjs = eg.getDeployedObjects();
                     while (depObjs.hasMoreElements()){
                        DeployedObject depO =depObjs.nextElement();
                        depObjArray[arrayCnt] = depO;
                        arrayCnt = arrayCnt +1;
                     }
                     DeployResult deployResult = null;
                     if (cmfCount == 1 && flowFound == true){
                         deployResult = eg.deleteDeployedObjects(depObjArray, DeployVariables.deployTimeOutSecs);
                     }

Back to top
View user's profile Send private message Yahoo Messenger
paustin_ours
PostPosted: Mon Aug 17, 2015 9:40 am    Post subject: Reply with quote

Yatiri

Joined: 19 May 2004
Posts: 667
Location: columbus,oh

Oh well finally got it to work using deleteDeployedObjectsByName
Back to top
View user's profile Send private message Yahoo Messenger
Vitor
PostPosted: Mon Aug 17, 2015 10:37 am    Post subject: Reply with quote

Grand High Poobah

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

paustin_ours wrote:
Oh well finally got it to work using deleteDeployedObjectsByName


Care to post the finished code (or at least an obfuscated sample) for the benefit of future readers?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
paustin_ours
PostPosted: Mon Aug 17, 2015 12:22 pm    Post subject: Reply with quote

Yatiri

Joined: 19 May 2004
Posts: 667
Location: columbus,oh

Code:
while (depObjs.hasMoreElements()) {
                        DeployedObject depO = depObjs.nextElement();
                        deployedObjNames.add(depO.getFullName());
                        System.out.println(depO.getFullName());
                        if (depO.getFullName().equals(flowName[0])) {
                           flowFound = true;
                        }
                        if (depO.getFullName().contains("cmf")) {
                           cmfCount = cmfCount + 1;
                        }
                     }
                     DeployResult deployResult = null;
                     //if only one flow is found and we are trying to remove that one flow, we remove all the dependent components along with it.
                     if (cmfCount == 1 && flowFound == true) {

                        String[] array = deployedObjNames
                              .toArray(new String[deployedObjNames
                                    .size()]);
                        deployResult = eg
                              .deleteDeployedObjectsByName(
                                    array,
                                    DeployVariables.deployTimeOutSecs * 1000); // wait


there you go
Back to top
View user's profile Send private message Yahoo Messenger
Vitor
PostPosted: Mon Aug 17, 2015 12:23 pm    Post subject: Reply with quote

Grand High Poobah

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


_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Aug 17, 2015 2:26 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Looks fine, but did you try it with
dpo.getName() for populating your array instead of dpo.getFullName()???

You might also want to look at the getFileExtension() method...

Now other things to check: Do you have somewhere a beginUpdate() that would prevent the updates from happening immediately?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » delete all under execution group using CMP api
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.