8 Replies Latest reply on Apr 25, 2007 3:46 PM by marklittle

    How do you get particular info from listeners?

      For example,

      I have a FTP listener, looking for .txt files in a specific folder.
      And I also set up a FTP/file notifier and I want to specify to this notifier the input filename.

      I looked in the code for the FTPNotifier, I set up the config, I can put the file on the remote server with a hardcoded filename, but I didn't find any info on the following:
      Hot to extract the filename from the incoming file? Is this possible? Does the Message in the action class contain any info about the incoming protocol? (for example if it were an email listener (which I understand is not available yet), could I retrieve info like: title of message, sender, list of receivers, etc?). Do my listener class have to extend a specific class, in order to gain access to the particular properties related to that protocol???

      I found out that I can set Objects on a message, via the properties, so I can set something like this:

      props.setProperty( "fileName", "Output" + System.currentTimeMillis() + ".dat" );

      and use this property in the Notifier to be the file name. But how do I get the original name of the file? Suppose I have to retrieve ABC18042007.dat and process it and send forward ABC18042007-processed.xml.

      BTW: @jboss guys, you should write in the Javadoc that you can set only Serializable objects with that method. I tried to put a POJO on the properties and everything freezes. No exception, warning, nothing. It just stops at the line where I put the object. Could be a "bug". I'm using the sources from SVN, fresh from today.

      Also, is there a way to get feedback from the notifier? For example if I send the file via FTPNotifier and the notifier gets some error (such as the remote folder does not exist, wrong username/password, etc), all I see is a stacktrace in the console. Is there some way to retrieve the error and consider the "transaction" failed?


        • 1. Re: How do you get particular info from listeners?
          derek.adams

          The gateways are not currently adding metadata about the source of the message. I agree that it would make sense to have standard metadata for each of the gateways for things like routing and naming files.

          The case we ran into at our company was: "What if we want to handle incoming FTP messages differently based on the hostname the message came from?" It kinda goes against the ESB notion of "a service should not care where incoming data comes from", but it is a requirement in many cases.

          Anybody else know how this should be handled?

          As for handling errors in notifiers, there is still some work to be done in this area of the ESB. The notifier can throw an exception when something goes wrong on the internal protocol, but the exception just kills the action chain. There are some discussions about proper implementation of outgoing gateways in the design forums right now, so you may want to take a look there.

          Thanks,
          Derek

          • 2. Re: How do you get particular info from listeners?
            marklittle

            You can set where the message is coming from via the wsa:From EPR. It doesn't need to be set in order for messages to be delivered, but if it is set by the sender then you can do work based on the value as you mention.

            • 3. Re: How do you get particular info from listeners?
              burrsutter

              I do like the concept of having things like:
              - name of file before it was sucked in
              - the file ext
              - the hostname/ip address it came from
              - the directory it came from
              - the date/time it was sucked in
              - the size of the file in bytes (perhaps that is easy to calculate since it is in an array)


              • 4. Re: How do you get particular info from listeners?

                Hi,

                I think we will need this kind of info quite soon. Now I'm doing a skeleton app and trying to figure out all the stuff that need to be done.

                If you don't plan to have this kind of info soon enough maybe we could help a bit.

                BTW: also the info set in the "listener" could be made available to the action class (this would take care of maybe half of your list)

                • 5. Re: How do you get particular info from listeners?
                  marklittle

                   

                  "burrsutter" wrote:
                  I do like the concept of having things like:
                  - name of file before it was sucked in
                  - the file ext
                  - the hostname/ip address it came from
                  - the directory it came from
                  - the date/time it was sucked in
                  - the size of the file in bytes (perhaps that is easy to calculate since it is in an array)


                  I've modified the code so that messages can have the following properties:

                  - source of the information within the message (can be the name of the file, which will also include the directory and extension).
                  - transport used to deliver the message (though that is available via the EPR).
                  - time the message entered the ESB.
                  - time the message left the ESB.

                  This should make it into MR2.

                  • 6. Re: How do you get particular info from listeners?

                    But if I get the latest sources from SVN I will find that info, right?
                    Thanks, you are really quick :).

                    • 7. Re: How do you get particular info from listeners?
                      marklittle

                      You will once it's checked in ;-)

                      Monitor http://jira.jboss.com/jira/browse/JBESB-521 to see when that happens. Just editing some docs at the moment.

                      • 8. Re: How do you get particular info from listeners?
                        marklittle

                        I checked it into trunk. If you check out the programmers guide you'll see how you can now augment the message yourself at runtime if the metadata we add by default isn't sufficient for you.