JavaRanch » Java Forums »
Products »
BEA/Weblogic
| Author |
Suspending/Pausing a MDB's Consumption Programmatically
|
Claudio Martins
Greenhorn
Joined: Jun 18, 2009
Posts: 6
|
|
Hey guys
I have come across a lot of forums saying that there are new methods available from Weblogic 9 that enable the suspension of a MDB's consumption but I can not find any examples of it in. Does anyone by any chance have an example of this?
I am using Weblogic 10.3.
Thanks for any help
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6603
|
|
This is a late reply but might help. The JMX beans that control the destination queue (if I remember correctly or was it the connection factory ?) expose some methods that allow this. I remember writing a batch program that connected to the JMX and did the same but I threw it away sometime back
But hey atleast you know it is possible
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
Claudio Martins
Greenhorn
Joined: Jun 18, 2009
Posts: 6
|
|
That's what you call a sad story!
Thanks for letting me know though
I don't know what to use but this is what I have so far, seems to be getting somewhere...
The problem I have is I don't know what to cast that object as. I know I must somehow use this "weblogic.management.runtime.MessageDrivenEJBRuntimeMBean"
Does it ring any bells?
With the above code I get this compilation error:
"Multiple markers at this line
- The type weblogic.health.HealthFeedback cannot be resolved. It is indirectly
referenced from required .class files
- The type weblogic.management.runtime.RuntimeMBean cannot be resolved. It
is indirectly referenced from required .class files"
It has to do with the line "MessageDrivenEJBRuntimeMBean mdb = (MessageDrivenEJBRuntimeMBean)server.getObjectInstance(ejbName);"
I will carry on updating if I find any solutions, but if anyone can help please do
Thanks again
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6603
|
|
RuntimeMBean
The missing classes can be found in the module directory. I think, I vaguely remember having to import some related JAR files from there (after painstakingly identifying which class belong in which JAR).
Searched for the related operation a little and found this
MDB
The end of the page shows the suspend and resume operations that can be invoked on the bean. I think this is what I executed. I could be wrong though since I did this quite a while back
|
 |
Claudio Martins
Greenhorn
Joined: Jun 18, 2009
Posts: 6
|
|
Thanks Deepak
That's exactly how I got to what I have using those pages. I will carry on trying to tinker with the code
Thanks for all the help
|
 |
Claudio Martins
Greenhorn
Joined: Jun 18, 2009
Posts: 6
|
|
I have found a solution
Here is an example of the code I think is the best option:
Here is another example using a web service instead of a new thread:
First of all, it has to be on its own thread separate from the MDB otherwise the thread will just hang... Secondly I know the context can be used to get the MBeanServer but it gives errors on authorization. That's why it has to be done this way, so that you can set the username and password to be used. The alternative way looks like this for anyone that is interested:
And to further this post, these two sections of code return the exact same thing. So if you are struggling with getting the object name of the message bean you can find out what that is with the first of the next two sections of code:
I will REPEAT, the immediate above two sections do the exact same thing. Please note, the variable "server" in these two sections of code refers to the MBeanServer.
Here are some useful attributes that can be retrieved from the MDB:
I think they all return as Strings. Just check it before you use it
I hope this helps anyone that was in my position!
ENJOY
|
 |
 |
|
|
subject: Suspending/Pausing a MDB's Consumption Programmatically
|
|
|
|