8 Replies Latest reply on Jul 25, 2012 10:04 PM by tadayosi

    How to handle the failure of a Notifier?

    mimra

      Hi all

      As I understand it, notifiers are used to do outcome processing and send notifications.

      They are not part of the 'normal' pocessing of the message pipeline and neither are they part of the 'normal' error handling (setting the exceptionMethod on actions).

      How do I handle errors that occur within a notifier - for example if the FTP notifier cannot connect to the remote FTP server and therefore is unable to deliver the message via FTP.

      Maybe I need to write an action for this?
      If so then what is the purpose of the Notifier mechanism?

      Thanks.

      /Michael

        • 1. Re: How to handle the failure of a Notifier?
          zerayaqob

          Michael,

           

          Did you figure this out? I dealing with the same issue, what to do if an FTP notifier throws an exception.

           

           

          Z

          • 2. Re: How to handle the failure of a Notifier?
            tadayosi

            Hi,

             

            If you need error handling, then notifiers are not the choice because they cannot catch exceptions as Michael pointed out. Instead, you have to use routers or create custom actions for the purpose. In my opinion, notifiers should be for additional notifications where successful message delivery is not so severe, not for mainstream actions processing.

             

            Tadayoshi

            • 3. Re: How to handle the failure of a Notifier?
              zerayaqob

              Thanks Tadayoshi,

               

              The thing is I have to send a message from the bus to a remote FTP folder. From what I understand so far, a notifier is the best way to do this (is it not?). That is why I want to be able to handle a situation when a notifier throws an exception.

               

              Z

              • 4. Re: How to handle the failure of a Notifier?
                zerayaqob

                I was able to handle this by extending the native notifer and adding some error handling code in the method that actually does the sending of the file. (NotifyFTP.sendNotification(Message message)).

                • 5. Re: How to handle the failure of a Notifier?
                  tadayosi

                  Hello Zerayaqob,

                   

                  Thank you for the sharing. It sounds a more elegant and nicer approach indeed!

                   

                  Tadayoshi

                  • 6. Re: How to handle the failure of a Notifier?
                    tadayosi

                    Hello Zerayaqob,

                     

                    Please let me check what you actually did for later reference. Did you create your own class like org.jboss.soa.esb.notification.MyNotifyFTP extending the original NotifyFTP, and then configure jboss-esb.xml like below?


                    <action name="notificationAction" class="org.jboss.soa.esb.actions.Notifier">

                      <property name="okMethod" value="notifyOK" />

                      <property name="notification-details">

                        <NotificationList type="ok">

                          <target class="MyNotifyFTP">

                            ...

                          </target>

                        </NotificationList>

                      </property>

                    </action>

                     

                    Just as a humble idea, it would be nicer if the OOTB Notifier action allows custom notification classes placed in other than org.jboss.soa.esb.notification package. Of course, this would be a feature request, though.

                     

                    Tadayoshi

                    • 7. Re: How to handle the failure of a Notifier?
                      zerayaqob

                      Tadayoshi,

                       

                      here is what I used

                       

                      <NotificationList type="ok">

                             <target class="com.company.project.esb.CustomNotifyFTP">

                              <ftp

                               URL="sftp://${user}:${password}@${url}${directory}" filename="filename"/>

                             </target>

                      ...

                       

                      Notice that you are allowed to put whatever class/package in here as long as you extend NotificationTarget. What i did was get the source code for NotifyFTP and added modified the parts I wanted and left the rest untouched. This also allowed me to get the filename from the message instead of the static filename that you're forecd to use with the OOTB notifier.

                       

                      Hope this helps.

                      • 8. Re: How to handle the failure of a Notifier?
                        tadayosi

                        Thanks, Zerayaqob, for your feedback! I didn't know that the Notifier is already extensible by any classes. It is great to know that.