File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how do i remove consumers on a queue

 
robert stevens
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am dynamically setting up a jms queue which i use to talk across 2 different jvms. Now when i try to delete that queue i get a big fat exception ... the essence of which is as below

ERROR [ORB-Worker-7] - Failed to remove destination=aqueue
javax.jms.JMSException: Cannot delete destination aqueue-true since there are active consumers.
aqueue is the name of the queue that i create.

Now i before i remove the queue i do probe the jms to find if it exists as below

JMSAdministrator jmsAdministratorInstance = JMSAdministrator.getInstance();
if(jmsAdministratorInstance.queueExists(queueName)

on finding that the queue i remove the active consumers by the following

Vector<String> consumerVector = new Vector();
try {
consumerVector= this.handleToAdminServer.getDurableConsumers(queueName);
//assumes no more than 100 consumers....
String[] consumerArray = new String[100];
consumerVector.copyInto(consumerArray);
int i=0;
while (i< consumerArray.length)
{
System.out.println("Consumer name :- " + consumerArray[i]);
if(this.handleToAdminServer.removeDurableConsumer(consumerArray[i]))
{
System.out.println("Successfully removed consumer " + consumerArray[i]);
}
if(this.handleToAdminServer.unregisterConsumer(consumerArray[i]))
{
System.out.println("Successfully deactivated " + consumerArray[i]);
}
i++;
}
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}


after having removed the consumers i go ahead to remove the queue by the following
try {
this.handleToAdminServer.removeDestination(queueName);
this.listOfAactiveQueues.remove(queueName);
} catch (JMSException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


now my program runs properly but the openjms (which i have opened in a linux terminal) throws the excetption which i have mentioned on top. Now i am a totally novice in the area. Can anyone please help me out.
 
robert stevens
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
problem solved \m/
 
Scott Selikoff
author
Saloon Keeper
Posts: 3905
16
Eclipse IDE Flex Google Web Toolkit
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not share your solution so others with a similar problem might benefit?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic