Add trim mode support,
Add "-tm" option, Add MQQueueManager() auto retry, Fix flush file name bad parsing bug.
This commit is contained in:
parent
b3f10a6962
commit
e807001586
59
MQSSave.java
59
MQSSave.java
@ -1,7 +1,7 @@
|
|||||||
// $RCSfile: MQSSave.java,v $
|
// $RCSfile: MQSSave.java,v $
|
||||||
// $Revision: 1.6 $
|
// $Revision: 1.7 $
|
||||||
// $Name: $
|
// $Name: $
|
||||||
// $Date: 2002/05/13 16:28:02 $
|
// $Date: 2002/05/21 15:36:28 $
|
||||||
// $Author: giberta1 $
|
// $Author: giberta1 $
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -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,6 +43,7 @@ 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 Trim_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;
|
||||||
|
|
||||||
|
|
||||||
@ -214,7 +215,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
|
||||||
{
|
{
|
||||||
@ -226,6 +227,10 @@ public class MQSSave
|
|||||||
{
|
{
|
||||||
TI_Swift_Batch_Mode = true;
|
TI_Swift_Batch_Mode = true;
|
||||||
}
|
}
|
||||||
|
else if ( args[argc].equals( "-tm"))
|
||||||
|
{
|
||||||
|
Trim_Mode = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Output_File_Name = args[argc++];
|
Output_File_Name = args[argc++];
|
||||||
@ -258,15 +263,27 @@ 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 + ") !");
|
|
||||||
}
|
|
||||||
|
|
||||||
catch( Exception Expt)
|
|
||||||
{
|
while( QMng == null)
|
||||||
throw Expt;
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QMng = new MQQueueManager( QMng_Name);
|
||||||
|
// System.out.println( "QManager Open: (" + QMng + ") !");
|
||||||
|
}
|
||||||
|
|
||||||
|
catch( Exception Expt)
|
||||||
|
{
|
||||||
|
System.out.print("!");
|
||||||
|
|
||||||
|
if( retry++ > RETRY_MAX)
|
||||||
|
{
|
||||||
|
throw Expt;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -546,6 +563,12 @@ 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();
|
||||||
|
}
|
||||||
|
|
||||||
Flush_File.write( buffer_byte, 0, buffer_byte.length);
|
Flush_File.write( buffer_byte, 0, buffer_byte.length);
|
||||||
|
|
||||||
MQSDelete_Msg( input_msg);
|
MQSDelete_Msg( input_msg);
|
||||||
@ -656,6 +679,12 @@ 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);
|
||||||
@ -706,8 +735,8 @@ public class MQSSave
|
|||||||
|
|
||||||
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 [-mb \"message_break\"] [-tisbm [-ffn <Flush_File_Name>]] [-tm] <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: Message Break: (" + Str_UnFormat( Message_Break) + ") TI Swift Batch Mode: (" + TI_Swift_Batch_Mode + ") Trim Mode: (" + Trim_Mode + ") Flush File Name: (" + Flush_File_Name + ")");
|
||||||
|
|
||||||
System.exit( 1);
|
System.exit( 1);
|
||||||
}
|
}
|
||||||
@ -718,7 +747,7 @@ 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 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( "Message Break: (" + Str_UnFormat( Message_Break) + ") TI Swift Batch Mode: (" + TI_Swift_Batch_Mode + ") Trim Mode: (" + Trim_Mode + ")");
|
||||||
|
|
||||||
MQSInit();
|
MQSInit();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user