Have a FTP Write Out to Three Different Destination Using One Thread

Clovertech Forums Cloverleaf Have a FTP Write Out to Three Different Destination Using One Thread

  • Creator
    Topic
  • #119862
    Lane O’Brien
    Participant

      Hello,

      Is it possible to have a fileset-local and a fileset-ftp to move a file to more than one location on the outbound thread using a TCL proc of some kind.

      Basically I am picking up a file from a folder and sending it out to three separate destinations and I am using four threads to do this, one for inbound picking it up and then three static routes to deliver them to three separate threads.

      I think I have heard about having some TCL proc that does some kind of iteration and changes the destination each time. Does anyone have an example of that I can look at.

      I am not very good with TCL. I have taken the Cloverleaf TCL class but it has been awhile.

      Thank you,

      James Lane O’Brien

      Attachments:
      You must be logged in to view attached files.
    Viewing 3 reply threads
    • Author
      Replies
      • #119864
        Peter Heggie
        Participant

          Yes this can be done, and its not difficult, however the part I hesitate is where the credentials are presented. I have not done this or even know if it is possible.

          So the simplest example is if there is a FTP node/virtual directory/share called X. The FTP Fileset configuration will specify the server/IP address of your FTP site. It will also specify the userid and password. In the simplest scenario, none of these change. Your three destinations are sub folders – A, B & C, all under the parent folder X. The tcl code examines the message content or message header, possibly performs some logic and determines that the message should go to X/B, for example. The TCL code has logic like this:

          set driverctl [msgmetaget $mh DRIVERCTL]

          keylset driverctl FILESET.OBFILE “$filename”

          msgmetaset $mh DRIVERCTL “$driverctl”

          It is up to you to set $filename. It will look like “X/B/filename”.

          As you think about it, you will realize, at least for Windows, you probably have one “corporate FTP site” and under the root level are all the folders you probably have to get to, as long as your credentials are granted access to the particular folders. So even if the FTP Fileset configuration specifies a certain folder and subfolder, you can change that in TCL code in real time.

          But UNIX is different – if you have some flavor of UNIX, each UNIX server will have its own FTP server, and you will have to use different credentials for each UNIX server. If the three output threads you have in your diagram have a mix of Windows and UNIX, you will need different credentials for one server vs. another. I don’t know a way to change credentials in real time using TCL code. If one of the copies of your file goes to Windows and another copy goes to UNIX, you will need at least two output threads.

          If you want to send the same file to three target threads, use TCL code in the source thread to create two more copies:

          set driverctl [msgmetaget $mh DRIVERCTL]

           

          keylset driverctl FILESET.OBFILE “$filename1”

          msgmetaset $mh DRIVERCTL “$driverctl”

          lappend dispList “CONTINUE $mh”

           

          set newmh2 [msgcopy $mh]

          keylset driverctl FILESET.OBFILE “$filename2”

          msgmetaset $newmh2 DRIVERCTL “$driverctl”

          lappend dispList “CONTINUE $newmh2”

           

          set newmh3 [msgcopy $mh]

          keylset driverctl FILESET.OBFILE “$filename3”

          msgmetaset $newmh3 DRIVERCTL “$driverctl”

          lappend dispList “CONTINUE $newmh3”

          return $dispList

           

           

          Peter Heggie

          • #119867
            Lane O’Brien
            Participant

              Thank you for this I will have to give this a try to see if I can get it to work.

          • #119865
            Peter Heggie
            Participant

              I also want to say that you can also update the message header to specify the output thread name, so if there are multiple output threads, and the route detail configuration will not work for you, you can specify the output thread name. I am not familiar with this method. There are code samples in the older posts in this forum.

              As long as you are using the same FTP site for all the possible destinations, then you can get by with just one destination thread and you can change the particular target folder using TCL code. And you can generate additional copies of your message and send each to a particular folder.

              If the message copies you are making are intended to go to a mix of FTP sites, then you will need an output thread for each site and you will have to route each message to a particular output thread. As stated above, you can use code to change the output thread. I am uncomfortable doing this, but thats probably because I don’t have a lot of experience with it. You could could use Routing (or a Filter proc in the Route Detail) to send a message to a particular output thread. When I say use Routing, I mean create a TCL proc that is invoked on the Inbound tab for the routing type. The TCL examines the message content, determines the destination and returns a specific value to Cloverleaf, which is then used in the Routing Configuration. So the code could determine that a copy should go to output thread XYZ. The code ends with “return “XYZ”. In the Routing Configuration, you create a route called XYZ and in that route, create a Route Detail that goes to output thread XYZ.

              Peter Heggie

            • #119866
              Charlie Bursell
              Participant

                IMHO you are better off with what you have unless the sites you are sending to will be changing.

                You can certainly write a Tcl proc to send to the three using  cURL or what ever.  But what you have will be much more maintainable.

                Maybe the confusion is being able to change the metadata on an OB thread to send to different places.  However, unless I am wrong, you want to send the same message to three different servers.  Changing the metadata would send to a different server but how about the other two?

                Maybe I have misinterpreted the problem?

                • #119868
                  Lane O’Brien
                  Participant

                    So I don’t want to change any data. I want to be able to pick up the file from one thread, then move it out on the second thread, but I want that second thread to go to three different sub folders in the directory that they are going to. A validation folder, production folder, and a development folder.

                    So one file copied three times and put in the three designated folders.

                • #119869
                  Charlie Bursell
                  Participant

                    Best thing there would have the people that own the server exec a script to do that.

                    On the Cloverleaf side the only way I know to do that would be to write a UPoC driver, using cURL and send the message three times.

                    Like I said, I think you are creating a maintenance nightmare for those that might follow.

                Viewing 3 reply threads
                • You must be logged in to reply to this topic.