Configure the message listener service using scripting
Use scripting to configure the message listener service.
Configure the message listener service for an application server:
In the following examples, code blocks beginning with wsadmin> show code that is entered by the user. Lines that do not begin with wsadmin> show code that has been returned by the console.
Tasks
- Identify the application server and assign it a variable. For this example the variable is named server.
- Use Jacl:
wsadmin>set server [$AdminConfig getid /Cell:mycell/Node:mynode/Server:server1/]- Use Jython:
wsadmin>server = AdminConfig.getid("/Server:server1/") wsadmin>print server
Example output:
server1(cells/mycell/nodes/mynode/servers/server1|server.xml#Server_1183122130078)- Idenify the message listener service for the server and assign it to a variable. In this example the variable is named mls.
- Use Jacl:
wsadmin>set mls [$AdminConfig list MessageListenerService $server]- Use Jython:
wsadmin>mls = AdminConfig.list('MessageListenerService', server) wsadmin>print mls
Example output:
(cells/mycell/nodes/mynode/servers/server1|server.xml#MessageListenerService_1183122130078)- Modify various attributes with one of the following examples:
- This example command changes the attributes of the thread pool for the message listener service:
- Use Jacl:
wsadmin>$AdminConfig modify $mls {{threadPool {{inactivityTimeout 4000} {isGrowable true} {maximumSize 100} {minimumSize 25}}}}- Use Jython:
wsadmin>AdminConfig.modify(mls, [['threadPool', [['inactivityTimeout', 4000], ['isGrowable', 'true'], ['maximumSize', 100], ['minimumSize', 25]]]])
- Create a listener port using the server and mls variables to provide information about the server and the message listener service:
- Use Jacl:
wsadmin>set new [$AdminConfig create ListenerPort $mls {{name my} {destinationJNDIName di} {connectionFactoryJNDIName jndi/fs}}] wsadmin>$AdminConfig create StateManageable $new {{initialState START}}- Use Jython:
wsadmin>new = AdminConfig.create('ListenerPort',mls,[['name','myLP'] ,['destinationJNDIName','jms/myqueue'],['connectionFactoryJNDIName','jms/myCF']]) wsadmin>print new
Example output:
myLP(cells/mycell/nodes/mynode/servers/server1|server.xml#ListenerPort_1318513831827)- Assign a variable to the 'State Manageable' property on the listener port and use it to change the initialState property on the listener port. In this example the variable is named sm.
- Use Jython:
wsadmin>sm = AdminConfig.list('StateManageable',new) wsadmin>print sm- Example output:
(cells/mycell/nodes/mynode/servers/server1|server.xml#StateManageable_1318513831827)- Use Jython:
wsadmin>AdminConfig.modify(sm,[['initialState','START']])
- Modify a property on the first listener port on the message listener service, using jython.
- Return a list of the listener ports on the message listener service:
wsadmin>lports = AdminConfig.showAttribute(mls,'listenerPorts') wsadmin>print lportsA list of the listener ports on the message listener service is returned in a string:
myLP(cells/mycell/nodes/mynode/servers/server1|server.xml#ListenerPort_1318504021702) myLP1(cells/mycell/nodes/mynode/servers/server1|server.xml#ListenerPort_1318504495 733) myLP2(cells/mycell/nodes/mynode/servers/server1|server.xml#ListenerPort_1318513831827)]- Remove the first and last character of each listener port in the list string, so that wsadmin can use the returned information:
wsadmin>clp = lports[1:len(lports)-1] wsadmin>print clpThe result is returned:
myLP(cells/mycell/nodes/mynode/servers/server1|server.xml#ListenerPort_1318504021702) myLP1(cells/mycell/nodes/mynode/servers/server1|server.xml#ListenerPort_13185044957 33) myLP2(cells/mycell/nodes/mynode/servers/server1|server.xml#ListenerPort_1318513831827)- Select the first listener port in the list:
wsadmin>lport =clp.split(" ")[0] wsadmin>print lportResult:
myLP(cells/mycell/nodes/mynode/servers/server1|server.xml#ListenerPort_1318504021702)- Alter a property on the listener port. In this example the maxRetries property has been altered:
wsadmin>AdminConfig.modify(lport, [['maxRetries', 2]])
- Modify a property on the first listener port on the message listener service, using jacl:
wsadmin>set lports [$AdminConfig showAttribute $mls listenerPorts] wsadmin>set lport [lindex $lports 0] wsadmin>$AdminConfig modify $lport {{maxRetries 2}}
- Save the configuration changes.
- In a network deployment environment only, synchronize the node.
wsadmin AdminConfig Start the wsadmin scripting client Save wsadmin configuration changes Synchronize nodes Commands for the AdminConfig object