jQuery in Action, 2nd edition*
The moose likes BEA/Weblogic and the fly likes Stop a Queue from consuming messages programatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Stop a Queue from consuming messages programatically" Watch "Stop a Queue from consuming messages programatically" New topic
Author

Stop a Queue from consuming messages programatically

Sagar kanchi
Ranch Hand

Joined: Oct 07, 2005
Posts: 50
Hi all,
I have four queues say Q1 to Q4 and a QueueConnectionFactory.
Can anybody suggest me, how can I stop a specific Queue from consuming messages.

I know we can pause the consumption using weblogic Admin console (I am using Weblogic 9.2) but is there any way to do it Programatically?

For example based on some condition I would like to stop Q2 temporarily while other Queues (Q1,Q2,Q3) remain unchanged.

Thanks in advance


Where there are more wonders there is less knowledge
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Sagar,
You could stop the queue listener. The API for this would be app server specific, so I'll move this to the WebLogic forum for you.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sagar kanchi
Ranch Hand

Joined: Oct 07, 2005
Posts: 50
I tried searching vendor specific API to do this task.
But I couldn't find anything related to this.
If anybody has idea, could you please share it?
Sagar kanchi
Ranch Hand

Joined: Oct 07, 2005
Posts: 50
Hi all,
I could search the API provided by BEA Weblogic and find a way to stop a Queue programtically.

Its very simple. The following are the steps to do so.

Properties env = new Properties();
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
env.put(Context.SECURITY_PRINCIPAL, "username");
env.put(Context.SECURITY_CREDENTIALS, "password");
env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
InitialContext ctx = new InitialContext(env);

Destination queue = (Destination) jndi
.lookup("destiantion JNDI name");

weblogic.management.runtime.JMSDestinationRuntimeMBean destMBean = weblogic.jms.extensions.JMSRuntimeHelper.getJMSDestinationRuntimeMBean(
jndi, queue);

destMBean.pauseConsumption();


That's it.
Maarten Abbring
Greenhorn

Joined: Jun 10, 2011
Posts: 1
Quite elegant if it works.
No problem retrieving the queue from the context. But I can't get the mbean.
What has gone wrong when I'm getting this exception?:

javax.jms.JMSException: JMS Destination runtime mbean not found
at weblogic.jms.extensions.JMSRuntimeHelper.getJMSDestinationRuntimeMBean(JMSRuntimeHelper.java:453)

This problem is giving me headaches. Help is very much appreciated.
Lakshman Gudiwada
Greenhorn

Joined: Nov 30, 2011
Posts: 2
Maarten Abbring wrote:Quite elegant if it works.
No problem retrieving the queue from the context. But I can't get the mbean.
What has gone wrong when I'm getting this exception?:

javax.jms.JMSException: JMS Destination runtime mbean not found
at weblogic.jms.extensions.JMSRuntimeHelper.getJMSDestinationRuntimeMBean(JMSRuntimeHelper.java:453)

This problem is giving me headaches. Help is very much appreciated.


Hi Maarten,

Did you resolve this?
I have the same exception but only when i use distributed Queue, for normal queue this code works perfect.
Please let me know how you got it resolved ..below is my code snippet and exception.
I am on tight deadlines ...i would really appreciate any help, thanks ...!

Destination dest = (Destination)ctx.lookup("jndi.test.DistributedQueue");
weblogic.management.runtime.JMSDestinationRuntimeMBean destMBean =
JMSRuntimeHelper.getJMSDestinationRuntimeMBean(ctx, dest);


EXCEPTION :

javax.jms.JMSException: JMS Destination runtime mbean not found
at weblogic.jms.extensions.JMSRuntimeHelper.getJMSDestinationRuntimeMBean(JMSRuntimeHelper.java:453)

Lakshman Gudiwada
Greenhorn

Joined: Nov 30, 2011
Posts: 2
Guys,

I got this issue resolved ..rather than creating default distributed queues, i created weighted queue so i can assign member queues .
The issue was due to distributed queue being a logical queue, i was not able to query queue information from each managed servers using distributed queue JNDI name.

So i created 2 stand alone queues for each JMS servers and assigned them each to one Managed server each (Also used same JNDI name for member queues)
Now i assigned both member queues to the weighted queue which i created earlier as members.
This way i was able to query each queue status in each managed server. Only thing which needs to be remembered is its cluster environment and the results are dependent on load balancer choosing the managed server.
sudipto shekhar
Ranch Hand

Joined: Apr 02, 2008
Posts: 818

Lakshman Gudiwada wrote:Guys,

I got this issue resolved ..rather than creating default distributed queues, i created weighted queue so i can assign member queues .
The issue was due to distributed queue being a logical queue, i was not able to query queue information from each managed servers using distributed queue JNDI name.

So i created 2 stand alone queues for each JMS servers and assigned them each to one Managed server each (Also used same JNDI name for member queues)
Now i assigned both member queues to the weighted queue which i created earlier as members.
This way i was able to query each queue status in each managed server. Only thing which needs to be remembered is its cluster environment and the results are dependent on load balancer choosing the managed server.


Thanks for posting this solution of yours, Lakshman.....


Regards, Sud.
SCJP 5 ScjpFAQ JLS
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Stop a Queue from consuming messages programatically
 
Similar Threads
Generic assignments
notifyAll and wait methods
WSAD5 + JMS support and external MQ
MDB listens to a queue different from input queue in WAS5.1x
variable scope question/confusion