Author |
Message
|
rbreault |
Posted: Tue Jan 30, 2007 9:57 pm Post subject: Java client iSeries |
|
|
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 |
|
 |
Vitor |
Posted: Wed Jan 31, 2007 12:55 am Post subject: |
|
|
 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 |
|
 |
mapa |
Posted: Wed Jan 31, 2007 3:04 am Post subject: iSeries Infocenter |
|
|
 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 |
|
 |
rbreault |
Posted: Wed Jan 31, 2007 12:53 pm Post subject: |
|
|
Novice
Joined: 23 Jan 2007 Posts: 21
|
|
Back to top |
|
 |
rbreault |
Posted: Wed Jan 31, 2007 12:54 pm Post subject: Here is the problem |
|
|
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 |
|
 |
fjb_saper |
Posted: Thu Feb 01, 2007 3:53 pm Post subject: |
|
|
 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 |
|
 |
rbreault |
Posted: Thu Feb 01, 2007 3:59 pm Post subject: |
|
|
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 |
|
 |
|