Compare commits
11 Commits
mqssave-1_
...
mqssave-1_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81f82b947f | ||
|
|
51a031b7ae | ||
|
|
67d8b5f6c4 | ||
|
|
4bdbc1e2e1 | ||
|
|
bf636a2cea | ||
|
|
00a78ea920 | ||
|
|
675a925c00 | ||
|
|
33b67fe311 | ||
|
|
9174e00abe | ||
|
|
f390c41e76 | ||
|
|
e807001586 |
144
MQSSave.java
144
MQSSave.java
@@ -1,14 +1,14 @@
|
||||
// $RCSfile: MQSSave.java,v $
|
||||
// $Revision: 1.6 $
|
||||
// $Revision: 1.12 $
|
||||
// $Name: $
|
||||
// $Date: 2002/05/13 16:28:02 $
|
||||
// $Author: giberta1 $
|
||||
// $Date: 2007/06/05 09:27:44 $
|
||||
// $Author: agibert $
|
||||
|
||||
/*
|
||||
* MQSSave.java - MQ/Seires queue to data file saver
|
||||
* Copyright (C) 2002 Arnaud G. Gibert
|
||||
* arnaud.gibert@misys.com
|
||||
* www.misys.com
|
||||
* MQSSave.java - MQ/Series queue to data file saver
|
||||
* 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
|
||||
@@ -35,7 +35,7 @@ import java.text.*;
|
||||
|
||||
public class MQSSave
|
||||
{
|
||||
private MQQueueManager QMng;
|
||||
private MQQueueManager QMng = null;
|
||||
private String QMng_Name = "";
|
||||
private MQQueue MsgQ;
|
||||
private String MsgQ_Name;
|
||||
@@ -43,7 +43,15 @@ public class MQSSave
|
||||
private String Output_File_Name, Flush_File_Name = "flush.txt";
|
||||
private String Message_Break = "\r\n";
|
||||
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 String MQSSave_Revision = "$Revision: 1.12 $";
|
||||
private String MQSSave_Tag = "$Name: $";
|
||||
private String MQSSave_Date = "$Date: 2007/06/05 09:27:44 $";
|
||||
private String MQSSave_Author = "$Author: agibert $";
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -198,7 +206,19 @@ public class MQSSave
|
||||
{
|
||||
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))
|
||||
{
|
||||
@@ -214,7 +234,7 @@ public class MQSSave
|
||||
{
|
||||
if( argc < ( args.length + 1))
|
||||
{
|
||||
Flush_File_Name = Str_Format( args[++argc]);
|
||||
Flush_File_Name = args[++argc];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -224,7 +244,35 @@ public class MQSSave
|
||||
}
|
||||
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
|
||||
{
|
||||
@@ -258,17 +306,29 @@ public class MQSSave
|
||||
|
||||
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);
|
||||
@@ -495,9 +555,18 @@ public class MQSSave
|
||||
buffer_byte = new byte[ input_msg.getMessageLength()];
|
||||
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);
|
||||
|
||||
MQSDelete_Msg( input_msg);
|
||||
if( Copy_Mode == false )
|
||||
{
|
||||
MQSDelete_Msg( input_msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -515,6 +584,7 @@ public class MQSSave
|
||||
Counter_Print( Total_Nb++, '#');
|
||||
|
||||
MQSDelete_Msg( input_msg);
|
||||
|
||||
first_flush = false;
|
||||
}
|
||||
else
|
||||
@@ -545,6 +615,12 @@ public class MQSSave
|
||||
input_msg.readString( FILLER_LEN);
|
||||
buffer_byte = new byte[ input_msg.getMessageLength() - MSGTYPE_LEN - FILLER_LEN];
|
||||
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);
|
||||
|
||||
@@ -656,9 +732,15 @@ public class MQSSave
|
||||
buffer_byte = new byte[ input_msg.getMessageLength() - MSGTYPE_LEN - FILLER_LEN];
|
||||
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);
|
||||
|
||||
MQSDelete_Msg( input_msg);
|
||||
MQSDelete_Msg( input_msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -675,6 +757,11 @@ public class MQSSave
|
||||
}
|
||||
while( input_msg != null);
|
||||
|
||||
if( MBTrailer_Mode)
|
||||
{
|
||||
Output_File.write( Message_Break.getBytes());
|
||||
}
|
||||
|
||||
System.out.println( "\n");
|
||||
}
|
||||
|
||||
@@ -700,14 +787,15 @@ public class MQSSave
|
||||
NumberFormat nf = NumberFormat.getInstance();
|
||||
BufferedOutputStream Output_File = null, Flush_File = null;
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
System.out.println("MQSSave: " + MQSSave_Tag + " / " + MQSSave_Date + " / " + MQSSave_Author);
|
||||
|
||||
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( " Default: Message Break: (" + Str_UnFormat( Message_Break) + ") TI Swift Batch Mode: (" + TI_Swift_Batch_Mode + ") Flush File Name: (" + Flush_File_Name + ")");
|
||||
System.out.println( "Usage: MQSSave [-qm \"Input_QueueMng_Name\"] [-mb \"message_break\"] [-tisbm [-ffn <Flush_File_Name>] | -cm ] [-tm] [-mbtm] <Output_File_Name> <Input_MsgQueue_Name>");
|
||||
System.out.println( " Default: Input QueueMng Name: (" + QMng_Name + ") 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);
|
||||
}
|
||||
@@ -717,9 +805,9 @@ public class MQSSave
|
||||
|
||||
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( "Message Break: (" + Str_UnFormat( Message_Break) + ") TI Swift Batch Mode: (" + TI_Swift_Batch_Mode + ")");
|
||||
|
||||
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 + ") Copy Mode: (" + Copy_Mode + ") Trim Mode: (" + Trim_Mode + ") MsgBreak Trailer Mode: (" + MBTrailer_Mode + ")");
|
||||
|
||||
MQSInit();
|
||||
|
||||
try
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# $RCSfile: ReadMe.txt,v $
|
||||
# $Revision: 1.3 $
|
||||
# $Revision: 1.4 $
|
||||
# $Name: $
|
||||
# $Date: 2002/05/03 17:23:49 $
|
||||
# $Date: 2002/05/21 16:07:17 $
|
||||
# $Author: giberta1 $
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ Notes:
|
||||
|
||||
- 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 Flush File Name is "flush.txt".
|
||||
|
||||
|
||||
@@ -1,13 +1,52 @@
|
||||
# $RCSfile: ReleaseNotes.txt,v $
|
||||
# $Revision: 1.5 $
|
||||
# $Revision: 1.9 $
|
||||
# $Name: $
|
||||
# $Date: 2002/05/13 16:38:12 $
|
||||
# $Author: giberta1 $
|
||||
# $Date: 2007/06/05 09:29:21 $
|
||||
# $Author: agibert $
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
MQSSave V 1.2.0 - A. Gibert - 05/06/07
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Add queue manager name option "-qm".
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
MQSSave V 1.1.5 - A. Gibert - 04/09/03
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Add message break trailer mode support,
|
||||
Add -mbtm option,
|
||||
Add copy mode support,
|
||||
Add "-cm" option.
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
MQSSave V 1.1.4 - A. Gibert - 29/07/02
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Fix trim mode support when tisbm off.
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
MQSSave V 1.1.3 - A. Gibert - 21/05/02
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
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 - 13/05/02
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user