Friday, 12 December 2014

Journeys in Python - Day 471 - Setting up WebSphere MQ Messaging Providers

So I've previously written about the fun I had setting up WebSphere Application Server to pull messages from a WebSphere MQ Cluster here: -

This time around, I wanted to streamline my code somewhat, specifically in terms of setting the Native Library Path, as my code wasn't generic enough last time: -

Update WAS MQ Provider to support local bindings ( need to add native path )

AdminTask.manageWMQ('"WebSphere MQ Resource Adapter(cells/bpm85Cell1/nodes/AppSrv01Node/servers/foobar|resources.xml#J2CResourceAdapter_1416556034607)"', '[-nativePath /opt/mqm/java/lib64/ -disableWMQ false ]')

In other words, my code would only work for THAT particular Resource Adapter.

Borrowing from the nice Mr Steven Robinson Esq; -

I produced a small Jython script that does the job: -

servers = AdminUtilities.convertToList(AdminTask.listServers('[-serverType APPLICATION_SERVER ]'))
ras = AdminUtilities.convertToList(AdminConfig.list('J2CResourceAdapter'))

for serverName in servers :
        name = AdminConfig.showAttribute(serverName, "name")
        if name == "server1" :
print name
                for ra in ras :
                        if ra.find(name) > 0:
                                desc = AdminConfig.showAttribute(ra, "description")
                         if desc.find("WebSphere MQ") > 0:
print "Setting native path for " + desc + " on " + name
AdminTask.manageWMQ(ra, '[-nativePath /opt/ibm/mqm/usr/mqm/java/lib64 -disableWMQ false ]')

Obviously I could parameterise it, rather than requiring the server name to be hard-coded, but that's a nice-to-have.


If I run it: -

/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/ -lang jython -user wasadmin -password passw0rd -f foobar.jy 

WASX7209I: Connected to process "server1" on node localhostNode01 using SOAP connector;  The type of process is: UnManagedProcess
Setting native path for WAS Built In WebSphere MQ Resource Adapter on server1

it does the job perfectly: -

1 comment:

Shoshana said...

Thank you so much, this is very helpful

Grokking grep

A colleague was tinkering with grep  and, thanks to him, I discovered a bit more about the trusty little utility. I had not really explored ...