| Author | 
		  Message
		 | 
		
		  | asudhakar | 
		  
		    
			  
				 Posted: Mon Jul 27, 2009 3:48 am    Post subject: Java Prog to read msg | 
				     | 
			   
			 
		   | 
		
		
		    Centurion
 
 Joined: 12 May 2007 Posts: 116 Location: Bangalore 
  | 
		  
		    
			  
				Hi 2 All,
 
 
Im planning to write a java program to read a msg from queue...
 
 
I am trying with pkg : com.ibm.mq PKg.... 
 
 
Can we write same thing in PCF commands. Can any one give suggestion how to use PCF commands... 
 
 
Thanks
 
 
//Get msg
 
 
import com.ibm.mq.*;
 
import java.io.*;
 
 
public class GetMsg {
 
	public static void main(String[] args) {
 
		try
 
		{
 
			GetMessage gett= new GetMessage();
 
			gett.Get();
 
		}
 
		catch(Exception e)
 
		{
 
			System.out.println("Error Msg"+e.getMessage());
 
		}
 
	}
 
}
 
class GetMessage
 
{
 
	public void Get()
 
	   {
 
		try{
 
 
		System.out.println( "Getting Messages from the the Queues" );
 
		MQQueueManager qmgr1=null;
 
		MQQueue que=null;
 
		int openOptions =  MQC.MQOO_INPUT_AS_Q_DEF ;
 
		qmgr1 = new MQQueueManager("SUDHA");
 
		que = qmgr1.accessQueue("QIN",openOptions,null,null,null);
 
		MQMessage out=new MQMessage();
 
		out.format = MQC.MQFMT_REF_MSG_HEADER;
 
		que.get(out);
 
		FileOutputStream fos = new FileOutputStream("c:\\mqout.dat");
 
		DataOutputStream dos = new DataOutputStream(fos);
 
		dos.writeBytes(out.readStringOfByteLength(out.getMessageLength()));
 
		System.out.println( "Successful : CHECK c:\\mqout.dat FILE for msg" );
 
	   }
 
		catch(Exception e)
 
		{
 
			e.printStackTrace(System.err);
 
		}
 
		}
 
 
} _________________ WebSphere MQ, MB Support and Admin
  Last edited by asudhakar on Mon Jul 27, 2009 3:59 am; edited 1 time in total | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | asudhakar | 
		  
		    
			  
				 Posted: Mon Jul 27, 2009 3:51 am    Post subject: Re: Java Prog to read msg | 
				     | 
			   
			 
		   | 
		
		
		    Centurion
 
 Joined: 12 May 2007 Posts: 116 Location: Bangalore 
  | 
		  
		    
			  
				import com.ibm.mq.*;
 
import java.io.*;
 
 
public class PutMsg {
 
	public static void main(String[] args) {
 
		try
 
		{
 
			//Queue Manager properties
 
			MQEnvironment.hostname = "localhost";
 
			MQEnvironment.port = 5555;
 
			MQEnvironment.channel = "SYSTEM.DEF.SVRCONN";
 
			String qName = "QIN";
 
 
			MQQueueManager qmgr = new MQQueueManager("SUDHA");
 
			System.out.println("\n\t\tQueue Manager Name : "+qmgr.name);
 
			System.out.println("\t\t----------------------------");
 
 
			int openOptions = MQC.MQOO_SET|MQC.MQOO_INQUIRE;
 
			MQQueue queue = qmgr.accessQueue(qName, openOptions);
 
	        System.out.print("\nCurrent Depth before put message : "+queue.getCurrentDepth());
 
 
 
			MQMessage mes=new MQMessage();
 
			mes.writeBytes(new String("Sudhakar from middleware"));
 
			qmgr.put(qName,mes);
 
 
			System.out.print("\nCurrent Depth after put message : "+queue.getCurrentDepth());
 
 
 
		    qmgr.close();
 
		}
 
		catch(Exception e)
 
		{
 
			System.out.println("Error Msg"+e.getMessage());
 
		}
 
	}
 
} _________________ WebSphere MQ, MB Support and Admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | smdavies99 | 
		  
		    
			  
				 Posted: Mon Jul 27, 2009 6:12 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land. 
  | 
		  
		    
			  
				Take a look at the sample apps that get supplied with WMQ. 
 
 
These are very useful to use as the basis of some 'quick & dirty' apps to help in dev/test _________________ WMQ User since 1999
 
MQSI/WBI/WMB/'Thingy' User since 2002
 
Linux user since 1995
 
 
 
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | asudhakar | 
		  
		    
			  
				 Posted: Mon Jul 27, 2009 8:06 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Centurion
 
 Joined: 12 May 2007 Posts: 116 Location: Bangalore 
  | 
		  
		    
			  
				
   
	| smdavies99 wrote: | 
   
  
	Take a look at the sample apps that get supplied with WMQ. 
 
 
These are very useful to use as the basis of some 'quick & dirty' apps to help in dev/test | 
   
 
 
 
Thank U smdavies.. I wil look into the samples. _________________ WebSphere MQ, MB Support and Admin | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | PeterPotkay | 
		  
		    
			  
				 Posted: Tue Jul 28, 2009 12:52 pm    Post subject: Re: Java Prog to read msg | 
				     | 
			   
			 
		   | 
		
		
		    Poobah
 
 Joined: 15 May 2001 Posts: 7723
  
  | 
		  
		    
			  
				
   
	| asudhakar wrote: | 
   
  
	| Can any one give suggestion how to use PCF commands...  | 
   
 
 
There is a whole manual dedicated to PCF commands in the MQ Info Centers. _________________ Peter Potkay
 
Keep Calm and MQ On | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |