| Author | 
		  Message
		 | 
		
		  | JohnRodey | 
		  
		    
			  
				 Posted: Mon May 16, 2005 1:01 pm    Post subject: Swapping messages based on priority to a full queue | 
				     | 
			   
			 
		   | 
		
		
		    Centurion
 
 Joined: 13 Apr 2005 Posts: 103
  
  | 
		  
		    
			  
				If a queue is full and an application wishes to place a high priority message on the queue, is there a way to tell mq to trash a low priority message and put this message in place of it.
 
 
I would like to find way to do the deletion of the low priority message and the put of the high priority message simultaneously, because if I manually delete a message from the queue another request might come in to place a message on the queue (and be successful, since now there is an empty slot) prior to my message being posted.
 
 
Thanks for any help in advance | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | fjb_saper | 
		  
		    
			  
				 Posted: Mon May 16, 2005 3:05 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 18 Nov 2003 Posts: 20768 Location: LI,NY 
  | 
		  
		    
			  
				| What is your message delivery option for the queue: priority or FIFO ?? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | JohnRodey | 
		  
		    
			  
				 Posted: Tue May 17, 2005 4:37 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Centurion
 
 Joined: 13 Apr 2005 Posts: 103
  
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | JT | 
		  
		    
			  
				 Posted: Tue May 17, 2005 6:25 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Padawan
 
 Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT. 
  | 
		  
		    
			  
				
   
	| Quote: | 
   
  
	| If a queue is full and an application wishes to place a high priority message on the queue, is there a way to tell mq to trash a low priority message and put this message in place of it.  | 
   
 
 
AFAIK, no.
 
   
	| Quote: | 
   
  
	| I would like to find way to do the deletion of the low priority message and the put of the high priority message simultaneously, because if I manually delete a message from the queue another request might come in to place a message on the queue (and be successful, since now there is an empty slot) prior to my message being posted | 
   
 
 
I'm not 100% sure, but wouldn't this work if you put the get and the put in the same unit of work, and then issued the MQCMIT? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | JohnRodey | 
		  
		    
			  
				 Posted: Fri May 20, 2005 3:35 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Centurion
 
 Joined: 13 Apr 2005 Posts: 103
  
  | 
		  
		    
			  
				Thanks JT for your response.
 
 
I thought what you said made sense so I tried it.  I issued a get and put prior to disconnecting from the manager (with a sleep between the get and put).  I figured either 2 things could happen.  
 
 
Since the "got" message could still be backed out to the Q I wasn't sure if it (1) remained on the Q and was just blocked from other applications trying to get messages or if (2) it was physically taken off the Q (leaving an empty spot) and if a backout was called then just placed back on Q in the empty spot.
 
 
if (1) was true then could the put find a spot on the queue to place its message? And if (2) then could any application fill that spot?
 
 
I tried it and it turns out 2 is true.  When an application pulls these messages from the queue there is an empty spot created on the queue that any application can place a message on.  So, even if prior to disconnecting from the QM (or committing) doing a get then a put, after a get there is a slice of time (granted a very small slice) in which other puts can come along and steal that open spot on the Q.
 
 
This now makes me wonder...
 
If you do a get on a poison message and have to backout that message but that queue could now be full since its spot could have been overwritten, it seems the backout would most likely fail.  I haven't tried this scenario, but if that's true It doesn't seem like the desired fundtionality. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | jefflowrey | 
		  
		    
			  
				 Posted: Fri May 20, 2005 4:05 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Poobah
 
 Joined: 16 Oct 2002 Posts: 19981
  
  | 
		  
		    
			  
				
   
	| JohnRodey wrote: | 
   
  
	This now makes me wonder...
 
If you do a get on a poison message and have to backout that message but that queue could now be full since its spot could have been overwritten, it seems the backout would most likely fail.  I haven't tried this scenario, but if that's true It doesn't seem like the desired fundtionality. | 
   
 
 
 
I would be surprised if the second put succeeded.  Messages in transaction still count in queue depth - and probably for just this reason.
 
 
So if you have a queue that is 100% full, and you get a message in transaction, the queue depth will still be 100% - and so a put should fail. _________________ I am *not* the model of the modern major general. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | JohnRodey | 
		  
		    
			  
				 Posted: Fri May 20, 2005 11:05 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Centurion
 
 Joined: 13 Apr 2005 Posts: 103
  
  | 
		  
		    
			  
				| I agree jeff and I thought that as well, although I tried this and it does seem to allow the put even though the get wasn't committed.  Although it is always possible that I did something wrong in my test, so if anyone finds different results then I would be interested in hearing them. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |