@@ -242,7 +242,7 @@ protected void executeCommandLine(CommandLine cmdLine) throws Exception{
242242 }
243243
244244 protected void executeMove (CommandLine cmdLine ) throws JMSException ,
245- UnsupportedEncodingException , IOException {
245+ UnsupportedEncodingException , ScriptException , IOException {
246246
247247 // Should be able to support some kind of Move operation even though the session is not transacted.
248248 boolean hasTransactionalSession = tsess != null ;
@@ -266,7 +266,7 @@ protected void executeMove(CommandLine cmdLine) throws JMSException,
266266 if (msg == null ) {
267267 break ;
268268 } else {
269- mp . send ( msg );
269+ sendWithOptionalTransformer ( cmdLine , msg , mp );
270270 if ( hasTransactionalSession ){
271271 moveSession .commit ();
272272 }
@@ -303,17 +303,12 @@ protected void executeCopy(CommandLine cmdLine) throws JMSException, ScriptExcep
303303 String haystack = ((TextMessage ) msg ).getText ();
304304 String needle = cmdLine .getOptionValue (CMD_FIND );
305305 if (haystack != null && haystack .contains (needle )) {
306- if ( cmdLine .hasOption (CMD_TRANSFORM_SCRIPT ) ) {
307- mp .send (transformMessage (msg ,cmdLine .getOptionValue (CMD_TRANSFORM_SCRIPT )));
308- } else {
309- mp .send (msg );
310- }
311-
306+ sendWithOptionalTransformer (cmdLine , msg , mp );
312307 ++j ;
313308 }
314309 }
315310 } else {
316- mp . send ( msg );
311+ sendWithOptionalTransformer ( cmdLine , msg , mp );
317312 ++j ;
318313 }
319314 ++i ;
@@ -323,6 +318,15 @@ protected void executeCopy(CommandLine cmdLine) throws JMSException, ScriptExcep
323318 " to " , cmdLine .getArgs ()[0 ]);
324319 }
325320
321+ protected void sendWithOptionalTransformer (CommandLine cmdLine , Message msg , MessageProducer mp ) throws JMSException , ScriptException , IOException {
322+ if ( cmdLine .hasOption (CMD_TRANSFORM_SCRIPT ) ) {
323+ mp .send (transformMessage (msg , cmdLine .getOptionValue (CMD_TRANSFORM_SCRIPT )));
324+ } else {
325+ mp .send (msg );
326+ }
327+
328+ }
329+
326330 protected void connect (String url , String user , String password ,
327331 Protocol protocol , String jndi , boolean noTransactionSupport ) throws Exception {
328332 if (StringUtils .isBlank (jndi )) {
0 commit comments