Author |
Message
|
bdaoust |
Posted: Wed Sep 26, 2012 11:44 am Post subject: WMB Create folders? |
|
|
Centurion
Joined: 23 Sep 2010 Posts: 130
|
Hello everyone:
I'm pretty new to the message broker development world and was wondering if WMB has the ability to create folders on a shared network drive. Ideally, the name of the folder would come from a value within the incoming XML file.
Does anyone have an example they can share?
Thank you,
-Brian
 |
|
Back to top |
|
 |
lancelotlinc |
Posted: Wed Sep 26, 2012 12:04 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Hi Brian.
Yes, WMB can do this. WMB is a container, and operates a number of languages in the container much like WAS or Tomcat are containers.
To create a folder on a network drive from WMB, first verify that the system you are using has ability to access the network share and that the WMB Service Id has authority to write to that directory (WMB service Ids should never be 'mqm').
Next create a Java compute node that has the following:
Code: |
import java.io.*;
public void createdir()
{
try{
String strDirectoy ="test";
String strManyDirectories="dir1/dir2/dir3";
// Create one directory
boolean success = (
new File(strDirectoy)).mkdir();
if (success) {
System.out.println("Directory: "
+ strDirectoy + " created");
}
// Create multiple directories
success = (new File(strManyDirectories)).mkdirs();
if (success) {
System.out.println("Directories: "
+ strManyDirectories + " created");
}
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
|
Good luck. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
Vitor |
Posted: Wed Sep 26, 2012 12:27 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
lancelotlinc wrote: |
Next create a Java compute node that has the following: |
Or get the FileOutput node to do it for you with 1 line of ESQL. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Esa |
Posted: Wed Sep 26, 2012 11:28 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
Vitor wrote: |
Or get the FileOutput node to do it for you with 1 line of ESQL. |
By the way, FileOutput cannot create a folder on a remote FTP server. Does anyone know if this has been fixed? I made a PMR for a customer a year or two ago but I'm under the impression that nothing was done. |
|
Back to top |
|
 |
zpat |
Posted: Wed Sep 26, 2012 11:57 pm Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
What was the APAR number assigned to the problem by IBM? |
|
Back to top |
|
 |
Vitor |
Posted: Thu Sep 27, 2012 5:20 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Esa wrote: |
By the way, FileOutput cannot create a folder on a remote FTP server. |
Quite so, but the OP was talking about a shared drive.
Esa wrote: |
Does anyone know if this has been fixed? I made a PMR for a customer a year or two ago but I'm under the impression that nothing was done. |
You would be best advised to look up the PMR number. As I indicate above, my belief is that it still doesn't work. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Thu Sep 27, 2012 8:17 pm Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
Hi Vitor,
Could you share the link to the documentation that describes how to implement this with FileOutput node? I tried to find it from InfoCenter with no luck. Perhaps it was just because of my inability to use right keywords.
Vitor wrote: |
lancelotlinc wrote: |
Next create a Java compute node that has the following: |
Or get the FileOutput node to do it for you with 1 line of ESQL. |
--
Marko |
|
Back to top |
|
 |
Esa |
Posted: Thu Sep 27, 2012 11:24 pm Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
marko.pitkanen wrote: |
Could you share the link to the documentation that describes how to implement this with FileOutput node? |
Marko, I think Vitor just means the one line you need for overriding $LocalEnvironment/Destination/File/Directory
Of course you will have to write a file in the directory, too, for this to work.
zpat wrote: |
What was the APAR number assigned to the problem by IBM? |
I'm not working at that client any more. I asked them for the PRM number but they have not replied. |
|
Back to top |
|
 |
Vitor |
Posted: Fri Sep 28, 2012 5:14 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Esa wrote: |
marko.pitkanen wrote: |
Could you share the link to the documentation that describes how to implement this with FileOutput node? |
Marko, I think Vitor just means the one line you need for overriding $LocalEnvironment/Destination/File/Directory |
Esa wrote: |
Of course you will have to write a file in the directory, too, for this to work. |
I made the simplifying assumption that if you're not writing a file to it, you don't care much if the directory's there or not. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Fri Sep 28, 2012 5:55 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
|
Back to top |
|
 |
Esa |
Posted: Fri Sep 28, 2012 6:36 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
Yes it does, paragraph LocalEnvironment.Destination.File fields. So basicly you just
Code: |
SET InputLocalEnvironment.Destination.File.Directory = '<some directory path>'; |
But if for example the input message already contains the directory path, you do not need to copy it to LocalEnvironment, you just set the FileOutput node property Request directory property location to point to the correct field as documented in FileOutput node documentation.
What may have confused you is that I copied the path from FileOutput node documentation where Request directory property location uses slash as path separator. I should have put it this way:
Marko, I think Vitor just means the one line you need for setting LocalEnvironment.Destination.File.Directory |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Fri Sep 28, 2012 6:53 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
Thanks Esa,
I must need either new brains or glasses ;-) but where does it say that by setting this LocalEnvironment.Destination.File.Directory -variable FileOutput node will create the folder to file system if it doesn't exist already?
--
Marko |
|
Back to top |
|
 |
marko.pitkanen |
Posted: Fri Sep 28, 2012 11:13 am Post subject: |
|
|
 Chevalier
Joined: 23 Jul 2008 Posts: 440 Location: Jamsa, Finland
|
Yes,
I tested and it works with 6.1 and 7 ;-)
Code: |
SET OutputLocalEnvironment.Destination.File.Directory = '/home/xx/filenode/test';
SET OutputLocalEnvironment.Destination.File.Name = 'test.txt';
where folder structure .../filenode/test didn't exist before writing test.txt with File Output node
|
does the trick.
--
Marko |
|
Back to top |
|
 |
|