Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Suspending/Pausing a MDB's Consumption Programmatically

 
Claudio Martins
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Claudio Martins
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic