ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General IBM MQ Support » MQ 7 does not close dynamic queue by closing MessageProducer

Post new topic  Reply to topic
 MQ 7 does not close dynamic queue by closing MessageProducer « View previous topic :: View next topic » 
Author Message
issac
PostPosted: Mon Mar 14, 2011 6:59 pm    Post subject: MQ 7 does not close dynamic queue by closing MessageProducer Reply with quote

Disciple

Joined: 02 Oct 2008
Posts: 158
Location: Shanghai

Hello, guys

I've verified the following on WMQ 7.0.1.3 for AIX:

After running the following method, I call Thread.sleep(100000) before calling session.close() and connection.close().

According to what I have observed, OPPROCS value is 1 for the temporary queue created bellow, EVEN THOUGH the producer is already closed.

Code:

   private void repeatedlySendMessage(MQQueueConnection connection, MQQueue requestQ, MQQueueSession session) throws JMSException {
      MessageProducer msgProducer = session.createProducer(requestQ);
      //connection.start();
      // 设定动态队列作为反馈队列
      TemporaryQueue responseQ = session.createTemporaryQueue();
      DevLog.debug("DynamicQ created.");
      //Pauser.pauseThread(1000);
      // 发送一条请求消息
      Message requestMsg = session.createMessage();
      //requestMsg.setJMSReplyTo(responseQ);
      msgProducer.send(requestMsg);
      // 关闭资源
      //responseQ.delete();
      msgProducer.close();
      DevLog.debug("resource closed.");
   }


So why? isn't the queue meant to be closed after closing the producer? If not how could I close the temporary queue?
_________________
Bazinga!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Mar 14, 2011 8:11 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Check it in the documentation but I believe that the lifetime of the temporary queue is the lifetime of the session that created it as long as you do not explicitly delete it.
Note that your responseQ.delete() is commented out.
So the lifetime of that queue is the rest of the lifetime of the session that created it.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
issac
PostPosted: Tue Mar 15, 2011 9:51 pm    Post subject: The Q is not meant to be deleted. Closing the Q is all. Reply with quote

Disciple

Joined: 02 Oct 2008
Posts: 158
Location: Shanghai

Hi,! Thanks for the reply.

But closing the queue is not what I desire. The Q is meant for another application to put some msg inside, thus not suitable for deletion.

You may question then why I wish to close the Q; it's because I wish to decrease the number of handles to the QMGR by eliminating unecessary ones.

Regardless of the reason why I wish to close it, shouldn't I be able to close the temporary Q anyway? Isn't this what MQ shall be capable of?
_________________
Bazinga!
Back to top
View user's profile Send private message
issac
PostPosted: Tue Mar 15, 2011 9:54 pm    Post subject: More to the spiderman... Reply with quote

Disciple

Joined: 02 Oct 2008
Posts: 158
Location: Shanghai

Hi again, spiderman,

You're right that lifetime of the temporary Q is as long as its deletion or termination of the process, depending which one is shorter. BUT, I don't think lifetime of the Q is identical to how long my APP shall open the Q, right?

I desire the state: when the temporaryQ still exists, but without a handle, neither output nor input, from my app. I'm trying to achieve this by closing the Q.
_________________
Bazinga!
Back to top
View user's profile Send private message
exerk
PostPosted: Wed Mar 16, 2011 12:05 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

So don't create a temporary dynamic queue, create a permanent dynamic queue? I'm not a developer so this question is by way of trying to understand the mechanics of it.
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Mar 16, 2011 3:16 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

If you want a queue to exist independently of whether or not an app is writing messages to it or reading messages from it, then you should strongly determine why you are using a DYNAMIC queue at all.

If it is only to avoid using PCF messages inside your app to create the queue, then ask why you are creating the queue inside your app instead.

Why do you want to use a dynamic queue instead of a qlocal?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Mar 16, 2011 1:04 pm    Post subject: Re: More to the spiderman... Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

issac wrote:
Hi again, spiderman,

You're right that lifetime of the temporary Q is as long as its deletion or termination of the process, depending which one is shorter. BUT, I don't think lifetime of the Q is identical to how long my APP shall open the Q, right?

I desire the state: when the temporaryQ still exists, but without a handle, neither output nor input, from my app. I'm trying to achieve this by closing the Q.

To close the queue you correctly close the producer. There is nothing else to do.
If you can prove that YOUR producer is still holding the queue open, open a PMR (trouble ticket) with IBM. Remember however to account for any uncommitted transaction before you do that.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Thu Mar 17, 2011 5:17 am    Post subject: Re: MQ 7 does not close dynamic queue by closing MessageProd Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

issac wrote:
isn't the queue meant to be closed after closing the producer?

No. The msgProducer never opened the response queue; how could it close it?

issac wrote:
I desire the state: when the temporaryQ still exists, but without a handle, neither output nor input, from my app.

Temporary dynamic queues with no open handles get deleted. That's what "temporary" means. More precisely, the handle returned when creating a temporary dynamic queue must remain open for the lifetime of the queue; closing it will automatically delete the queue.

Even if the underlying queue were a permanent dynamic queue, the only methods that JMS provides for closing this handle are TemporaryQueue.delete() and Connection.close(), both of which will also delete the queue. (Note that the lifetime of a TemporaryQueue is that of the Connection, not the Session, unless the TemporaryQueue is deleted earlier.)

A typical sequence of events within a session are:
  • create producer for request queue
  • create temporary response queue
  • create consumer for response queue
  • create request (with replyto response queue)
  • send request
  • close producer
  • receive response
  • close consumer
  • delete temporary response queue
  • close session
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Mar 17, 2011 7:05 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Thanks for the precision. I take it that this means you can share the temporary queue across sessions as long as the connection is alive.

Can you also share it across connections as long as the connection that created it is alive and in a "good" state?

What issac seems to be doing is creating the dynamic queue and never using the reference again... I guess this is just wrong (as a waste of resources)...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Thu Mar 17, 2011 3:04 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

fjb_saper wrote:
I take it that this means you can share the temporary queue across sessions as long as the connection is alive.

Yes. A connection that creates a temporary queue can share it across all of the sessions it creates, for as long as the queue exists. If the connection is no longer alive, then neither are its sessions, or temporary queues.

fjb_saper wrote:
Can you also share it across connections as long as the connection that created it is alive and in a "good" state?

Not exactly. Only the connection that creates a temporary queue can create consumers for it, but other connections can create producers for it, for as long as the queue exists.

fjb_saper wrote:
What issac seems to be doing is creating the dynamic queue and never using the reference again ...

Either that, or he just didn't post the code that uses the queue.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » MQ 7 does not close dynamic queue by closing MessageProducer
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.