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 » IBM MQ Java / JMS » Java client iSeries

Post new topic  Reply to topic
 Java client iSeries « View previous topic :: View next topic » 
Author Message
rbreault
PostPosted: Tue Jan 30, 2007 9:57 pm    Post subject: Java client iSeries Reply with quote

Novice

Joined: 23 Jan 2007
Posts: 21

I am writing an application that will get a data file from a lib. This file needs to be sent via MQ with java. I am looking for an example on how to get this file then write it to the queue. I have access to the JTopen toolkit as well. Any help would be great as I am very new to java. I have went through all the examples / Samples and can connect and pass messages that I type when I run the java so now I just need that next step.

Thanks

the Java Newbie
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jan 31, 2007 12:55 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

If you can put messages to a queue by typing, it's a straightforward job to read a file and put the contents using the same mechanism. There are plenty of samples of file reading Java (according to Mr Google).

More a Java question than an MQ one.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mapa
PostPosted: Wed Jan 31, 2007 3:04 am    Post subject: iSeries Infocenter Reply with quote

Master

Joined: 09 Aug 2001
Posts: 257
Location: Malmö, Sweden

If you have not already seen it:
Infocenter Java topic

Check out the IBM Toolbox for Java classes topic or download the pdf.
There are examples that may get you started.
Back to top
View user's profile Send private message Visit poster's website
rbreault
PostPosted: Wed Jan 31, 2007 12:53 pm    Post subject: Reply with quote

Novice

Joined: 23 Jan 2007
Posts: 21

thanks
Back to top
View user's profile Send private message
rbreault
PostPosted: Wed Jan 31, 2007 12:54 pm    Post subject: Here is the problem Reply with quote

Novice

Joined: 23 Jan 2007
Posts: 21

I get this far.


/**
*
*/
package com.arkona.mq.client;

import java.io.IOException;

import com.ibm.as400.access.AS400;
import com.ibm.as400.access.AS400SecurityException;
import com.ibm.as400.access.QSYSObjectPathName;
import com.ibm.as400.access.Record;
import com.ibm.as400.access.SequentialFile;
import com.ibm.mq.*;

/**
* @author rbreault
*
*/
public class Client {

/**
* @param args
*/
public static void main(String[] args) {

// Set up MQ enviorment
MQEnvironment.hostname = "arkona3.arkona.com";
MQEnvironment.channel = "";
MQEnvironment.port = 1414;

// Define a Qmgr Object

MQQueueManager qMgr;


int openOptions = MQC.MQOO_INPUT_SHARED |
MQC.MQOO_OUTPUT;

String queueManagerName = "";
String queueName = "";


try {

// Connect to the Queue Manager

qMgr = new MQQueueManager(queueManagerName);
System.out.println("MQ Connect Successful");

// Open the Queue for input and output

MQQueue IOQUEUE = qMgr.accessQueue(queueName, openOptions, null, null, null);
System.out.println("MQ Open Successful");

// Build The Message


// Create the sequential file object that represents the
// file on the AS/400. We use a QSYSObjectPathName object
// to get the name of the file into the correct format.

AS400 system = new AS400("xxxxx", "robert", "xxxxxx");
system.connectService(AS400.FILE);


QSYSObjectPathName fileName = new QSYSObjectPathName("QIWS", "QCUSTCDT", "FILE");
System.out.println("As400 Datafile");

SequentialFile file = new SequentialFile(system, fileName.getPath());

// Open the File for read-only access. Specify a blacking factor of 10 (the file object will get 50 records
// when it accesses the AS400 for data). Do not use commitment control.

file.open(SequentialFile.READ_ONLY, 50, SequentialFile.COMMIT_LOCK_LEVEL_NONE);

// Read the all records of the file.


Record data = file.read();

// Put data on Queue

MQMessage msgData = new MQMessage();
msgData.

}


}

}



but I cant get past this point any help would be great
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Feb 01, 2007 3:53 pm    Post subject: Reply with quote

Grand High Poobah

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

Looks like you may need to read up on java.io.* and java.nio packages.

I do not know how that interacts with the AS400 file descriptors but I do not expect file.read() to return a record. Have you ever worked with a BufferedReader class ?

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rbreault
PostPosted: Thu Feb 01, 2007 3:59 pm    Post subject: Reply with quote

Novice

Joined: 23 Jan 2007
Posts: 21

Yeah I have slowly figured this out.

I started over with and example for java on the iSeries reading files the a example for writing to MQ so things are starting to look up.

Thanks for the replies
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 » IBM MQ Java / JMS » Java client iSeries
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.