|   | 
	 
  
    | 
RSS Feed - WebSphere MQ Support
 | 
RSS Feed - Message Broker Support
 |   
 
  
	     | 
	 | 
   
 
  
	|  Error when using PCF to clear a queue | 
	« View previous topic :: View next topic »  | 
   
  
  	
	  
		
		
		  | Author | 
		  Message
		 |  
		
		  | paul0al | 
		  
		    
			  
				 Posted: Mon Aug 26, 2002 2:38 pm    Post subject: Error when using PCF to clear a queue | 
				     | 
			   
			 
		   | 
		 
		
		   Apprentice
 
 Joined: 30 May 2002 Posts: 26
  
  | 
		  
		    
			  
				I have written a VB program to clear the contents of a queue using PCF. The program compiles and executes without errors, but my queue never gets cleared. I wrote the PCF following the "pcfsamp" example from IBM (included with MQSeries 5.2.1). I'm using Win2k. It would be great if anyone can take a look at the code and tell me what I am doing wrong.
 
 
   
	| Code: | 
   
  
	
 
Private Type PCFCommand
 
    commandHeader As MQCFH
 
    commandParameter As MQCFST
 
    string As String
 
End Type
 
 | 
   
 
 
 
   
	| Code: | 
   
  
	
 
Private Sub clearQueueCommand(ByVal machineName As String)
 
    Dim machine As Collection
 
    Dim Command As PCFCommand
 
    
 
    Set machine = gTargetMachines.Item(machineName)
 
    
 
    MQCFH_DEFAULTS Command.commandHeader
 
    Command.commandHeader.MsgSeqNumber = MQCFC_LAST
 
    Command.commandHeader.Command = MQCMD_CLEAR_Q
 
    Command.commandHeader.ParameterCount = 1
 
    
 
    MQCFST_DEFAULTS Command.commandParameter
 
    Command.commandParameter.StrucLength = MQCFST_STRUC_LENGTH_FIXED + MQ_Q_NAME_LENGTH
 
    Command.commandParameter.Parameter = MQCA_Q_NAME
 
    Command.string = machine.Item("queueName")
 
    Command.commandParameter.StringLength = Len(Command.string)
 
 
    SendPCFCommand Command
 
End Sub
 
 
Private Sub SendPCFCommand(ByRef Command As PCFCommand)
 
    Dim msgDescriptor As MQMD
 
    Dim putOptions As MQPMO
 
    Dim CompCode As Long
 
    Dim Reason As Long
 
    
 
    MQMD_DEFAULTS msgDescriptor
 
    msgDescriptor.ReplyToQMgr = "QM_alert03"
 
    msgDescriptor.MsgType = MQMT_REQUEST
 
    msgDescriptor.ReplyToQ = "SYSTEM.DEFAULT.LOCAL.QUEUE"
 
    msgDescriptor.Format = MQFMT_ADMIN
 
   
 
    MQPMO_DEFAULTS putOptions
 
    putOptions.Options = MQPMO_NO_SYNCPOINT
 
    
 
    MQPUTAny gHandleToTheQueueManager, gHandleToTheQueue, msgDescriptor, putOptions, Len(Command), Command, CompCode, Reason
 
    
 
    If CompCode <> MQCC_OK Then
 
        MsgBox "MQPUTAny failed with " & CompCode
 
    End If
 
    
 
End Sub
 
 | 
   
 
 
 
thanks in advance,
 
paul. | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | jc_squire | 
		  
		    
			  
				 Posted: Mon Aug 26, 2002 5:36 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		    Centurion
 
 Joined: 14 Apr 2002 Posts: 105 Location: New Zealand 
  | 
		  
		    
			  
				Hi Paul,
 
 
Queues cannot be cleared if an application or MCA has them open which could be your problem. 
 
 
Regards _________________ J C Squire
 
IBM Certified Specialist - MQSeries | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | dgolding | 
		  
		    
			  
				 Posted: Mon Aug 26, 2002 11:05 pm    Post subject: Re: Error when using PCF to clear a queue | 
				     | 
			   
			 
		   | 
		 
		
		    Yatiri
 
 Joined: 16 May 2001 Posts: 668 Location: Switzerland 
  | 
		  
		    
			  
				"It would be great if anyone can take a look at the code and tell me what I am doing wrong."
 
 
Well, using Visual Basic for a start    
 
 
Seriously (my VB is crap so maybe I'm getting it wrong):
 
 
What error code do you get on the PUT?
 
Where do you open the queue?
 
 
NB By leaving the ReplyToQManager blank, you're currently connected queue manager is filled in - best practise (saves hard-coding queue manager names). | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | 
		    
		   | 
		 
	   
	 | 
   
 
  
	     | 
	 | 
	Page 1 of 1 | 
   
 
 
 
  
  	
	  
		
		  
 
  | 
		  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
  | 
  		 
	   
	 | 
   
 
  	 | 
	  |