Java with MQ file transfer


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Java with MQ file transfer

Threaded View

  1. #1
    Join Date
    Jul 2005
    Posts
    20

    Java with MQ file transfer

    The code below does file transfer. I am successful in putting a file into a queue. I can also grab the file from the queue. However in the GET FILE section I am getting the error saying that the path does not exist. The problem is with the retrievedMessage.putApplicationName specified in the path. How do I solve the problem?.
    Code:
    PUT FILE
    
    qMgr = new MQQueueManager(qManager);
    int openOptions = MQC.MQOO_OUTPUT ;
    MQQueue MQ1_RQSTIN = qMgr.accessQueue("QM1.RQSTIN",openOptions);
    MQMessage hello_world = new MQMessage();
    hello_world.putApplicationName = "src_mqsample.txt";
    
    File file = new File("C:\\Documents and Settings\\JCreatorLE\\src_mqsample.txt");
    StringBuffer contents = new StringBuffer();
    BufferedReader reader = null;
    reader = new BufferedReader(new FileReader(file));
    String text = null;
    
    while((text = reader.readLine())!= null) 
    {
    contents.append(text).append(System.getProperty("line.separator"));
    }
    
    MQPutMessageOptions pmo = new MQPutMessageOptions();
    MQ1_RQSTIN.put(hello_world,pmo);
    
    hello_world.writeObject(contents); 
    MQPutMessageOptions pmo = new MQPutMessageOptions();
    MQ1_RQSTIN.put(hello_world,pmo);
    
    MQ1_RQSTIN.close();
    qMgr.disconnect(); 
    
    GET FILE 
    
    qMgr = new MQQueueManager("QM5");
    int openOptions = MQC.MQOO_INPUT_AS_Q_DEF ;
    MQQueue MQ1_RQSTIN = qMgr.accessQueue("QM1.RQSTIN",openOptions);
    MQMessage retrievedMessage = new MQMessage();
    MQGetMessageOptions gmo = new MQGetMessageOptions();
    MQ1_RQSTIN.get(retrievedMessage,gmo);
    
    StringBuffer msg = (StringBuffer) retrievedMessage.readObject();
    FileWriter fn = new FileWriter("C:\\Documents and Settings\\JCreator LE\\MyProjects\\" + "'" + retrievedMessage.putApplicationName + "'");
    fn.write(msg.toString(),0,msg.toString().length()); 
    fn.flush();
    fn.close(); 
    
    MQ1_RQSTIN.close();
    qMgr.disconnect();
    Last edited by Hack; 10-24-2008 at 11:00 AM. Reason: Added Code Tags

Similar Threads

  1. Replies: 8
    Last Post: 11-27-2008, 02:13 AM
  2. Replies: 2
    Last Post: 04-08-2008, 08:29 AM
  3. Java File IO
    By emoos in forum Java
    Replies: 2
    Last Post: 11-03-2005, 07:24 AM
  4. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 06:46 AM
  5. Java Security in File access
    By TA in forum Java
    Replies: 0
    Last Post: 09-01-2000, 08:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center