Topic
3 replies Latest Post - ‏2012-06-08T22:15:42Z by Hal_R
Hal_R
Hal_R
8 Posts
ACCEPTED ANSWER

Pinned topic Sample Custom Sender Handler?

‏2012-02-28T23:08:57Z |
It appears I'll need to write a custom sender handler to set the name of a binary output file on an FTP destination. Are there any good examples of sender handlers online somewhere? I've looked at the Programmer's Guide, and it's good, but an actual implementation of a sender handler would be great to see.

TIA for any pointers.
Updated on 2012-06-08T22:15:42Z at 2012-06-08T22:15:42Z by Hal_R
  • Hal_R
    Hal_R
    8 Posts
    ACCEPTED ANSWER

    Re: Sample Custom Sender Handler?

    ‏2012-02-28T23:20:16Z  in response to Hal_R
    FWIW, I already found this one: https://www.ibm.com/developerworks/forums/message.jspa?messageID=14116607&tstart=0

    I was hoping to have an example that had more than just dummy code.

    Thanks.
  • AvV
    AvV
    117 Posts
    ACCEPTED ANSWER

    Re: Sample Custom Sender Handler?

    ‏2012-05-26T09:20:41Z  in response to Hal_R
    Hello Hal,

    please find below the code for modifying the output file name.
    Please let me know if this working for you.

    Thanks.
    Arjan

    Senior IT-Specialist
    WebSphere B2B (WPG/WDI), WMQ AMS, WMQ FTE
    IBM Software Services for WebSphere
    Software Group, IMT BNL

    import java.util.logging.Logger;

    import com.ibm.bcg.bcgdk.common.BusinessDocumentInterface;
    import com.ibm.bcg.bcgdk.common.Config;
    import com.ibm.bcg.bcgdk.common.Context;
    import com.ibm.bcg.bcgdk.common.exception.BCGSenderException;
    import com.ibm.bcg.bcgdk.gateway.SenderPreProcessHandlerInterface;

    public class PreProcessSender implements SenderPreProcessHandlerInterface {
    static String className = PreProcessSender.class.getName();
    public final static Logger logger = Logger.getLogger(className);

    public boolean applies(BusinessDocumentInterface businessDocumentInterface) throws BCGSenderException {
    String methodName = "applies";
    logger.entering(className, methodName);
    //TODO
    logger.exiting(className, methodName);
    return true;
    }

    public void init(Context context, Config config) throws BCGSenderException {
    String methodName = "init";
    logger.entering(className, methodName);
    //TODO
    logger.exiting(className, methodName);
    }

    public BusinessDocumentInterface process(BusinessDocumentInterface businessDocumentInterface) throws BCGSenderException {
    String methodName = "process";
    logger.entering(className, methodName);

    //TODO
    String outFileName = (String)businessDocumentInterface.getAttribute(BCGDocumentConstants.BCG_OUT_DOC_FILENAME);

    businessDocumentInterface.setAttribute(BCGDocumentConstants.BCG_OUT_DOC_FILENAME, newFileName);

    logger.exiting(className, methodName);
    return businessDocumentInterface;
    }
    }
    • Hal_R
      Hal_R
      8 Posts
      ACCEPTED ANSWER

      Re: Sample Custom Sender Handler?

      ‏2012-06-08T22:15:42Z  in response to AvV
      Arjan -- Thank you! This helps quite a bit.