6 Replies Latest reply on May 18, 2011 5:08 AM by ckpasu

    NotifyFTP and URL Property Substitution

    adam704a

      Hello

       

      I am currently using the NotifyFTP action to send on the message through FTP.  Everything is working fine with that.  I even am utilizing  the property substitution for the file name it self as referenced here:https://issues.jboss.org/browse/SOA-461?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel

       

      My question is, what is the best approach for also dynamically setting the url string? I notificed that using the same syntax in the jbossesb.xml doesn't work here.  So I think I am down to extending the NotifyFTP, but didn't see anybody else doing this.

       

      Any thoughts, anyone?

        • 1. NotifyFTP and URL Property Substitution
          adam704a

          Hey everybody,

           

          I ended up extending the NotifyFTP. Works great.  I will post this in the next few days

          • 2. NotifyFTP and URL Property Substitution
            ckpasu

            Hi Adam

             

            I have been looking exactly for the same stuff, can you please post your solution of extending the NotifyFTP to get substitution work for the URL too.

             

            Thanks.

            • 3. NotifyFTP and URL Property Substitution
              adam704a

              Hi Pasu,

               

              What I ended up doing here was, I dynamically add the  FTP URL as a message property in an Action

               

              String url = createFtpUrl(hostName, userName, password);

                                                      message.getProperties().setProperty(MessageConstants.FTP_URL_PROPERTY_NAME, url );

               

               

              Then in a custom ReportNotify I referenced that message property in an overrideen getFtpConfig

               

              /**

                         * Get the ConfigTree for the 'ftp' element.

                         *

                         * @return ConfigTree

                         */

                        protected ConfigTree getFtpConfig(Message message)

                                            throws NotificationException {

               

               

                                  ConfigTree ftpConfig = super.getFtpConfig();

                                  String url = (String)message.getProperties().getProperty(MessageConstants.FTP_URL_PROPERTY_NAME);

                                  url = PropertySubstituter.replaceArguments(url, message);

                                  ftpConfig.setAttribute(FTPEpr.URL_TAG, url);

               

               

                                  return ftpConfig;

                        }

               

               

              Here is what my jboss-esb.xml looks like:

               

              <ftp URL="{ftpUrl}" deletelistFile="false"

                       filename="{org.jboss.soa.esb.gateway.file}" listFiles="false"/>

               

               

               

              I hope that helps.

              • 4. NotifyFTP and URL Property Substitution
                ckpasu

                Thanks Adam.

                 

                When I saw your original message about extending the NotifyFTP I tried to create something similar to your custom notify class overriding the getFTPConfig just like above.

                 

                However when I try to specify that on the <target class=""> I get an instantiation failure exception.

                 

                My question is where would you specify that your custom notifier have to be notified in the processing pipeline ?

                • 5. NotifyFTP and URL Property Substitution
                  adam704a

                  Here is how I am configuring my custom NotifyFTP.  This seems to work for me

                   

                  <action class="org.jboss.soa.esb.actions.Notifier" name="File Transfer Notification">

                       <property name="destinations">

                        <NotificationList type="ok">

                        <target class="com.esb.action.MysNotifyFtpList">

                      <ftp URL="{ftpUrl}"

                          filename="{org.jboss.soa.esb.gateway.file}"

                          listFiles="false"

                          deletelistFile="false"/>

                            </target>

                        </NotificationList>

                        <NotificationList type="err">

                         <target class="NotifyEmail"/>

                        </NotificationList>

                       </property>

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

                       <property name="exceptionMethod" value="notifyError"/>

                      </action>

                  • 6. NotifyFTP and URL Property Substitution
                    ckpasu

                    Adam

                     

                    Thanks for the reply. It works great now.

                     

                    The getFtpConfig() method doeesn't take Message as a parameter on the NotifyFTP class. So I created a no-arg getFtpConfig() method in my custom ftp class which took care of the overriding part. But in order to get a reference to the Message object on the custom FTP class I had to override sendNotification(Message inMessage) of NotifyFTP

                     

                    public void sendNotification(Message inMessage) throws NotificationException {

                                        this.message = inMessage;

                                        super.sendNotification(inMessage);

                              }

                     

                    Rest all changes are just similar to what you explained before. I Appreciate the help and thanks for the immediate responses.