Compare commits

..

No commits in common. "e46167036793b1ac6c064427fb4341ab5937239f" and "7bc0510954789ec3b142eab177df2382070fd242" have entirely different histories.

6 changed files with 804 additions and 788 deletions

View File

@ -1,12 +1,12 @@
// $RCSfile: MQSSave.java,v $
// $Revision: 1.21 $
// $Revision: 1.14 $
// $Name: $
// $Date: 2013/11/08 17:17:12 $
// $Date: 2008/01/03 13:46:01 $
// $Author: agibert $
/*
* MQSSave.java - MQ/Series queue to data file saver
* Copyright (C) 2001-2008 Arnaud G. Gibert
* Copyright (C) 2001-2006 Arnaud G. Gibert
* mailto:arnaud@rx3.net
* http://www.rx3.org/dvp/MQSLoad
*
@ -26,41 +26,33 @@
*/
import com.ibm.mq.*;
import com.ibm.mq.constants.*;
import java.io.*;
import java.text.*;
public class MQSSave
{
private String MQSSave_Revision = "$Revision: 1.21 $";
private String MQSSave_Tag = "$Name: $";
private String MQSSave_Date = "$Date: 2013/11/08 17:17:12 $";
private String MQSSave_Author = "$Author: agibert $";
private MQQueueManager QMng = null;
private String QMng_Name = "";
private MQQueue MsgQ;
private String MsgQ_Name;
private int MsgQ_Open_Options = CMQC.MQOO_INPUT_AS_Q_DEF | CMQC.MQOO_FAIL_IF_QUIESCING | CMQC.MQOO_BROWSE | CMQC.MQOO_INQUIRE;
private boolean Character_Convert = false;
private int Character_Set = 1208;
private int Sleep_Time = 0;
private int MsgQ_Open_Options = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_FAIL_IF_QUIESCING | MQC.MQOO_BROWSE | MQC.MQOO_INQUIRE;
private String Output_File_Name, Flush_File_Name = "flush.txt";
private String Message_Break = "\r\n";
private int Message_Skip = 0;
private int Message_Count = 0;
private int Repeat_Count = 1;
private boolean TI_Swift_Batch_Mode = false;
private boolean Copy_Mode = false;
private boolean Trim_Mode = false;
private boolean MBTrailer_Mode = false;
private boolean Best_Effort_Mode = false;
private String Output_File_Name;
private int Msg_Counter = 0;
private int Msg_Saved_Nb = 0;
private int Msg_Skiped_Nb = 0;
private int Msg_Error_Nb = 0;
private boolean CC_Error = false;
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;
@ -206,7 +198,7 @@ public class MQSSave
//
//-------------------------------------------------------------------------------------------------------------------------
private void Args_Parse( String args[]) throws Exception
private void Arg_Parse( String args[]) throws Exception
{
int argc = 0;
@ -227,15 +219,23 @@ public class MQSSave
throw new Exception();
}
}
else if ( args[argc].equals( "-cc"))
{
Character_Convert = true;
}
else if ( args[argc].equals( "-cs"))
else if ( args[argc].equals( "-mb"))
{
if( argc < ( args.length + 1))
{
Character_Set = Integer.parseInt( args[++argc]);
Message_Break = Str_Format( args[++argc]);
}
else
{
System.out.println( "Invalid number of command line options...");
throw new Exception();
}
}
else if ( args[argc].equals( "-ffn"))
{
if( argc < ( args.length + 1))
{
Flush_File_Name = args[++argc];
}
else
{
@ -255,22 +255,30 @@ public class MQSSave
throw new Exception();
}
}
else if ( args[argc].equals( "-mb"))
else if ( args[argc].equals( "-tisbm"))
{
if( argc < ( args.length + 1))
if( Copy_Mode == false)
{
Message_Break = Str_Format( args[++argc]);
TI_Swift_Batch_Mode = true;
}
else
{
System.out.println( "Invalid number of command line options...");
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;
@ -279,46 +287,6 @@ public class MQSSave
{
MBTrailer_Mode = true;
}
else if ( args[argc].equals( "-bem"))
{
Best_Effort_Mode = true;
}
else if ( args[argc].equals( "-ms"))
{
if( argc < ( args.length + 1))
{
Message_Skip = Integer.parseInt( args[++argc]);
}
else
{
System.out.println( "Invalid number of command line options...");
throw new Exception();
}
}
else if ( args[argc].equals( "-mc"))
{
if( argc < ( args.length + 1))
{
Message_Count = Integer.parseInt( args[++argc]);
}
else
{
System.out.println( "Invalid number of command line options...");
throw new Exception();
}
}
else if ( args[argc].equals( "-rc"))
{
if( argc < ( args.length + 1))
{
Repeat_Count = Integer.parseInt( args[++argc]);
}
else
{
System.out.println( "Invalid number of command line options...");
throw new Exception();
}
}
else
{
Output_File_Name = args[argc++];
@ -360,7 +328,7 @@ public class MQSSave
try
{
QMng = new MQQueueManager( QMng_Name);
// System.out.println( "QManager Open: (" + QMng + ") !");
// System.out.println( "QManager Open: (" + QMng + ") !");
}
catch( Exception Expt)
@ -377,7 +345,7 @@ public class MQSSave
try
{
MsgQ = QMng.accessQueue( MsgQ_Name, MsgQ_Open_Options, null, null, null);
// System.out.println( "MsgQ Open: (" + MsgQ + ") !");
// System.out.println( "MsgQ Open: (" + MsgQ + ") !");
MQException.log = null;
}
@ -385,7 +353,7 @@ public class MQSSave
catch( Exception Expt)
{
QMng.disconnect();
// System.out.println( "QManager Close: (" + QMng + ") !");
// System.out.println( "QManager Close: (" + QMng + ") !");
throw Expt;
}
@ -404,9 +372,9 @@ public class MQSSave
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)
@ -432,19 +400,14 @@ public class MQSSave
{
if( First)
{
gmo.options = CMQC.MQGMO_NO_WAIT | CMQC.MQGMO_BROWSE_FIRST;
gmo.options = MQC.MQGMO_NO_WAIT | MQC.MQGMO_BROWSE_FIRST | MQC.MQGMO_CONVERT;
}
else
{
gmo.options = CMQC.MQGMO_NO_WAIT | CMQC.MQGMO_BROWSE_NEXT;
gmo.options = MQC.MQGMO_NO_WAIT | MQC.MQGMO_BROWSE_NEXT | MQC.MQGMO_CONVERT;
}
if( Character_Convert)
{
gmo.options = gmo.options | CMQC.MQGMO_CONVERT;
}
gmo.matchOptions = CMQC.MQMO_NONE;
gmo.matchOptions = MQC.MQMO_NONE;
MsgQ.get( Msg, gmo);
@ -453,23 +416,15 @@ public class MQSSave
catch( MQException Expt)
{
if( ( Expt.completionCode == 2) && ( Expt.reasonCode == 2033))
if( ( Expt.completionCode != 2) || (Expt.reasonCode != 2033))
{
/* no more messages */
return( null);
}
if( Best_Effort_Mode && ( Expt.completionCode == 1) && ( ( Expt.reasonCode == 2110) || ( Expt.reasonCode == 2150)))
{
/* caracter convertion error */
CC_Error = true;
return( null);
}
//System.out.println("Exception: (" + Expt + ") !!!");
throw Expt;
}
return( null);
}
catch( Exception Expt)
{
//System.out.println("Exception: (" + Expt + ") !!!");
@ -492,8 +447,8 @@ public class MQSSave
try
{
gmo.options = CMQC.MQGMO_NO_WAIT | CMQC.MQGMO_CONVERT;
gmo.matchOptions = CMQC.MQMO_MATCH_MSG_ID;
gmo.options = MQC.MQGMO_NO_WAIT | MQC.MQGMO_CONVERT;
gmo.matchOptions = MQC.MQMO_MATCH_MSG_ID;
MsgQ.get( Msg, gmo);
}
@ -512,21 +467,46 @@ public class MQSSave
//
//-------------------------------------------------------------------------------------------------------------------------
private void Counter_Print( String Mark)
private void Counter_Print( int Msg_Nb, char Mark)
{
if( ( Msg_Counter % 50) == 0)
if( ( Msg_Nb % 50) == 0)
{
System.out.print( "\n(" + Msg_Counter + ")\t");
System.out.print( "\n(" + Msg_Nb + ")\t");
}
if( ( Msg_Counter % 10) == 0)
if( ( Msg_Nb % 10) == 0)
{
System.out.print( " ");
}
System.out.print( Mark);
Msg_Counter++;
switch( Mark)
{
case '.':
{
Moved_Nb++;
break;
}
case '*':
{
Flushed_Nb++;
break;
}
case '#':
{
Skiped_Nb++;
break;
}
case '~':
{
Scaned_Nb++;
break;
}
}
}
@ -537,7 +517,7 @@ public class MQSSave
//
//-------------------------------------------------------------------------------------------------------------------------
private void Stand_By(int timer) throws Exception
private void Stand_By(int timer)
{
if( timer > 0)
{
@ -548,9 +528,9 @@ public class MQSSave
wait( timer);
}
}
catch(InterruptedException Expt)
catch(InterruptedException ie)
{
throw Expt;
ie.printStackTrace();
}
}
}
@ -563,125 +543,287 @@ public class MQSSave
//
//-------------------------------------------------------------------------------------------------------------------------
private boolean Msg_Get( MQMessage Input_Msg, int Msg_Id, int Msg_Skip, int Msg_Count, boolean Get_First) throws Exception
{
if( ( Msg_Count != 0) && ( Msg_Id >= ( Msg_Skip + Msg_Count)))
{
return(false);
}
else
{
Input_Msg = MQSGet_Msg( Input_Msg, Get_First);
if( Input_Msg != null)
{
if( Msg_Id < Msg_Skip)
{
Counter_Print( "#");
Msg_Skiped_Nb++;
}
else
{
Counter_Print( ".");
Msg_Saved_Nb++;
Stand_By( Sleep_Time);
}
return(true);
}
else
{
if( CC_Error)
{
Counter_Print( "*");
Msg_Error_Nb++;
return(true);
}
else
{
return(false);
}
}
}
}
//-------------------------------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------------------------------
private void File_Save( BufferedOutputStream Output_File, int Msg_Skip, int Msg_Count, boolean Copy_Mode) throws Exception
private void Save_File( BufferedOutputStream Output_File, BufferedOutputStream Flush_File) throws Exception
{
MQMessage input_msg = new MQMessage();
byte[] buffer;
int msg_id = 0;
boolean get_first = true;
byte[] buffer_byte;
short mode;
final short MODE_FLUSH = 0;
final short MODE_SCAN = 1;
final short MODE_MOVE = 2;
final short MODE_FULLMOVE = 3;
final short MSGTYPE_LEN = 10, FILLER_LEN = 128;
String msg_type;
final String TYPE_SWIFTBEGIN = "SWIFTBEGIN";
final String TYPE_SWIFTEND = "SWIFTEND ";
final String TYPE_SWIFTERROR = "SWIFTERROR";
final String TYPE_SWIFTOUT = "SWIFTOUT ";
boolean get_first = false;
boolean first_flush = true;
boolean first_scan = true;
try
{
// input_msg.format = CMQC.MQFMT_STRING;
input_msg.characterSet = Character_Set;
input_msg.format = MQC.MQFMT_STRING;
/* Loop while Msg_Count not reatch */
while( Msg_Get( input_msg, msg_id, Msg_Skip, Msg_Count, get_first))
if( TI_Swift_Batch_Mode)
{
get_first = false;
if( CC_Error == false)
mode = MODE_SCAN;
}
else
{
/* This message is not in error */
mode = MODE_FULLMOVE;
}
if( msg_id >= Msg_Skip)
do
{
/* This message is not skiped */
input_msg = MQSGet_Msg( input_msg, get_first);
if( Msg_Saved_Nb > 1)
if( input_msg != null)
{
if( mode == MODE_FULLMOVE)
{
Counter_Print( Total_Nb++, '.');
Stand_By( Sleep_Time);
if( Moved_Nb > 1)
{
Output_File.write( Message_Break.getBytes());
}
buffer = new byte[ input_msg.getMessageLength()];
input_msg.readFully( buffer);
buffer_byte = new byte[ input_msg.getMessageLength()];
input_msg.readFully( buffer_byte);
if( Trim_Mode)
{
String buffer_string = new String( buffer).trim();
buffer = buffer_string.getBytes();
String buffer_string = new String( buffer_byte).trim();
buffer_byte = buffer_string.getBytes();
}
Output_File.write( buffer, 0, buffer.length);
Output_File.write( buffer_byte, 0, buffer_byte.length);
if( Copy_Mode == false )
{
MQSDelete_Msg( input_msg);
}
}
else
{
msg_type = input_msg.readString( MSGTYPE_LEN);
switch( mode)
{
case MODE_FLUSH:
{
if( msg_type.equals( TYPE_SWIFTBEGIN))
{
if( first_flush)
{
// System.out.print( "FB1 ");
Counter_Print( Total_Nb++, '#');
Stand_By( Sleep_Time);
MQSDelete_Msg( input_msg);
first_flush = false;
}
else
{
/* This message is in error */
// System.out.print( "FB2 ");
mode = MODE_SCAN;
CC_Error = false;
first_flush = true;
}
}
else if( msg_type.equals( TYPE_SWIFTEND) || msg_type.equals( TYPE_SWIFTERROR))
{
// System.out.print( "FEA ");
Counter_Print( Total_Nb++, '#');
Stand_By( Sleep_Time);
MQSDelete_Msg( input_msg);
}
else if( msg_type.equals( TYPE_SWIFTOUT))
{
// System.out.print( "FO ");
Counter_Print( Total_Nb++, '*');
Stand_By( Sleep_Time);
if( Flushed_Nb > 1)
{
Flush_File.write( Message_Break.getBytes());
}
input_msg.readString( FILLER_LEN);
buffer_byte = new byte[ input_msg.getMessageLength() - MSGTYPE_LEN - FILLER_LEN];
input_msg.readFully( buffer_byte);
msg_id++;
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);
MQSDelete_Msg( input_msg);
}
else
{
System.out.println( "Invalid msg_type: (" + msg_type + ") !");
throw new Exception();
}
break;
}
case MODE_SCAN:
{
get_first = false;
if( first_scan)
{
if( msg_type.equals( TYPE_SWIFTBEGIN))
{
// System.out.print( "SB1 ");
first_scan = false;
}
else
{
// System.out.print( "SAEO ");
mode = MODE_FLUSH;
get_first = true;
first_scan = true;
}
}
else if( msg_type.equals( TYPE_SWIFTBEGIN))
{
// System.out.print( "SB2 ");
mode = MODE_FLUSH;
get_first = true;
first_scan = true;
}
else if( msg_type.equals( TYPE_SWIFTERROR))
{
// System.out.print( "SA ");
mode = MODE_FLUSH;
get_first = true;
first_scan = true;
}
else if( msg_type.equals( TYPE_SWIFTEND))
{
// System.out.print( "SE ");
mode = MODE_MOVE;
get_first = true;
first_scan = true;
}
else if( msg_type.equals( TYPE_SWIFTOUT))
{
// System.out.print( "SO ");
}
else
{
System.out.println( "Invalid msg_type: (" + msg_type + ") !");
throw new Exception();
}
Counter_Print( Total_Nb++, '~');
Stand_By( Sleep_Time);
break;
}
case MODE_MOVE:
{
if( msg_type.equals( TYPE_SWIFTBEGIN))
{
// System.out.print( "MB ");
Counter_Print( Total_Nb++, '#');
Stand_By( Sleep_Time);
MQSDelete_Msg( input_msg);
}
else if( msg_type.equals( TYPE_SWIFTEND))
{
// System.out.print( "ME ");
Counter_Print( Total_Nb++, '#');
Stand_By( Sleep_Time);
MQSDelete_Msg( input_msg);
mode = MODE_SCAN;
get_first = true;
}
else if( msg_type.equals( TYPE_SWIFTERROR))
{
System.out.println( "Internal error: (" + msg_type + ") found during Move!");
throw new Exception();
}
else if( msg_type.equals( TYPE_SWIFTOUT))
{
// System.out.print( "MO ");
Counter_Print( Total_Nb++, '.');
Stand_By( Sleep_Time);
if( Moved_Nb > 1)
{
Output_File.write( Message_Break.getBytes());
}
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();
}
Output_File.write( buffer_byte, 0, buffer_byte.length);
MQSDelete_Msg( input_msg);
}
else
{
System.out.println( "Invalid msg_type: (" + msg_type + ") !");
throw new Exception();
}
break;
}
}
}
}
}
while( input_msg != null);
if( MBTrailer_Mode)
{
Output_File.write( Message_Break.getBytes());
}
System.out.println( "\n");
}
catch( Exception Expt)
{
// System.out.println("Exception: (" + Expt + ") !!!");
throw Expt;
}
}
@ -690,116 +832,99 @@ public class MQSSave
//-------------------------------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------------------------------
private void Usage_Print( ) throws Exception
{
System.out.println( "Usage: MQSSave [-qm \"Input_QueueMng_Name\"] [-cc] [-cs \"character_set\"] [-st \"sleep_time\"] [-mb \"message_break\"] [-cm] [-tm] [-mbtm] [-bem] [-ms \"message_skip\"] [-mc \"message_count\"] [-rc \"repeat_count\"] <Output_File_Name> <Input_MsgQueue_Name>");
System.out.println( "");
System.out.println( " Default: Input QueueMng Name: (" + QMng_Name + ") Character Convert: (" + Character_Convert + ") Character Set: (" + Character_Set + ") Sleep Time: (" + Sleep_Time + ") Message Break: (" + Str_UnFormat( Message_Break) + ") Copy Mode: (" + Copy_Mode + ") Trim Mode: (" + Trim_Mode + ") MsgBreak Trailer Mode: (" + MBTrailer_Mode + ") Best Effort Mode: (" + Best_Effort_Mode + ") Message Skip: (" + Message_Skip + ") Message Count: (" + Message_Count + ") Repeat Count: (" + Repeat_Count + ")");
}
//-------------------------------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------------------------------
private void Args_Print( ) throws Exception
{
System.out.println( "Output File Name: (" + Output_File_Name + ") Input QueueMng Name: (" + QMng_Name + ") Input MsgQue Name: (" + MsgQ_Name + ")");
System.out.println( "Character Convert: (" + Character_Convert + ") Character Set: (" + Character_Set + ") Sleep Time: (" + Sleep_Time + ") Message Break: (" + Str_UnFormat( Message_Break) + ") Copy Mode: (" + Copy_Mode + ") Trim Mode: (" + Trim_Mode + ") MsgBreak Trailer Mode: (" + MBTrailer_Mode + ") Best Effort Mode: (" + Best_Effort_Mode + ") Message Skip: (" + Message_Skip + ") Message Count: (" + Message_Count + ") Repeat Count: (" + Repeat_Count + ")");
}
//-------------------------------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------------------------------
public MQSSave( String args[])
{
int loop;
long time_begin, time_end;
double time_elapsed, speed;
NumberFormat nf = NumberFormat.getInstance();
BufferedOutputStream output_file = null;
BufferedOutputStream Output_File = null, Flush_File = null;
try
{
System.out.println("MQSSave: " + MQSSave_Tag + " / " + MQSSave_Date + " / " + MQSSave_Author);
if( ( args.length < 2) || ( args.length > 19))
if( ( args.length < 2) || ( args.length > 7))
{
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: 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 + ")");
Usage_Print();
System.exit( 1);
}
else
{
System.out.println( "MQS Save Starting...");
Args_Parse( args);
Args_Print();
Arg_Parse( args);
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( "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();
try
{
output_file = new BufferedOutputStream( new FileOutputStream( Output_File_Name));
Output_File = new BufferedOutputStream( new FileOutputStream( Output_File_Name));
System.out.println( "Legend: .: Saved #: Skiped *: Error");
if( TI_Swift_Batch_Mode)
{
System.out.println( "Legend: .: Saved *: Flushed #: Skiped ~: Scaned");
Flush_File = new BufferedOutputStream( new FileOutputStream( Flush_File_Name));
}
try
{
// System.out.println( "Output File Open: (" + output_file + ") !");
// System.out.println("Output File Open: (" + Output_file + ") !");
time_begin = System.currentTimeMillis();
for( loop = 0; loop < Repeat_Count; loop++ )
{
if( loop < ( Repeat_Count - 1))
{
File_Save( output_file, Message_Skip, Message_Count, true);
}
else
{
File_Save( output_file, Message_Skip, Message_Count, Copy_Mode);
}
}
Save_File( Output_File, Flush_File);
time_end = System.currentTimeMillis();
time_elapsed = ( time_end - time_begin) / 1000.0;
speed = Msg_Saved_Nb / time_elapsed;
time_elapsed = ( time_end - time_begin) / 100.0;
speed = Total_Nb / time_elapsed;
nf.setMinimumFractionDigits(2);
nf.setMaximumFractionDigits(2);
System.out.println( "");
System.out.println( "");
System.out.println( "Saved Message Nb: (" + Msg_Saved_Nb
+ ") Skiped Messages Nb: (" + Msg_Skiped_Nb
+ ") Error Messages Nb: (" + Msg_Error_Nb
if( TI_Swift_Batch_Mode)
{
System.out.println( "Saved Message Nb: (" + Moved_Nb + ") Skiped Message Nb: (" + Skiped_Nb + ") Flushed Message Nb: (" + Flushed_Nb + ") Scaned Message Nb: (" + Scaned_Nb + ")");
System.out.println( "Total Message Nb: (" + Total_Nb
+ ") Elapsed Time: (" + nf.format(time_elapsed)
+ ") s Speed: (" + nf.format(speed)
+ ") msg/s");
}
else
{
System.out.println( "Saved Message Nb: (" + Total_Nb
+ ") Elapsed Time: (" + nf.format(time_elapsed)
+ ") s Speed: (" + nf.format(speed)
+ ") msg/s");
}
}
catch( Exception Expt)
{
output_file.close();
Output_File.close();
if( TI_Swift_Batch_Mode)
{
Flush_File.close();
}
throw Expt;
}
output_file.close();
Output_File.close();
if( TI_Swift_Batch_Mode)
{
Flush_File.close();
}
}
catch( Exception Expt)
@ -824,6 +949,4 @@ public class MQSSave
}
}
//-------------------------------------------------------------------------------------------------------------------------
}

View File

@ -1,7 +1,7 @@
# $RCSfile: ReadMe.txt,v $
# $Revision: 1.6 $
# $Revision: 1.5 $
# $Name: $
# $Date: 2009/01/05 17:40:17 $
# $Date: 2007/12/11 16:50:50 $
# $Author: agibert $
@ -10,7 +10,6 @@
Compilation:
------------
- Just type: "javac MQSSave.java" !
@ -22,42 +21,10 @@ Installation:
Usage:
------
MQSSave [-qm "Input_QueueMng_Name"] [-cc] [-cs "character_set"] [-st "sleep_time"] [-mb "message_break"] [-cm] [-tm] [-mbtm] [-bem] [-ms "message_skip"] [-mc "message_count"] [-rc "repeat_count"] <Output_File_Name> <Input_MsgQueue_Name>
Default: Input QueueMng Name: () Character Convert: (false) Character Set: (1208) Sleep Time: (0) Message Break: (\r\n) Copy Mode: (false) Trim Mode: (false) MsgBreak Trailer Mode: (false) Best Effort Mode: (false) Message Skip: (0) Message Count: (0) Repeat Count: (1)
Arguments:
----------
- Optional arguments:
-qm "Input_QueueMng_Name": Name of the queue manager to use,
-cc "character_convert": Switch on the caracter conversion (Set the MQGetMessageOptions to MQC.MQGMO_CONVERT),
-cs "character_set": MQMessage character set,
-st "sleep_time": Delay between message sending,
-mb "message_break": String used as message separator,
-cm "copy_mode": Don't remove messages from queue,
-tm "trim_mode": Remove trailing spaces at the message end,
-mbtm "msg_break_trailer_mode": Add a message break at the end of the last message,
-bem "best effort mode": Skip errors and continue to save the next message,
-ms "message_skip": Number of message to skip before to start the saving,
-mc "message_count": Number of message to save,
-rc "repeat_count": Number of time the whole process (start of file + skip + save) should be repeated.
- Mandatory arguments:
<Output_File_Name>: Name of the output file to save to,
<Input_MsgQueue_Name>: Name of the input message queue to save from.
Notes:
------
- MQSSave has been tested with WMQ 6.0.
- 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:
+ "\n" for newline,
@ -70,9 +37,12 @@ Notes:
- Windows text files: newline is specified as "\r\n",
- Unix text files: newline is specified as "\n".
- 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".
- This software is under the GNU General Public License. See GNU-GPL.txt.
@ -84,5 +54,5 @@ Usage Example:
- To save the messages of the MQ/Series "SWIFT-QUEUE" queue into a swift batch file "swift-batch.txt" with "---MESSAGE-BREAK---" message separator use:
java MQSSave -mb "---MESSAGE-BREAK---\r\n" swift-batch.txt SWIFT-QUEUE
- To save 10 times the third message of the MQ/Series "SWIFT-QUEUE" queue into a swift batch file "swift-batch.txt" with "---MESSAGE-BREAK---" message separator without removing it from the queue use:
java MQSSave -mb "---MESSAGE-BREAK---\r\n" -cm -ms 2 -mc 1 -rc 10 swift-batch.txt SWIFT-QUEUE
- To save the messages of the MQ/Series "SWIFT-QUEUE" queue into a swift batch file "swift-batch.txt" with no message break message and by using the TI Swift Batch Mode, use:
java MQSSave -mb "" -tisbm swift-batch.txt SWIFT-QUEUE

View File

@ -1,39 +1,13 @@
# $RCSfile: ReleaseNotes.txt,v $
# $Revision: 1.16 $
# $Revision: 1.11 $
# $Name: $
# $Date: 2009/01/05 17:41:42 $
# $Date: 2008/01/03 13:46:01 $
# $Author: agibert $
--------------------------------------------------------------------------------
MQSSave V 2.0.0 - A. Gibert - 2009/01/05
--------------------------------------------------------------------------------
- Major code rewrite and cleanup,
- Add binary data support,
- Drop obsolete TI swift batch mode support,
- Add message skip option "-ms",
- Add message count option "-mc",
- Add repeat count option "-rc",
- Add character convert option "-cc",
- Add character set option "-cs",
- Add best effort mode "-bem",
- Add error message count,
- Fix Java 1.4 compatibility.
--------------------------------------------------------------------------------
MQSSave V 1.3.2 - A. Gibert - 2008/11/10
--------------------------------------------------------------------------------
Fix elapsed time computation !
--------------------------------------------------------------------------------
MQSSave V 1.3.1 - A. Gibert - 2008/01/03
--------------------------------------------------------------------------------

View File

@ -1 +0,0 @@
ISO [И]

View File

@ -1 +0,0 @@
UTF8 [é]

View File

@ -1,49 +0,0 @@
#!/bin/bash
function file_load
{
out="$1"
in="$2"
cc="$3"
cs="$4"
echo -n "CC: [$cc] CS: [$cs] $(cat $in)" >$$.tmp
mqsload -mb '\n---\n' $cc -cs $cs $out $$.tmp
\rm $$.tmp
}
function file_save
{
out="$1"
in="$2"
cc="$3"
cs="$4"
cm="$5"
mqssave -mb '\n---\n' $cc -cs $cs $cm -bem $out $in
}
file_load DLQ test-charset-in-utf "-cc" 1208
file_load DLQ test-charset-in-utf "-cc" 819
file_load DLQ test-charset-in-iso "-cc" 1208
file_load DLQ test-charset-in-iso "-cc" 819
file_load DLQ test-charset-in-utf " " 1208
file_load DLQ test-charset-in-utf " " 819
file_load DLQ test-charset-in-iso " " 1208
file_load DLQ test-charset-in-iso " " 819
\rm test-charset-out-cc-utf test-charset-out-cc-iso test-charset-out-__-utf test-charset-out-__-iso
file_save test-charset-out-cc-utf DLQ "-cc" 1208 "-cm"
file_save test-charset-out-cc-iso DLQ "-cc" 819 "-cm"
file_save test-charset-out-__-utf DLQ " " 1208 "-cm"
file_save test-charset-out-__-iso DLQ " " 819 " "