Hi,

Jay SenSharma

Jay SenSharma

Many times we want to suspend or resume the MDBs due to some production maintenance. In this case rather than using the AdminConsole we can use WLSTScript to automate the Production maintenance. The best thing to suspend the Message Processing (Message Consumption) is to untarget the MDB Application. Suppose if the MDB is targeted to WebLogic Server “TestServerOne” then using WLST script we need to just untarget the MDB Application. So in this case the Incoming Messages will be still stored in the JMS Queue but they will not be processed by the MDB because the MDBs are not targeted to any Server.

As soon as the Maintenance completes  we can again Target the MDB to the WebLogic Server so that the MDB will again start processing the JMS Messages present inside the JMS Queue. Here is a Simple Demonstration of it:

Step1). Create an MDB application as described in the following Link:   http://middlewaremagic.com/weblogic/?p=1987

Step2). Now Create a Jar file of your MDB then place it inside an EAR file with the following kind of  “MDB_Apps_Ear/META-INF/application.xml” file.

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.4">
<description>Suspending_Resuming MDB Example</description>
<display-name>Suspending_Resuming MDB Example</display-name>

<module>
<ejb>mdb30.jar</ejb>
</module>

</application>

Step3). Now Deploy the EAR application to some Server like AdminServer ..

Step4). Start Sending some Messages using the Program “QueueSend.java” in Step6)  as mentioned in the Above Link:  http://middlewaremagic.com/weblogic/?p=1987

Step5). Now write the following WLST Script somewhere in your FileSystem to Untarget your Deployed EAR application so that it will stop Consuming JMS Messages which are coming to the JMS Queue.

earAppName="MDB_Apps_Ear"
currentTargetOfEAR="AdminServer"

connect('weblogic','weblogic','t3://localhost:7001')
edit()
startEdit()
ls()
cd('/AppDeployments/' + earAppName)
ls()
cmo.removeTarget(getMBean('/Servers/' + currentTargetOfEAR))

save()
activate()

Step6). Now you can write the Following WLST Script to make your MDBs again ready to start Consuming JMS Messages from the JMS Queue by Targeting them back to the WebLogic Server back.

earAppName="MDB_Apps_Ear"
currentTargetOfEAR="AdminServer"

connect('weblogic','weblogic','t3://localhost:7001')
edit()
startEdit()
ls()
cd('/AppDeployments/' + earAppName)
ls()
cmo.addTarget(getMBean('/Servers/' + currentTargetOfEAR))

save()
activate()

NOTE:Suspending One individual MDB from an EAR file is not possible so if your EAR application Contains multiple MDBs then you will have to suspend all the MDBs present in that EAR like above.

Or Whatever MDB you think is requires regular Suspension or Resuming process make them Separate from the Original EAR.

.

.

Thanks

Jay SenSharma

If you enjoyed this post, please considerleaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.