Parsing your .classpath file in Ant

“Don’t you worry how your project gets built, lets us worry about it!”
                                                           -Probably some IBM RAD Engineer

To build and deploy your enterprise applications from RAD (or WSAD, or RSA) you have to run a headless version of your IDE and call special IBM ant tasks that basically say, “Build and Deploy” and your CTO’s favorite IDE then just does it based on your project files. This is fun and all but we now want to instrument all our code with Cobertura as part of our continuous integration project.

One way I figured out how to get access to your project settings is to parse the .classpath file. This is an issue with us because we have 10+ enterprise projects so we can’t just hardcode the path to the SRC folder. Here is how I parse the .classpath file from Ant.

1) Become farmiliar with IBM’s proprietary ANT tasks, and quickly realize they are poorly documented, and will not help:
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.etools.ant.tasks.doc/topics/tantprojectsetbuild.html

2) Install the XML Ant task: http://www.oopsconsultancy.com/software/xmltask/

3) Quickly learn how XPath’s work: http://projects.ischool.washington.edu/tabrooks/545/XMLSurvey/XPathExamples.htm

4) Write a target to parse out the SRC dir:

   
       
           
       

       
   

Scripting Websphere 6.1 configurations, Part 9

Messaging

Part 3

Your service integration bus needs “destinations” (see: Queues). Adding the destinations is easy, but what you do with them later could be more complicated. I am going to assume you want to connect them with JMS Queues (which is also easy).

def addQueue(self, qname):
params = WASConfigParams();
params.add(“bus”, busName);
params.add(“node”, nodeName);
params.add(“server”, serverName);
params.add(“name”, qname);
params.add(“type”, “Queue”);
params.add(“reliability”, “BEST_EFFORT_NONPERSISTENT”);
q = AdminTask.createSIBDestination(params.asString());

Now that your queues have been added, you will have to add a client queue alias. An alias queue is not a queue, but an object that you can use to access another queue.

(@see: http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.amqzag.doc/fa10420_.htm)

def addMQClientQueueAlias(self, targetQueName):
mqClientAliasName = self.makeMQClientAliasName(targetQueName);
log = Log(“SIBusConfig.addMQClientQueueAlias”, mqClientAliasName);
params = WASConfigParams();
params.add(“bus”, busName);
params.add(“aliasBus”, busName);
params.add(“targetBus”, busName);
params.add(“name”, mqClientAliasName);
params.add(“type”, “ALIAS”);
params.add(“targetName”, targetQueName);
qa = AdminTask.createSIBDestination(params.asString());

The next step in completing your messaging application is to create a standard JMS queue connection factory, then create your JMS queues, and tie them to your SIB Destinations. I will show you how to do that in my next post.

Scripting Websphere 6.1 configurations, Part 8

Messaging

Part 2

Setting up the SIBus (Service Integration Bus) is fairly trivial. For this activity that needs to be performed first, below are the examples.

def create(self):
params = WASConfigParams();
params.add(“bus”, self.busName);
params.add(“busSecurity”, “false”);
AdminTask.createSIBus(params.asString());

After the SIBus has been created. You create a Bus Member. There are probably good reasons why this is a separate exercise but I haven’t stumbled upon the reason.

def addServerMember(self):
params = WASConfigParams();
params.add(“bus”, self.busName);
params.add(“node”, self.wasDef.nodeName);
params.add(“server”, self.wasDef.serverName);
params.add(“fileStore”, “”);
params.add(“logSize”, 10);
params.add(“minPermanentStoreSize”, 10);
params.add(“maxPermanentStoreSize”, 500);
params.add(“minTemporaryStoreSize”, 10);
params.add(“maxTemporaryStoreSize”, 500);
AdminTask.addSIBusMember(params.asString());

This third task, albeit optional, is necessary if you wish to connect to your queues using third party tools for monitoring and debugging. I recommend it.

Note: The qmName HAS to follow the below naming convention. Don’t ask why.

def createMQClientLink(self):
msgEngine = self.getMessagingEngine();
params = WASConfigParams();
params.add(‘name’, self.mqClientLinkName);
params.add(‘channelName’, “WAS.JMS.SVRCONN”);
params.add(“qmName”, “WAS_” + self.wasDef.nodeName + “_” + self.wasDef.serverName);
params.add(“defaultQM”, “true”);
params.add(“maxMsgSize”,”4194304″);
params.add(“heartBeat”, “300”);
AdminConfig.create(‘SIBMQClientLink’, msgEngine, params.asList());

The few posts will finish off with examples of creating SIQueues and tying them to JMS Queue’s and a Queue Connection Factory. Then I will show examples of creating Activation Specs.