Creating Weblogic JMS Server (Modules and other resources) using WLST

Overview

In the below scripts, we first connect to the WebLogic Admin Server using connect command. Then we start editing the domain using edit and startEdit commands.

Next, we will create respective JMS services i.e. Server, Modules, Connection Factory, Queues and Topics.

Finally, we save and activate the changes using save and activate commands.

Note: These examples assume that you are already connected to the WebLogic server using WLST. You will need to modify the server name, port number, username, password, and resource names according to your environment.

Creating JMS Server

connect('weblogic', 'welcome1', 't3://localhost:7001')
edit()
startEdit()

cd('/')
cmo.createJMSServer('MyJMSServer')

cd('/JMSServers/MyJMSServer')
cmo.addTarget(getMBean('/Servers/AdminServer'))

save()
activate()

Creating a JMS Module

connect('weblogic', 'welcome1', 't3://localhost:7001')
edit()
startEdit()

cd('/')
cmo.createJMSSystemResource('MyJMSModule')

cd('/JMSSystemResources/MyJMSModule/JmsResource/NO_NAME_0')
cmo.createConnectionFactory('MyConnectionFactory')

cd('/JMSSystemResources/MyJMSModule/JmsResource/NO_NAME_0/ConnectionFactories/MyConnectionFactory')
cmo.setJNDIName('jms/MyConnectionFactory')
cmo.setSubDeploymentName('MyJMSSubDeployment')

cd('/JMSSystemResources/MyJMSModule/JmsResource/NO_NAME_0')
cmo.createQueue('MyQueue')

cd('/JMSSystemResources/MyJMSModule/JmsResource/NO_NAME_0/Queues/MyQueue')
cmo.setJNDIName('jms/MyQueue')
cmo.setSubDeploymentName('MyJMSSubDeployment')

cd('/JMSSystemResources/MyJMSModule/JmsResource/NO_NAME_0')
cmo.createTopic('MyTopic')

cd('/JMSSystemResources/MyJMSModule/JmsResource/NO_NAME_0/Topics/MyTopic')
cmo.setJNDIName('jms/MyTopic')
cmo.setSubDeploymentName('MyJMSSubDeployment')

cd('/JMSSystemResources/MyJMSModule/SubDeployments/MyJMSSubDeployment')
cmo.addTarget(getMBean('/JMSServers/MyJMSServer'))

save()
activate()

Creating a Connection Factory

connect('weblogic', 'welcome1', 't3://localhost:7001')
edit()
startEdit()

cd('/')
cmo.createJMSSystemResource('MyJmsModule')

cd('/JMSSystemResources/MyJmsModule')
set('Targets',jarray.array([ObjectName('com.bea:Name=MyJmsServer,Type=JMSServer')], ObjectName))

cd('/JMSSystemResources/MyJmsModule/JMSResource/MyJmsModule')
cmo.createConnectionFactory('MyConnectionFactory')

cd('/JMSSystemResources/MyJmsModule/JMSResource/MyJmsModule/ConnectionFactories/MyConnectionFactory')
cmo.setJNDIName('jms/MyConnectionFactory')
cmo.setSubDeploymentName('MySubdeployment')

save()
activate()

Creating a JMS Queue and Topic

A JMS queue can be created using create command and set its JNDI name using setJNDIName. Similarly, we will create a JMS topic and set its JNDI name using below WLST script.

connect('<username>','<password>','t3://<hostname>:<port>')
edit()
startEdit()

# Creating a JMS Queue
queueName = 'myQueue'
queueJndiName = 'jms/' + queueName
queue = create(queueName, 'Queue')
queue.setJNDIName(queueJndiName)

# Creating a JMS Topic
topicName = 'myTopic'
topicJndiName = 'jms/' + topicName
topic = create(topicName, 'Topic')
topic.setJNDIName(topicJndiName)

save()
activate()

Setting JMS Server Quotas

connect('weblogic', 'welcome1', 't3://localhost:7001')
edit()
startEdit()

cd('/JMSServers/MyJMSServer')
cmo.setMessagesMaximum(1000)
cmo.setBytesMaximum(10485760)

save()
activate()

These examples demonstrate how to create a JMS server and module, as well as how to set JMS server quotas using WLST scripting for WebLogic

Cheers!!!

About the author

Mohit Chaudhary

Hey there, I am IT enthusiast who is passionate about Middleware, DevOps, Cloud and much more.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *