Compare commits
6 Commits
mqsload-1_
...
mqsload-1_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d02756a1f2 | ||
|
|
ff4e50d58c | ||
|
|
9c43a21b50 | ||
|
|
10646d1aed | ||
|
|
44bde69fd5 | ||
|
|
fa0a1f8f73 |
127
MQSLoad.java
127
MQSLoad.java
@@ -1,7 +1,7 @@
|
||||
// $RCSfile: MQSLoad.java,v $
|
||||
// $Revision: 1.3 $
|
||||
// $Revision: 1.4 $
|
||||
// $Name: $
|
||||
// $Date: 2002/04/19 15:22:14 $
|
||||
// $Date: 2002/04/23 15:07:47 $
|
||||
// $Author: giberta1 $
|
||||
|
||||
/*
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
import com.ibm.mq.*;
|
||||
import java.io.*;
|
||||
import java.text.*;
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +42,7 @@ public class MQSLoad
|
||||
private int MsgQ_Open_Options = MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING;
|
||||
private String File_Name;
|
||||
private String Field_Break = "";
|
||||
private String Message_Break = "\n";
|
||||
private String Message_Break = "\r\n";
|
||||
|
||||
|
||||
|
||||
@@ -64,46 +65,47 @@ public class MQSLoad
|
||||
//
|
||||
//-------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public static String Str_Format( String Fmt)
|
||||
public static String Str_Format( String UnFmt)
|
||||
{
|
||||
int idx;
|
||||
boolean esc = false;
|
||||
String result = "";
|
||||
String fmt = "";
|
||||
|
||||
|
||||
for( idx = 0; idx < Fmt.length(); idx++)
|
||||
for( idx = 0; idx < UnFmt.length(); idx++)
|
||||
{
|
||||
if( esc)
|
||||
{
|
||||
switch( Fmt.charAt( idx))
|
||||
switch( UnFmt.charAt( idx))
|
||||
{
|
||||
case '/':
|
||||
case '\\':
|
||||
{
|
||||
result = result + "\\";
|
||||
fmt += "\\";
|
||||
break;
|
||||
}
|
||||
|
||||
case 'n':
|
||||
{
|
||||
result = result + "\n";
|
||||
fmt += "\n";
|
||||
break;
|
||||
}
|
||||
|
||||
case 'r':
|
||||
{
|
||||
result = result + "\r";
|
||||
fmt += "\r";
|
||||
break;
|
||||
}
|
||||
|
||||
case 't':
|
||||
{
|
||||
result = result + "\t";
|
||||
fmt += "\t";
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
result = result + "?";
|
||||
fmt += "?";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,18 +113,71 @@ public class MQSLoad
|
||||
}
|
||||
else
|
||||
{
|
||||
if( Fmt.charAt( idx) == '\\')
|
||||
if( UnFmt.charAt( idx) == '\\')
|
||||
{
|
||||
esc = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = result + Fmt.charAt( idx);
|
||||
fmt += UnFmt.charAt( idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return( result);
|
||||
return( fmt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------------------
|
||||
//
|
||||
//-------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public static String Str_UnFormat( String Fmt)
|
||||
{
|
||||
int idx;
|
||||
String unfmt = "";
|
||||
|
||||
|
||||
for( idx = 0; idx < Fmt.length(); idx++)
|
||||
{
|
||||
switch( Fmt.charAt( idx))
|
||||
{
|
||||
case '\\':
|
||||
{
|
||||
unfmt += "\\\\";
|
||||
break;
|
||||
}
|
||||
|
||||
case '\n':
|
||||
{
|
||||
unfmt += "\\n";
|
||||
break;
|
||||
}
|
||||
|
||||
case '\r':
|
||||
{
|
||||
unfmt += "\\r";
|
||||
break;
|
||||
}
|
||||
|
||||
case '\t':
|
||||
{
|
||||
unfmt += "\\t";
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
unfmt += Fmt.charAt( idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return( unfmt);
|
||||
}
|
||||
|
||||
|
||||
@@ -201,7 +256,7 @@ public class MQSLoad
|
||||
try
|
||||
{
|
||||
QMng = new MQQueueManager( QMng_Name);
|
||||
System.out.println( "QManager Open: (" + QMng + ") !");
|
||||
// System.out.println( "QManager Open: (" + QMng + ") !");
|
||||
}
|
||||
|
||||
catch( Exception Expt)
|
||||
@@ -212,13 +267,13 @@ public class MQSLoad
|
||||
try
|
||||
{
|
||||
MsgQ = QMng.accessQueue( MsgQ_Name, MsgQ_Open_Options, null, null, null);
|
||||
System.out.println( "MsgQ Open: (" + MsgQ + ") !");
|
||||
// System.out.println( "MsgQ Open: (" + MsgQ + ") !");
|
||||
}
|
||||
|
||||
catch( Exception Expt)
|
||||
{
|
||||
QMng.disconnect();
|
||||
System.out.println( "QManager Close: (" + QMng + ") !");
|
||||
// System.out.println( "QManager Close: (" + QMng + ") !");
|
||||
|
||||
throw Expt;
|
||||
}
|
||||
@@ -237,9 +292,9 @@ public class MQSLoad
|
||||
try
|
||||
{
|
||||
MsgQ.close();
|
||||
System.out.println( "MsgQ Close: (" + MsgQ + ") !");
|
||||
// System.out.println( "MsgQ Close: (" + MsgQ + ") !");
|
||||
QMng.disconnect();
|
||||
System.out.println( "QManager Close: (" + QMng + ") !");
|
||||
// System.out.println( "QManager Close: (" + QMng + ") !");
|
||||
}
|
||||
|
||||
catch( Exception Expt)
|
||||
@@ -301,7 +356,7 @@ public class MQSLoad
|
||||
//
|
||||
//-------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
private void Load_File( BufferedInputStream Input_File) throws Exception
|
||||
private int Load_File( BufferedInputStream Input_File) throws Exception
|
||||
{
|
||||
byte input_char;
|
||||
int msg_nb = 0;
|
||||
@@ -413,6 +468,7 @@ public class MQSLoad
|
||||
}
|
||||
|
||||
System.out.println( "\n");
|
||||
return( msg_nb);
|
||||
}
|
||||
|
||||
catch( Exception Expt)
|
||||
@@ -431,12 +487,19 @@ public class MQSLoad
|
||||
|
||||
public MQSLoad( String args[])
|
||||
{
|
||||
int msg_nb;
|
||||
long time_begin, time_end;
|
||||
double time_elapsed, speed;
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if( ( args.length < 2) || ( args.length > 6))
|
||||
{
|
||||
System.out.println( "Usage: MQSLoad [-fb \"field_break\"] [-mb \"message_break\"] <Output_MsgQueue_Name> <Input_File_Name>");
|
||||
System.out.println( " Default: Field Break: (" + Str_UnFormat( Field_Break) + ") Message Break: (" + Str_UnFormat( Message_Break) + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -445,7 +508,7 @@ public class MQSLoad
|
||||
Arg_Parse( args);
|
||||
|
||||
System.out.println( "Output MsgQueue Name: (" + MsgQ_Name + ") Input File Name: (" + File_Name + ")");
|
||||
System.out.println( "Field Break: (" + Field_Break + ") Message_Break: (" + Message_Break + ")");
|
||||
System.out.println( "Field Break: (" + Str_UnFormat( Field_Break) + ") Message Break: (" + Str_UnFormat( Message_Break) + ")");
|
||||
|
||||
MQSInit();
|
||||
|
||||
@@ -455,10 +518,22 @@ public class MQSLoad
|
||||
|
||||
try
|
||||
{
|
||||
System.out.println("Input File Open: (" + input_file + ") !");
|
||||
// System.out.println("Input File Open: (" + input_file + ") !");
|
||||
|
||||
time_begin = System.currentTimeMillis();
|
||||
msg_nb = Load_File( input_file);
|
||||
time_end = System.currentTimeMillis();
|
||||
|
||||
Load_File( input_file);
|
||||
|
||||
time_elapsed = ( time_end - time_begin) / 100.0;
|
||||
speed = msg_nb / time_elapsed;
|
||||
|
||||
nf.setMinimumFractionDigits(2);
|
||||
nf.setMaximumFractionDigits(2);
|
||||
|
||||
System.out.println( "Loaded Message Nb: (" + msg_nb
|
||||
+ ") Elapsed Time: (" + nf.format(time_elapsed)
|
||||
+ ") s Speed: (" + nf.format(speed)
|
||||
+ ") msg/s");
|
||||
}
|
||||
|
||||
catch( Exception Expt)
|
||||
|
||||
54
ReadMe.txt
54
ReadMe.txt
@@ -1,5 +1,55 @@
|
||||
# $RCSfile: ReadMe.txt,v $
|
||||
# $Revision: 1.1 $
|
||||
# $Revision: 1.4 $
|
||||
# $Name: $
|
||||
# $Date: 2001/07/09 15:51:18 $
|
||||
# $Date: 2002/04/23 18:06:55 $
|
||||
# $Author: giberta1 $
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Compilation:
|
||||
------------
|
||||
- Just type: "javac MQSLoad.java" !
|
||||
|
||||
|
||||
|
||||
Installation:
|
||||
-------------
|
||||
|
||||
- You only need the MQSLoad.class file.
|
||||
|
||||
|
||||
|
||||
Notes:
|
||||
------
|
||||
|
||||
- MQSLoad has been tested with MQ/Series 5.2,
|
||||
|
||||
- "-fb" and "-mb" arguments accept a string with formated escape character:
|
||||
+ "\n" for newline,
|
||||
+ "\r" for return,
|
||||
+ "\t" for tabulation,
|
||||
+ "\\" for \.
|
||||
|
||||
- Message break are used for message separation in the batch file, and are striped from the sended message,
|
||||
- Field are striped from the seded message.
|
||||
|
||||
- Windows text files: newline is specified as "\r\n",
|
||||
- Unix text files: newline is specified as "\n".
|
||||
|
||||
- By default:
|
||||
+ There is no field break,
|
||||
+ Message break is "\r\n".
|
||||
|
||||
- This software is under the GNU General Public License. See GNU-GPL.txt.
|
||||
|
||||
|
||||
|
||||
Usage Examples:
|
||||
---------------
|
||||
|
||||
- To load a swift batch file "swift-batch.txt" with "---MESSAGE-BREAK---" message separator into the MQ/Series "SWIFT-QUEUE" use:
|
||||
java MQSLoad -mb "---MESSAGE-BREAK---\r\n" SWIFT-QUEUE swift-batch.txt
|
||||
- To load a csv batch file "batch.csv" with ";" field separator into the MQ/Series "DATA-QUEUE" use:
|
||||
java MQSLoad -fb ";" DATA-QUEUE csv-batch.csv
|
||||
|
||||
@@ -1,5 +1,32 @@
|
||||
# $RCSfile: ReleaseNotes.txt,v $
|
||||
# $Revision: 1.1 $
|
||||
# $Revision: 1.2 $
|
||||
# $Name: $
|
||||
# $Date: 2001/07/09 15:51:18 $
|
||||
# $Date: 2002/04/23 16:18:06 $
|
||||
# $Author: giberta1 $
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
MQSLoad V 1.1.0 - A. Gibert - 23/04/02
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Add string field break and string message break support,
|
||||
Add customisable field break and message break support,
|
||||
Add command line switches "-fb" and "-mb",
|
||||
Add statistics reporting,
|
||||
Add nicer message sending progress indicator,
|
||||
Complete rewrite of the sending engine,
|
||||
Remove some debug print-out,
|
||||
Add GPL and FDL licenses files.
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
MQSLoad V 1.0.0 - A. Gibert - 12/07/01
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
First release,
|
||||
Field break hardcoded to ";",
|
||||
Message break hardcoded to "\r\n".
|
||||
|
||||
Reference in New Issue
Block a user