22 Commits

Author SHA1 Message Date
agibert
d882d2a6a1 Add queue manager name option "-qm". 2007-06-05 09:22:43 +00:00
agibert
2c55f4ac61 Add in 1.2.0 entry:
Add queue manager name option "-qm".
2007-06-05 09:21:44 +00:00
giberta1
d327c3e4e9 Add in 1.1.3 entry:
Add version, date and author print out.
2002-05-21 15:55:17 +00:00
giberta1
15b8cece80 Add version, date and author print out. 2002-05-21 15:48:09 +00:00
giberta1
20cc7fc471 Add message tail option "-mt" explanations and example. 2002-05-21 15:22:00 +00:00
giberta1
402f904383 Add 1.1.3 entry:
Add message tail option "-mt",
    Add MQQueueManager() auto retry.
2002-05-21 15:08:37 +00:00
giberta1
f3b64d8cc5 Add message tail option "-mt",
Add MQQueueManager() auto retry.
2002-05-21 15:06:27 +00:00
giberta1
c03202827e Replace SWIFTABORT by SWIFTERROR. 2002-05-21 15:00:45 +00:00
giberta1
5bd41e53ef Add 1.1.2 entry:
Add return code handling.
2002-05-06 09:57:19 +00:00
giberta1
0ffc88e129 Add System.exit() handling. 2002-05-06 09:52:24 +00:00
giberta1
7187b8e088 Initial creation. 2002-05-03 17:26:19 +00:00
giberta1
79e9c52f34 Initial creation. 2002-05-02 17:31:18 +00:00
giberta1
982b8533a1 Add "message breaks are striped by default". 2002-05-02 17:24:15 +00:00
giberta1
895119edc8 Add -kmb description. 2002-05-02 17:22:48 +00:00
giberta1
a886c59026 Add 1.1.1 entry:
Add Keep Message Break support,
    Add -kmb option.
2002-05-02 17:17:28 +00:00
giberta1
eafca20611 Add Keep Message Break support,
Add -kmb option.
2002-05-02 17:09:35 +00:00
giberta1
d02756a1f2 Fix minor spelling bug. 2002-04-23 18:06:55 +00:00
giberta1
ff4e50d58c Add GPL license. 2002-04-23 17:17:14 +00:00
giberta1
9c43a21b50 Add and fill Compilation, Installation, Notes and Usage Examples chapters. 2002-04-23 17:13:45 +00:00
giberta1
10646d1aed Add documentation need. 2002-04-23 16:25:50 +00:00
giberta1
44bde69fd5 Add 1.0.0 and 1.1.0 entries. 2002-04-23 16:18:06 +00:00
giberta1
fa0a1f8f73 Add statistics reporting,
Add Str_UnFormat() method,
Remove some debug print-out.
2002-04-23 15:07:47 +00:00
9 changed files with 10091 additions and 48 deletions

View File

@@ -1,14 +1,14 @@
// $RCSfile: MQSLoad.java,v $
// $Revision: 1.3 $
// $Revision: 1.9 $
// $Name: $
// $Date: 2002/04/19 15:22:14 $
// $Author: giberta1 $
// $Date: 2007/06/05 09:22:43 $
// $Author: agibert $
/*
* MQSLoad.java - Data file to MQ/Series queue loader
* Copyright (C) 2001-2002 Arnaud G. Gibert
* arnaud.gibert@misys.com
* www.miys-ibs.fr
* Copyright (C) 2001-2006 Arnaud G. Gibert
* mailto:arnaud@rx3.net
* http://www.rx3.org/dvp/MQSLoad
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -27,6 +27,7 @@
import com.ibm.mq.*;
import java.io.*;
import java.text.*;
@@ -34,14 +35,20 @@ import java.io.*;
public class MQSLoad
{
private MQQueueManager QMng;
private MQQueueManager QMng = null;
private String QMng_Name = "";
private MQQueue MsgQ;
private String MsgQ_Name;
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";
private String Message_Tail = "";
private boolean Keep_Message_Break = false;
private String MQSLoad_Revision = "$Revision: 1.9 $";
private String MQSLoad_Tag = "$Name: $";
private String MQSLoad_Date = "$Date: 2007/06/05 09:22:43 $";
private String MQSLoad_Author = "$Author: agibert $";
@@ -64,46 +71,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 +119,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);
}
@@ -142,7 +203,19 @@ public class MQSLoad
{
while( argc < args.length)
{
if( args[argc].equals( "-fb"))
if( args[argc].equals( "-qm"))
{
if( argc < ( args.length + 1))
{
QMng_Name = Str_Format( args[++argc]);
}
else
{
System.out.println( "Invalid number of command line options...");
throw new Exception();
}
}
else if( args[argc].equals( "-fb"))
{
if( argc < ( args.length + 1))
{
@@ -166,6 +239,22 @@ public class MQSLoad
throw new Exception();
}
}
else if ( args[argc].equals( "-mt"))
{
if( argc < ( args.length + 1))
{
Message_Tail = Str_Format( args[++argc]);
}
else
{
System.out.println( "Invalid number of command line options...");
throw new Exception();
}
}
else if ( args[argc].equals( "-kmb"))
{
Keep_Message_Break = true;
}
else
{
MsgQ_Name = args[argc++];
@@ -198,27 +287,39 @@ public class MQSLoad
private void MQSInit() throws Exception
{
try
{
QMng = new MQQueueManager( QMng_Name);
System.out.println( "QManager Open: (" + QMng + ") !");
}
short retry = 0;
final short RETRY_MAX = 10;
while( QMng == null)
{
try
{
QMng = new MQQueueManager( QMng_Name);
// System.out.println( "QManager Open: (" + QMng + ") !");
}
catch( Exception Expt)
{
throw Expt;
catch( Exception Expt)
{
System.out.print("!");
if( retry++ > RETRY_MAX)
{
throw Expt;
}
}
}
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 +338,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 +402,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;
@@ -384,6 +485,13 @@ public class MQSLoad
if( next_message <= cur_window_size)
{
// System.out.println( "* Write Msg CurPos: (" + cur_pos + ")");
output_msg.writeString( Message_Tail);
if( Keep_Message_Break)
{
output_msg.writeString( Message_Break);
}
output_msg.messageId = MQC.MQMI_NONE;
MQSPut_Msg( output_msg);
output_msg.clearMessage();
@@ -413,6 +521,7 @@ public class MQSLoad
}
System.out.println( "\n");
return( msg_nb);
}
catch( Exception Expt)
@@ -431,12 +540,22 @@ public class MQSLoad
public MQSLoad( String args[])
{
int msg_nb;
long time_begin, time_end;
double time_elapsed, speed;
NumberFormat nf = NumberFormat.getInstance();
try
{
System.out.println("MQSLoad: " + MQSLoad_Tag + " / " + MQSLoad_Date + " / " + MQSLoad_Author);
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( "Usage: MQSLoad [-qm \"Output_QueueMng_Name\"] [-fb \"field_break\"] [-mb \"message_break\"] [-mt \"message_tail\"] [-kmb] <Output_MsgQueue_Name> <Input_File_Name>");
System.out.println( " Default: Output QueueMng Name: (" + QMng_Name + ") Field Break: (" + Str_UnFormat( Field_Break) + ") Message Break: (" + Str_UnFormat( Message_Break) + ") Message Tail: (" + Str_UnFormat( Message_Tail) + ") Keep Message Break: (" + Keep_Message_Break + ")");
System.exit( 1);
}
else
{
@@ -444,8 +563,8 @@ 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( "Output QueueMng Name: (" + QMng_Name + ") Output MsgQueue Name: (" + MsgQ_Name + ") Input File Name: (" + File_Name + ")");
System.out.println( "Field Break: (" + Str_UnFormat( Field_Break) + ") Message Break: (" + Str_UnFormat( Message_Break) + ") Message Tail: (" + Str_UnFormat( Message_Tail) + ") Keep Message Break: (" + Keep_Message_Break + ")");
MQSInit();
@@ -455,10 +574,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)
@@ -478,6 +609,8 @@ public class MQSLoad
MQSDeInit();
System.out.println( "MQS Load Completed !");
System.exit( 0);
}
}
@@ -485,6 +618,8 @@ public class MQSLoad
{
System.out.println("Exception: (" + Expt + ") !");
Expt.printStackTrace();
System.exit( 1);
}
}
}

View File

@@ -1,5 +1,62 @@
# $RCSfile: ReadMe.txt,v $
# $Revision: 1.1 $
# $Revision: 1.7 $
# $Name: $
# $Date: 2001/07/09 15:51:18 $
# $Date: 2002/05/21 15:22:00 $
# $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 breaks are used for message separation in the batch file,
- Message breaks are striped from the sended message if "-kmb" (keep message break) is not set,
- Message tail specified after "-mt" option is inserted between message and message break,
- Field breaks are striped from the sended 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",
+ Message breaks are striped.
- 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 raw swift batch file "swift-batch-raw.txt" with "}\r\n" message break into the MQ/Series "SWIFT-QUEUE" and by keeping message break separator use:
java MQSLoad -mb "}\r\n" -kmb SWIFT-QUEUE swift-batch-raw.txt
- To load a raw swift batch file "swift-batch-raw.txt" with "}\r\n" message break into the MQ/Series "SWIFT-QUEUE" and by keeping only "}" as end of message use:
java MQSLoad -mb "}\r\n" -mt "}" SWIFT-QUEUE swift-batch-raw.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

View File

@@ -1,5 +1,67 @@
# $RCSfile: ReleaseNotes.txt,v $
# $Revision: 1.1 $
# $Revision: 1.7 $
# $Name: $
# $Date: 2001/07/09 15:51:18 $
# $Author: giberta1 $
# $Date: 2007/06/05 09:21:44 $
# $Author: agibert $
--------------------------------------------------------------------------------
MQSLoad V 1.2.0 - A. Gibert - 05/06/07
--------------------------------------------------------------------------------
Add queue manager name option "-qm".
--------------------------------------------------------------------------------
MQSLoad V 1.1.4 - A. Gibert - 21/05/02
--------------------------------------------------------------------------------
Add message tail option "-mt",
Add MQQueueManager() auto retry,
Add version, date and author print out.
--------------------------------------------------------------------------------
MQSLoad V 1.1.2 - A. Gibert - 06/05/02
--------------------------------------------------------------------------------
Add return code handling.
--------------------------------------------------------------------------------
MQSLoad V 1.1.1 - A. Gibert - 02/05/02
--------------------------------------------------------------------------------
Add Keep Message Break support,
Add -kmb option.
--------------------------------------------------------------------------------
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".

View File

@@ -1,5 +1,12 @@
# $RCSfile: ToDo.txt,v $
# $Revision: 1.1 $
# $Revision: 1.2 $
# $Name: $
# $Date: 2001/07/09 15:51:17 $
# $Date: 2002/04/23 16:25:50 $
# $Author: giberta1 $
- write a better documentation !
- ...

5411
test-swift-batch-big1.txt Normal file

File diff suppressed because it is too large Load Diff

49
test-swift-batch-big2.txt Normal file
View File

@@ -0,0 +1,49 @@
SWIFTOUT
{1:F01BCMAMAMCAXXX0857229951}{2:O1001511000801CICPFRPPAXXX65003436280008011611N}{4:
:20:CIC0001
:32A:000918EUR25062,66
:50:SOCIETE S.A.
PARIS
FRANCE
:57A:BCMAMAMCXXX
:59:I.A.M.
FES
MAROC
:70:/RFB/SOC01901
:71A:BEN
-}{5:{MAC:BCED2F18}{CHK:075B64FB4533}}
---MESSAGE-BREAK---
SWIFTOUT
{1:F01BCMAMAMC1XXX0000000000}{2:I730BNPAFRPPXXXXN}{4:
:20:ELC00001007
:21:TESTS-DL-003
:30:010629
-}
---MESSAGE-BREAK---
SWIFTOUT
{1:F01BCMAMAMC1XXX0000000000}{2:I710BCPCMACCXXXXN}{4:
:27:1/1
:40B:IRREVOCABLE TRANSFERABLE
ADDING OUR CONFIRMATION
:20:ELC00001002
:21:POB00001001
:31C:010328
:31D:010528PARIS
:52A:BARCGB22XXX
:50:SOCIETE ABC
AVENUE DES ALPES
CASABLANCA
:59:HUSUM PLASTIC
:32B:MAD100000,00
:41A:BARCGB22XXX
BY PAYMENT
:43P:NOT ALLOWED
:43T:NOT ALLOWED
:44A:GERMANY
:44B:CASABLANCA
:71B:ALL FOREIGN BANK CHARGES ARE FOR
THE ACCOUNT OF THE BENEFICIARY
:49:WITHOUT
-}
---MESSAGE-BREAK---
SWIFTEND

80
test-swift-batch.txt Normal file
View File

@@ -0,0 +1,80 @@
SWIFTBEGIN
---MESSAGE-BREAK---
SWIFTOUT
{1:F01BCMAMAMCAXXX0857229951}{2:O1001511000801CICPFRPPAXXX65003436280008011611N}{4:
:20:CIC0001
:32A:000918EUR25062,66
:50:SOCIETE S.A.
PARIS
FRANCE
---MESSAGE-BREAK---
SWIFTBEGIN
---MESSAGE-BREAK---
SWIFTOUT
{1:F01BCMAMAMCAXXX0857229951}{2:O1001511000801CICPFRPPAXXX65003436280008011611N}{4:
:20:CIC0001
:32A:000918EUR25062,66
:50:SOCIETE S.A.
PARIS
FRANCE
:57A:BCMAMAMCXXX
:59:I.A.M.
FES
MAROC
:70:/RFB/SOC01901
:71A:BEN
-}{5:{MAC:BCED2F18}{CHK:075B64FB4533}}
---MESSAGE-BREAK---
SWIFTABORT
---MESSAGE-BREAK---
SWIFTBEGIN
---MESSAGE-BREAK---
SWIFTOUT
{1:F01BCMAMAMCAXXX0857229951}{2:O1001511000801CICPFRPPAXXX65003436280008011611N}{4:
:20:CIC0001
:32A:000918EUR25062,66
:50:SOCIETE S.A.
PARIS
FRANCE
:57A:BCMAMAMCXXX
:59:I.A.M.
FES
MAROC
:70:/RFB/SOC01901
:71A:BEN
-}{5:{MAC:BCED2F18}{CHK:075B64FB4533}}
---MESSAGE-BREAK---
SWIFTOUT
{1:F01BCMAMAMC1XXX0000000000}{2:I730BNPAFRPPXXXXN}{4:
:20:ELC00001007
:21:TESTS-DL-003
:30:010629
-}
---MESSAGE-BREAK---
SWIFTOUT
{1:F01BCMAMAMC1XXX0000000000}{2:I710BCPCMACCXXXXN}{4:
:27:1/1
:40B:IRREVOCABLE TRANSFERABLE
ADDING OUR CONFIRMATION
:20:ELC00001002
:21:POB00001001
:31C:010328
:31D:010528PARIS
:52A:BARCGB22XXX
:50:SOCIETE ABC
AVENUE DES ALPES
CASABLANCA
:59:HUSUM PLASTIC
:32B:MAD100000,00
:41A:BARCGB22XXX
BY PAYMENT
:43P:NOT ALLOWED
:43T:NOT ALLOWED
:44A:GERMANY
:44B:CASABLANCA
:71B:ALL FOREIGN BANK CHARGES ARE FOR
THE ACCOUNT OF THE BENEFICIARY
:49:WITHOUT
-}
---MESSAGE-BREAK---
SWIFTEND

4200
test-swift-raw-big.txt Normal file

File diff suppressed because it is too large Load Diff

42
test-swift-raw.txt Normal file
View File

@@ -0,0 +1,42 @@
{1:F01BCMAMAMCAXXX0857229951}{2:O1001511000801CICPFRPPAXXX65003436280008011611N}{4:
:20:CIC0001
:32A:000918EUR25062,66
:50:SOCIETE S.A.
PARIS
FRANCE
:57A:BCMAMAMCXXX
:59:I.A.M.
FES
MAROC
:70:/RFB/SOC01901
:71A:BEN
-}{5:{MAC:BCED2F18}{CHK:075B64FB4533}}
{1:F01BCMAMAMC1XXX0000000000}{2:I730BNPAFRPPXXXXN}{4:
:20:ELC00001007
:21:TESTS-DL-003
:30:010629
-}
{1:F01BCMAMAMC1XXX0000000000}{2:I710BCPCMACCXXXXN}{4:
:27:1/1
:40B:IRREVOCABLE TRANSFERABLE
ADDING OUR CONFIRMATION
:20:ELC00001002
:21:POB00001001
:31C:010328
:31D:010528PARIS
:52A:BARCGB22XXX
:50:SOCIETE ABC
AVENUE DES ALPES
CASABLANCA
:59:HUSUM PLASTIC
:32B:MAD100000,00
:41A:BARCGB22XXX
BY PAYMENT
:43P:NOT ALLOWED
:43T:NOT ALLOWED
:44A:GERMANY
:44B:CASABLANCA
:71B:ALL FOREIGN BANK CHARGES ARE FOR
THE ACCOUNT OF THE BENEFICIARY
:49:WITHOUT
-}