Author |
Message
|
cwazpitt3 |
Posted: Mon Mar 05, 2012 1:36 pm Post subject: How can I halt the creation of a batch file creation |
|
|
Acolyte
Joined: 31 Aug 2011 Posts: 61
|
I am working on a flow that uses record by record writing to an output file and I want to "cancel" file creation when certain conditions are met (i.e. the count on the trailer record does not match the total records processed). When I throw an exception in the ESQL node connected to finish file terminal of the fileoutput node, it halts the flow, which is desired, however, it keeps the partially built file in the mqsitransit folder of the output directory. This would be OK, but if I drop the same file again for processing (with the same name), now it will append all of the "new" records to the partially built file and what I end up with is a huge mess of an XML file. Changing the file name on re-drop is not really a solution because it leaves room for human error if they don't know the process.
Is there any way to cause the file output node to "stop" building the output file and rollback what it has done (i.e. delete the file in mqsitransit)? I have not found much information about this in docs so I figured I would ask the experts. My next best solution is to call a shell script to delete the file out of the mqsitransit directory whenever this error is encountered, but this just doesn't seem like it should be the only way to handle this problem. Any ideas or workarounds?
Thanks in advance for your help. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Mar 05, 2012 1:37 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
 |
cwazpitt3 |
Posted: Mon Mar 05, 2012 1:40 pm Post subject: |
|
|
Acolyte
Joined: 31 Aug 2011 Posts: 61
|
Sorry, Message Broker 7.0.0.2 |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Mar 05, 2012 1:41 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
You can control the naming of files using $LocalEnvironment/Destination/File/Name . Append a time to that name and you'll have aunique file every time. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
cwazpitt3 |
Posted: Mon Mar 05, 2012 1:43 pm Post subject: |
|
|
Acolyte
Joined: 31 Aug 2011 Posts: 61
|
lancelotlinc wrote: |
You can control the naming of files using $LocalEnvironment/Destination/File/Name . Append a time to that name and you'll have aunique file every time. |
Yes, I thought of that too and its a good fix, however, the system consuming the file cannot handle a timestamp in the file name (sad isn't it?). |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Mar 05, 2012 1:44 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
I said "time" not "timestamp". As far as the file system is concerned, its just a string of numbers. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
cwazpitt3 |
Posted: Mon Mar 05, 2012 1:49 pm Post subject: |
|
|
Acolyte
Joined: 31 Aug 2011 Posts: 61
|
lancelotlinc wrote: |
I said "time" not "timestamp". As far as the file system is concerned, its just a string of numbers. |
In either case, they want a file called, output.xml everytime, that's what I meant by cannot handle timestamp.
I just remembered that I might have some control over that because there is a flow that picks up this created file and FTP's it over to their server. I think I can look at the filename and change it in that flow before it goes out the door. Thanks for the idea!
Is there no way that you know of to do what I was asking though? |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Mar 05, 2012 1:51 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
1. >> In either case, they want a file called, output.xml everytime << So you take the file that was created and you rename it to whatever filename they want.
2. >> Is there no way that you know of to do what I was asking though? << Using JCN or ESQL, delete the file in your exception processing. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
cwazpitt3 |
Posted: Mon Mar 05, 2012 1:53 pm Post subject: |
|
|
Acolyte
Joined: 31 Aug 2011 Posts: 61
|
OK great. Thanks for the help. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Mar 05, 2012 1:55 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Glad to help out. Should be an easy task to delete the partial file in your exception processing. Post back if you run into problems. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
cwazpitt3 |
Posted: Mon Mar 05, 2012 1:59 pm Post subject: |
|
|
Acolyte
Joined: 31 Aug 2011 Posts: 61
|
I actually think the first solution of renaming works better for me because I already have another flow reading that file where I can control the rename. If I had to delete, I would use jcn to call a shell script. Out of curiosity is there an easier way? |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Mar 05, 2012 2:04 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
JCN to shell script is good. JCN directly (ie. java.io.File class ) also would work. Remember, anything you can do in a POJO, you can do from a JCN. For Java code more than a line or two, I prefer to use a Jar and write Junits against the Jar. Then call the Jar from the JCN. Also, directly calling log4j from JCN or ESQL is a great way to verify functionality during operation. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
cwazpitt3 |
Posted: Mon Mar 05, 2012 2:12 pm Post subject: |
|
|
Acolyte
Joined: 31 Aug 2011 Posts: 61
|
We actually use the IAM3 support package and do logging throughout our code. It has its quirks but it works pretty good. Do you use jcn a lot? I thought the best practices from IBM said to avoid if possible. That's a good tip to create a separate jar and use junit; its typically what we do. Wish mb provided some type of automated unit testing. |
|
Back to top |
|
 |
cociu_2012 |
Posted: Tue Mar 06, 2012 12:39 am Post subject: |
|
|
Acolyte
Joined: 06 Jan 2012 Posts: 72
|
cwazpitt3 wrote: |
If I had to delete, I would use jcn to call a shell script. Out of curiosity is there an easier way? |
My personal opinion is that using shell script is not a good idea, and it's outside of broker development.
The answer is easy, consume your file.
On error handling mechanism , have a FileRead Node to consume it.
I would change the entire solution, and propagate to FileOutput node when no error/logical error is raised. |
|
Back to top |
|
 |
cwazpitt3 |
Posted: Tue Mar 06, 2012 4:14 am Post subject: |
|
|
Acolyte
Joined: 31 Aug 2011 Posts: 61
|
cociu_2012 wrote: |
cwazpitt3 wrote: |
If I had to delete, I would use jcn to call a shell script. Out of curiosity is there an easier way? |
My personal opinion is that using shell script is not a good idea, and it's outside of broker development.
The answer is easy, consume your file.
On error handling mechanism , have a FileRead Node to consume it.
I would change the entire solution, and propagate to FileOutput node when no error/logical error is raised. |
@cociu_2012 I like your idea of using the FileRead node in the exception path...I might try that out.
As for your suggestion about changing the entire solution, I really didn't understand what you meant. In this case, I am reading record by record not whole file, so I really cannot stop processing until all records are read (i.e. in ESQL that connects to FinishFile). Even if I throw an exception while processing (i.e. when an error/logical error is found), it must continue to process the rest of the file. Please let me know if this is not what you meant. |
|
Back to top |
|
 |
|