Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Stop a Queue from consuming messages programatically

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
author & internet detective
Posts: 40200
816
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sagar kanchi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 2
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 826
Eclipse IDE Oracle Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.....
 
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic