17 Commits

Author SHA1 Message Date
agibert
7bc0510954 Fix usage print out. 2008-01-03 13:46:01 +00:00
agibert
d46511d384 Add sleep time option "-st". 2007-12-11 16:50:50 +00:00
agibert
81f82b947f Add in 1.2.0 entry:
Add queue manager name option "-qm".
2007-06-05 09:29:21 +00:00
agibert
51a031b7ae Add queue manager name option "-qm". 2007-06-05 09:27:44 +00:00
giberta1
67d8b5f6c4 Add 1.1.5 entry. 2003-09-04 15:47:10 +00:00
giberta1
4bdbc1e2e1 Add Copy Mode (-cm). 2003-09-04 15:42:41 +00:00
giberta1
bf636a2cea Add -mbtm switch,
Implement message break trailer mode.
2002-11-14 13:40:24 +00:00
giberta1
00a78ea920 Add 1.1.4 entry:
Fix trim mode when tisbm off.
2002-07-29 10:00:03 +00:00
giberta1
675a925c00 Add trim_mode support whan TI swift batch mode off. 2002-07-29 09:56:18 +00:00
giberta1
33b67fe311 Add trim mode ("-tm") explanations. 2002-05-21 16:07:17 +00:00
giberta1
9174e00abe Add 1.1.3 entry:
Add trim mode support,
    Add "-tm" option,
    Add MQQueueManager() auto retry,
    Fix flush file name bad parsing bug,
    Add version, date and author print out.
2002-05-21 16:03:38 +00:00
giberta1
f390c41e76 Add version, date and author print out. 2002-05-21 15:44:45 +00:00
giberta1
e807001586 Add trim mode support,
Add "-tm" option,
Add MQQueueManager() auto retry,
Fix flush file name bad parsing bug.
2002-05-21 15:36:28 +00:00
giberta1
b3f10a6962 Add 1.1.2 entry:
Rename SWIFTABORT into SWIFTERROR,
    Add Legend printout line.
2002-05-13 16:38:12 +00:00
giberta1
49d568238e Rename SWIFTABORT message into SWIFTERROR,
Add legend message.
2002-05-13 16:28:02 +00:00
giberta1
a4bb9a9f1b Add 1.1.1 entry:
Add return code handling.
2002-05-06 10:00:34 +00:00
giberta1
781932ee0c Add System.exit() handling. 2002-05-06 09:51:49 +00:00
3 changed files with 266 additions and 41 deletions

View File

@@ -1,14 +1,14 @@
// $RCSfile: MQSSave.java,v $ // $RCSfile: MQSSave.java,v $
// $Revision: 1.4 $ // $Revision: 1.14 $
// $Name: $ // $Name: $
// $Date: 2002/05/03 17:12:58 $ // $Date: 2008/01/03 13:46:01 $
// $Author: giberta1 $ // $Author: agibert $
/* /*
* MQSSave.java - MQ/Seires queue to data file saver * MQSSave.java - MQ/Series queue to data file saver
* Copyright (C) 2002 Arnaud G. Gibert * Copyright (C) 2001-2006 Arnaud G. Gibert
* arnaud.gibert@misys.com * mailto:arnaud@rx3.net
* www.misys.com * http://www.rx3.org/dvp/MQSLoad
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@@ -35,7 +35,7 @@ import java.text.*;
public class MQSSave public class MQSSave
{ {
private MQQueueManager QMng; private MQQueueManager QMng = null;
private String QMng_Name = ""; private String QMng_Name = "";
private MQQueue MsgQ; private MQQueue MsgQ;
private String MsgQ_Name; private String MsgQ_Name;
@@ -43,7 +43,16 @@ public class MQSSave
private String Output_File_Name, Flush_File_Name = "flush.txt"; private String Output_File_Name, Flush_File_Name = "flush.txt";
private String Message_Break = "\r\n"; private String Message_Break = "\r\n";
private boolean TI_Swift_Batch_Mode = false; private boolean TI_Swift_Batch_Mode = false;
private boolean Copy_Mode = false;
private boolean Trim_Mode = false;
private boolean MBTrailer_Mode = false;
private int Total_Nb = 0, Moved_Nb = 0, Skiped_Nb = 0, Scaned_Nb = 0, Flushed_Nb = 0; private int Total_Nb = 0, Moved_Nb = 0, Skiped_Nb = 0, Scaned_Nb = 0, Flushed_Nb = 0;
private String MQSSave_Revision = "$Revision: 1.14 $";
private String MQSSave_Tag = "$Name: $";
private String MQSSave_Date = "$Date: 2008/01/03 13:46:01 $";
private String MQSSave_Author = "$Author: agibert $";
private Integer Sleep_Time = 0;
@@ -198,7 +207,19 @@ public class MQSSave
{ {
while( argc < args.length) while( argc < args.length)
{ {
if ( args[argc].equals( "-mb")) 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( "-mb"))
{ {
if( argc < ( args.length + 1)) if( argc < ( args.length + 1))
{ {
@@ -214,7 +235,7 @@ public class MQSSave
{ {
if( argc < ( args.length + 1)) if( argc < ( args.length + 1))
{ {
Flush_File_Name = Str_Format( args[++argc]); Flush_File_Name = args[++argc];
} }
else else
{ {
@@ -222,9 +243,49 @@ public class MQSSave
throw new Exception(); throw new Exception();
} }
} }
else if ( args[argc].equals( "-st"))
{
if( argc < ( args.length + 1))
{
Sleep_Time = Integer.parseInt( args[++argc]);
}
else
{
System.out.println( "Invalid number of command line options...");
throw new Exception();
}
}
else if ( args[argc].equals( "-tisbm")) else if ( args[argc].equals( "-tisbm"))
{ {
TI_Swift_Batch_Mode = true; if( Copy_Mode == false)
{
TI_Swift_Batch_Mode = true;
}
else
{
System.out.println( "Invalid command line option combination: -tisbm and -cm...");
throw new Exception();
}
}
else if ( args[argc].equals( "-cm"))
{
if( TI_Swift_Batch_Mode == false)
{
Copy_Mode = true;
}
else
{
System.out.println( "Invalid command line option combination: -tisbm and -cm...");
throw new Exception();
}
}
else if ( args[argc].equals( "-tm"))
{
Trim_Mode = true;
}
else if ( args[argc].equals( "-mbtm"))
{
MBTrailer_Mode = true;
} }
else else
{ {
@@ -258,17 +319,29 @@ public class MQSSave
private void MQSInit() throws Exception private void MQSInit() throws Exception
{ {
try short retry = 0;
{ final short RETRY_MAX = 10;
QMng = new MQQueueManager( QMng_Name);
// System.out.println( "QManager Open: (" + QMng + ") !");
} while( QMng == null)
{
try
{
QMng = new MQQueueManager( QMng_Name);
// System.out.println( "QManager Open: (" + QMng + ") !");
}
catch( Exception Expt) catch( Exception Expt)
{ {
throw Expt; System.out.print("!");
if( retry++ > RETRY_MAX)
{
throw Expt;
}
}
} }
try try
{ {
MsgQ = QMng.accessQueue( MsgQ_Name, MsgQ_Open_Options, null, null, null); MsgQ = QMng.accessQueue( MsgQ_Name, MsgQ_Open_Options, null, null, null);
@@ -440,6 +513,32 @@ public class MQSSave
//-------------------------------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------------------------------
private void Stand_By(int timer)
{
if( timer > 0)
{
try
{
synchronized( this)
{
wait( timer);
}
}
catch(InterruptedException ie)
{
ie.printStackTrace();
}
}
}
//------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------
// //
//------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------
@@ -457,7 +556,7 @@ public class MQSSave
String msg_type; String msg_type;
final String TYPE_SWIFTBEGIN = "SWIFTBEGIN"; final String TYPE_SWIFTBEGIN = "SWIFTBEGIN";
final String TYPE_SWIFTEND = "SWIFTEND "; final String TYPE_SWIFTEND = "SWIFTEND ";
final String TYPE_SWIFTABORT = "SWIFTABORT"; final String TYPE_SWIFTERROR = "SWIFTERROR";
final String TYPE_SWIFTOUT = "SWIFTOUT "; final String TYPE_SWIFTOUT = "SWIFTOUT ";
boolean get_first = false; boolean get_first = false;
boolean first_flush = true; boolean first_flush = true;
@@ -486,6 +585,8 @@ public class MQSSave
if( mode == MODE_FULLMOVE) if( mode == MODE_FULLMOVE)
{ {
Counter_Print( Total_Nb++, '.'); Counter_Print( Total_Nb++, '.');
Stand_By( Sleep_Time);
if( Moved_Nb > 1) if( Moved_Nb > 1)
{ {
@@ -495,9 +596,18 @@ public class MQSSave
buffer_byte = new byte[ input_msg.getMessageLength()]; buffer_byte = new byte[ input_msg.getMessageLength()];
input_msg.readFully( buffer_byte); input_msg.readFully( buffer_byte);
if( Trim_Mode)
{
String buffer_string = new String( buffer_byte).trim();
buffer_byte = buffer_string.getBytes();
}
Output_File.write( buffer_byte, 0, buffer_byte.length); Output_File.write( buffer_byte, 0, buffer_byte.length);
MQSDelete_Msg( input_msg); if( Copy_Mode == false )
{
MQSDelete_Msg( input_msg);
}
} }
else else
{ {
@@ -513,8 +623,11 @@ public class MQSSave
{ {
// System.out.print( "FB1 "); // System.out.print( "FB1 ");
Counter_Print( Total_Nb++, '#'); Counter_Print( Total_Nb++, '#');
Stand_By( Sleep_Time);
MQSDelete_Msg( input_msg); MQSDelete_Msg( input_msg);
first_flush = false; first_flush = false;
} }
else else
@@ -525,11 +638,13 @@ public class MQSSave
first_flush = true; first_flush = true;
} }
} }
else if( msg_type.equals( TYPE_SWIFTEND) || msg_type.equals( TYPE_SWIFTABORT)) else if( msg_type.equals( TYPE_SWIFTEND) || msg_type.equals( TYPE_SWIFTERROR))
{ {
// System.out.print( "FEA "); // System.out.print( "FEA ");
Counter_Print( Total_Nb++, '#'); Counter_Print( Total_Nb++, '#');
Stand_By( Sleep_Time);
MQSDelete_Msg( input_msg); MQSDelete_Msg( input_msg);
} }
else if( msg_type.equals( TYPE_SWIFTOUT)) else if( msg_type.equals( TYPE_SWIFTOUT))
@@ -537,6 +652,8 @@ public class MQSSave
// System.out.print( "FO "); // System.out.print( "FO ");
Counter_Print( Total_Nb++, '*'); Counter_Print( Total_Nb++, '*');
Stand_By( Sleep_Time);
if( Flushed_Nb > 1) if( Flushed_Nb > 1)
{ {
Flush_File.write( Message_Break.getBytes()); Flush_File.write( Message_Break.getBytes());
@@ -545,6 +662,12 @@ public class MQSSave
input_msg.readString( FILLER_LEN); input_msg.readString( FILLER_LEN);
buffer_byte = new byte[ input_msg.getMessageLength() - MSGTYPE_LEN - FILLER_LEN]; buffer_byte = new byte[ input_msg.getMessageLength() - MSGTYPE_LEN - FILLER_LEN];
input_msg.readFully( buffer_byte); input_msg.readFully( buffer_byte);
if( Trim_Mode)
{
String buffer_string = new String( buffer_byte).trim();
buffer_byte = buffer_string.getBytes();
}
Flush_File.write( buffer_byte, 0, buffer_byte.length); Flush_File.write( buffer_byte, 0, buffer_byte.length);
@@ -588,7 +711,7 @@ public class MQSSave
get_first = true; get_first = true;
first_scan = true; first_scan = true;
} }
else if( msg_type.equals( TYPE_SWIFTABORT)) else if( msg_type.equals( TYPE_SWIFTERROR))
{ {
// System.out.print( "SA "); // System.out.print( "SA ");
@@ -615,6 +738,9 @@ public class MQSSave
} }
Counter_Print( Total_Nb++, '~'); Counter_Print( Total_Nb++, '~');
Stand_By( Sleep_Time);
break; break;
} }
@@ -625,6 +751,8 @@ public class MQSSave
// System.out.print( "MB "); // System.out.print( "MB ");
Counter_Print( Total_Nb++, '#'); Counter_Print( Total_Nb++, '#');
Stand_By( Sleep_Time);
MQSDelete_Msg( input_msg); MQSDelete_Msg( input_msg);
} }
else if( msg_type.equals( TYPE_SWIFTEND)) else if( msg_type.equals( TYPE_SWIFTEND))
@@ -632,12 +760,14 @@ public class MQSSave
// System.out.print( "ME "); // System.out.print( "ME ");
Counter_Print( Total_Nb++, '#'); Counter_Print( Total_Nb++, '#');
Stand_By( Sleep_Time);
MQSDelete_Msg( input_msg); MQSDelete_Msg( input_msg);
mode = MODE_SCAN; mode = MODE_SCAN;
get_first = true; get_first = true;
} }
else if( msg_type.equals( TYPE_SWIFTABORT)) else if( msg_type.equals( TYPE_SWIFTERROR))
{ {
System.out.println( "Internal error: (" + msg_type + ") found during Move!"); System.out.println( "Internal error: (" + msg_type + ") found during Move!");
throw new Exception(); throw new Exception();
@@ -647,6 +777,8 @@ public class MQSSave
// System.out.print( "MO "); // System.out.print( "MO ");
Counter_Print( Total_Nb++, '.'); Counter_Print( Total_Nb++, '.');
Stand_By( Sleep_Time);
if( Moved_Nb > 1) if( Moved_Nb > 1)
{ {
Output_File.write( Message_Break.getBytes()); Output_File.write( Message_Break.getBytes());
@@ -656,9 +788,15 @@ public class MQSSave
buffer_byte = new byte[ input_msg.getMessageLength() - MSGTYPE_LEN - FILLER_LEN]; buffer_byte = new byte[ input_msg.getMessageLength() - MSGTYPE_LEN - FILLER_LEN];
input_msg.readFully( buffer_byte); input_msg.readFully( buffer_byte);
if( Trim_Mode)
{
String buffer_string = new String( buffer_byte).trim();
buffer_byte = buffer_string.getBytes();
}
Output_File.write( buffer_byte, 0, buffer_byte.length); Output_File.write( buffer_byte, 0, buffer_byte.length);
MQSDelete_Msg( input_msg); MQSDelete_Msg( input_msg);
} }
else else
{ {
@@ -675,6 +813,11 @@ public class MQSSave
} }
while( input_msg != null); while( input_msg != null);
if( MBTrailer_Mode)
{
Output_File.write( Message_Break.getBytes());
}
System.out.println( "\n"); System.out.println( "\n");
} }
@@ -700,14 +843,17 @@ public class MQSSave
NumberFormat nf = NumberFormat.getInstance(); NumberFormat nf = NumberFormat.getInstance();
BufferedOutputStream Output_File = null, Flush_File = null; BufferedOutputStream Output_File = null, Flush_File = null;
try try
{ {
System.out.println("MQSSave: " + MQSSave_Tag + " / " + MQSSave_Date + " / " + MQSSave_Author);
if( ( args.length < 2) || ( args.length > 7)) if( ( args.length < 2) || ( args.length > 7))
{ {
System.out.println( "Usage: MQSSave [-mb \"message_break\"] [-tisbm [-ffn <Flush_File_Name>]] <Output_File_Name> <Input_MsgQueue_Name>"); System.out.println( "Usage: MQSSave [-qm \"Input_QueueMng_Name\"] [-st \"sleep_time\"] [-mb \"message_break\"] [-tisbm [-ffn <Flush_File_Name>] | -cm ] [-tm] [-mbtm] <Output_File_Name> <Input_MsgQueue_Name>");
System.out.println( " Default: Message Break: (" + Str_UnFormat( Message_Break) + ") TI Swift Batch Mode: (" + TI_Swift_Batch_Mode + ") Flush File Name: (" + Flush_File_Name + ")"); System.out.println( " Default: Input QueueMng Name: (" + QMng_Name + ") Sleep Time: (" + Sleep_Time + ") Message Break: (" + Str_UnFormat( Message_Break) + ") TI Swift Batch Mode: (" + TI_Swift_Batch_Mode + ") Copy Mode: (" + Copy_Mode + ") Flush File Name: (" + Flush_File_Name + ") Trim Mode: (" + Trim_Mode + ") MsgBreak Trailer Mode: (" + MBTrailer_Mode + ")");
System.exit( 1);
} }
else else
{ {
@@ -715,9 +861,9 @@ public class MQSSave
Arg_Parse( args); Arg_Parse( args);
System.out.println( "Output File Name: (" + Output_File_Name + ") Input MsgQue Name: (" + MsgQ_Name + ") Flush File Name: (" + Flush_File_Name + ")"); System.out.println( "Output File Name: (" + Output_File_Name + ") Input QueueMng Name: (" + QMng_Name + ") Input MsgQue Name: (" + MsgQ_Name + ") Flush File Name: (" + Flush_File_Name + ")");
System.out.println( "Message Break: (" + Str_UnFormat( Message_Break) + ") TI Swift Batch Mode: (" + TI_Swift_Batch_Mode + ")"); System.out.println( "Sleep Time: (" + Sleep_Time + ") Message Break: (" + Str_UnFormat( Message_Break) + ") TI Swift Batch Mode: (" + TI_Swift_Batch_Mode + ") Copy Mode: (" + Copy_Mode + ") Trim Mode: (" + Trim_Mode + ") MsgBreak Trailer Mode: (" + MBTrailer_Mode + ")");
MQSInit(); MQSInit();
try try
@@ -726,6 +872,7 @@ public class MQSSave
if( TI_Swift_Batch_Mode) if( TI_Swift_Batch_Mode)
{ {
System.out.println( "Legend: .: Saved *: Flushed #: Skiped ~: Scaned");
Flush_File = new BufferedOutputStream( new FileOutputStream( Flush_File_Name)); Flush_File = new BufferedOutputStream( new FileOutputStream( Flush_File_Name));
} }
@@ -788,6 +935,8 @@ public class MQSSave
MQSDeInit(); MQSDeInit();
System.out.println( "MQS Save Completed !"); System.out.println( "MQS Save Completed !");
System.exit( 0);
} }
} }
@@ -795,6 +944,8 @@ public class MQSSave
{ {
System.out.println("Exception: (" + Expt + ") !"); System.out.println("Exception: (" + Expt + ") !");
Expt.printStackTrace(); Expt.printStackTrace();
System.exit( 1);
} }
} }

View File

@@ -1,8 +1,8 @@
# $RCSfile: ReadMe.txt,v $ # $RCSfile: ReadMe.txt,v $
# $Revision: 1.3 $ # $Revision: 1.5 $
# $Name: $ # $Name: $
# $Date: 2002/05/03 17:23:49 $ # $Date: 2007/12/11 16:50:50 $
# $Author: giberta1 $ # $Author: agibert $
@@ -24,7 +24,7 @@ Installation:
Notes: Notes:
------ ------
- MQSSave has been tested with MQ/Series 5.2, - MQSSave has been tested with MQ/Series 5.2, 5.2, 5.3 and WMQ 6.0.
- "-mb" argument accept a string with formated escape character: - "-mb" argument accept a string with formated escape character:
+ "\n" for newline, + "\n" for newline,
@@ -39,6 +39,8 @@ Notes:
- The Flush File is only used when TI Swift Batch Mode is enabled (by setting "-tisbm" command line switch). - The Flush File is only used when TI Swift Batch Mode is enabled (by setting "-tisbm" command line switch).
- When trim mode is enabled (by setting "-tm" command line switch), all the trailing spaces are removed.
- By default Message break is "\r\n", - By default Message break is "\r\n",
- By default Flush File Name is "flush.txt". - By default Flush File Name is "flush.txt".

View File

@@ -1,15 +1,87 @@
# $RCSfile: ReleaseNotes.txt,v $ # $RCSfile: ReleaseNotes.txt,v $
# $Revision: 1.3 $ # $Revision: 1.11 $
# $Name: $ # $Name: $
# $Date: 2002/05/03 17:15:36 $ # $Date: 2008/01/03 13:46:01 $
# $Author: giberta1 $ # $Author: agibert $
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
MQSSave V 1.1.0 - A. Gibert - 03/05/02 MQSSave V 1.3.1 - A. Gibert - 2008/01/03
--------------------------------------------------------------------------------
Fix usage print out.
--------------------------------------------------------------------------------
MQSSave V 1.3.0 - C. Colin / A. Gibert - 2007/12/10
--------------------------------------------------------------------------------
Add sleep time option "-st".
--------------------------------------------------------------------------------
MQSSave V 1.2.0 - A. Gibert - 2007/06/05
--------------------------------------------------------------------------------
Add queue manager name option "-qm".
--------------------------------------------------------------------------------
MQSSave V 1.1.5 - A. Gibert - 2003/09/04
--------------------------------------------------------------------------------
Add message break trailer mode support,
Add -mbtm option,
Add copy mode support,
Add "-cm" option.
--------------------------------------------------------------------------------
MQSSave V 1.1.4 - A. Gibert - 2002/07/29
--------------------------------------------------------------------------------
Fix trim mode support when tisbm off.
--------------------------------------------------------------------------------
MQSSave V 1.1.3 - A. Gibert - 2002/05/21
--------------------------------------------------------------------------------
Add trim mode support,
Add "-tm" option,
Add MQQueueManager() auto retry,
Fix flush file name bad parsing bug,
Add version, date and author print out.
--------------------------------------------------------------------------------
MQSSave V 1.1.2 - A. Gibert - 2002/05/13
--------------------------------------------------------------------------------
Rename SWIFTABORT into SWIFTERROR,
Add Legend printout line.
--------------------------------------------------------------------------------
MQSSave V 1.1.1 - A. Gibert - 2002/05/06
--------------------------------------------------------------------------------
Add return code handling.
--------------------------------------------------------------------------------
MQSSave V 1.1.0 - A. Gibert - 2002/05/03
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Add TI Swift batch mode support, Add TI Swift batch mode support,
@@ -21,7 +93,7 @@ Fix MQSSave usage print: replace MQSLoad by MSSave !
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
MQSSave V 1.0.0 - A. Gibert - 23/04/02 MQSSave V 1.0.0 - A. Gibert - 2002/04/23
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
First release. First release.