CEP Custom File Adapter

Good Day!
I'm new to CEP. I would like to ask how can I develop a custom file adapter wherein it tries to get only new lines added into the file.
I'm trying also to integrate this with BAM for reporting. Any tutorials out there which I can refer upon?
Thanks!
Regards,
Jeff

Hi Jeff,
You create your qwn adapter by creating a bean or an event bean.
If your adapter needs to send events to the EPN (for example the new lines that you read from the file) then you need to create an event bean.
Your event bean will needs implement the StreamSource API. If you want to read the file periodically then you will need to create a loop. One way to do this is using the RunnableBean API.
So your adapter code should look something like that:
public class FileAdapter implements StreamSource, RunnableBean{
    StreamSender sender;
    boolean suspendFlag = false;
    @Override
    public void setEventSender(StreamSender sender) {
        this.sender = sender;
    @Override
    public void run() {
        while(!getSuspendFlag()){
            // read the file
            // implement your logic
            // create an event instance
            sender.sendInsertEvent(event);
    @Override
    public synchronized void suspend() throws Exception {
        suspendFlag = true;
    private synchronized boolean getSuspendFlag(){
        return suspendFlag;
As for BAM:
One way is to put the events that your EPN produces to a queue. It is very common practice for the BAM to read messages from a queue. Since BAM is deployed on weblogic and since weblogic can also act as a JMS server, you can put the queue on the BAM weblogic.
However, if this queue needs to be highly available, or if the load on it is going to be very high, it recommended to put it on separate weblogic or weblogic cluster.
Hope this helps,
Regards

Similar Messages

  • Biztalk custom File Adapter

    Hi,
    Recently i have faced this below issue. please guide me if any one already faced similar issue. i am using Biztalk server 2013
    "Could not stop the BizTalk Service BizTalk Group : BizTalkServerApplication 
    service on Local Computer. 
    Error 1053: The service did not respond to the stop or control request in a 
    timely fashion
    when i checked event log, i am getting like
    "A timeout was reached (30000 milliseconds) while waiting for the BizTalk Service BizTalk
    Group "
    this is came after i deployed the custom file adapter.
    Actually i took the sdk samples[File Adapter] from biztalk server location path , for doing zero byte file receving process.
    I made few lines of code for promoting few properties.
    then, i used registry file to register the assemblies.
    Now i am able to receive the zero byte files and send the same file to some other location vai send port. It is woking perfectly. 
    but when i tried to restart the host instance , i am getting the above error. i am not sure why it is coming.
    i am sure about that i am getting this error if i am used custom file adaper. since if i run other  biztalk application , i dont have any issue. but if i run , the custom file adapter application . i am able to recreate this issue.
    Also, i debugged, and find out which place i am getting
    this.batch.SubmitMessage(file.Message, file.UserData); this is the method call to push the msg to biztalk db. I think some references object are not removed. when i verified the method call, it goes several event handler function. i am unable to follow that.
    Can any one help me is there any this i need to do in custom file adapter?

    Hi,
    No.it is not hanging in debugger. I am able to process the message . after that stopped the application as well, that means all the received locations are disabled. 
    but when i tried to restart the host instance, Host instance not stopping even when the application was stopped at that time.
    Also i find out one more step. if i just start and stop the application . there is no issue while restarting host instance.
    but after started the app, i tried to put one file in received location [custom file adapter], then the file is picked and the message is send to messagebox DB and send to send port. now i stopped the app, and try to restart the host instance , that time
    i am getting error.
    but if i wait for 1 more minute , service will automatically started. i don't understand this behavior.
    These are the exact below steps i did that in custom file adapter. i followed this url to do the custom file adapter http://ninocrudele.me/2012/07/05/biztalk-and-zero-byte-file/
    1. I took the SDK file adapter samples[runtime, design time and adapter management] in Biztalk installation path.
    2. add few lines of code in PickUpFilesAndSubmit
    // If we couldn’t lock the file, just move onto the next file
    IBaseMessage msg = CreateMessage(fileName, renamedFileName);
    //new code
    MemoryStream ms = new MemoryStream();
    msg.BodyPart.Data.CopyTo(ms);
    msg.BodyPart.Data.Position = 0;
    //new code end
    if ( null == msg )
    continue;
    if ( null == renamedFileName )
    files.Add(new BatchMessage(msg, fileName, BatchOperationType.Submit));
    else
    files.Add(new BatchMessage(msg, renamedFileName, BatchOperationType.Submit));
    //new code
    if (ms.CanSeek)
    ms.Position = 0;
    msg.BodyPart.Data = ms;
    //new code end
    3. build the 3 dlls.
    4. make the path change in the provided registry file and add the entry to the registry.
    5. add the adapter in admin console.
    6. create one application , create one receive port and send port. In the receive port, i used the custom file adapter.
    7. start the application and place one file in receive port . now the file is received and send to send port.
    8. now i  am trying to restart the host instance. that time i am getting the error which i above mentioned. but if i wait for 1 more minute , service will automatically started. i dont understand this behavior.
    Please help me , i facing this issue last few days . i tried maximum .but no clue.  it would be great if you guys provide if i need to check some thing else in the code part .
    Thanks
    Vinoth

  • XI File Adapter Custom File Encoding for  issues between SJIS and CP932

    Dear SAP Forum,
    Has anybody found a solution for the difference between the JVM (IANA) SJIS and MS SJIS implementation ?
    When users enter characters in SAPGUI, the MS SJIS implementation is used, but when the XI file adapter writes SJIS, the JVM SJIS implementation is used, which causes issues for 7 characters:
    1. FULLWIDTH TILDE/EFBD9E                 8160     ~     〜     
    2. PARALLEL TO/E288A5                          8161     ∥     ‖     
    3. FULLWIDTH HYPHEN-MINUS/EFBC8D     817C     -     −     
    4. FULLWIDTH CENT SIGN/EFBFA0             8191     ¢     \u00A2     
    5. FULLWIDTH POUND SIGN/EFBFA1            8192     £     \u00A3     
    6. FULLWIDTH NOT SIGN/EFBFA2              81CA     ¬     \u00AC     
    7. REVERSE SOLIDUS                             815F     \     \u005C
    The following line of code can solve the problem (either in an individual mapping or in a module)
    String sOUT = myString.replace(\u0027~\u0027,\u0027〜\u0027).replace(\u0027∥\u0027,\u0027‖\u0027).replace(\u0027-\u0027,\u0027−\u0027).replace(\u0027¢\u0027,\u0027\u00A2\u0027).replace(\u0027£\u0027,\u0027\u00A3\u0027).replace(\u0027¬\u0027,\u0027\u00AC\u0027);
    But I would prefer to add a custome Character set to the file encoding. Has anybody tried this ?

    Dear SAP Forum,
    Has anybody found a solution for the difference between the JVM (IANA) SJIS and MS SJIS implementation ?
    When users enter characters in SAPGUI, the MS SJIS implementation is used, but when the XI file adapter writes SJIS, the JVM SJIS implementation is used, which causes issues for 7 characters:
    1. FULLWIDTH TILDE/EFBD9E                 8160     ~     〜     
    2. PARALLEL TO/E288A5                          8161     ∥     ‖     
    3. FULLWIDTH HYPHEN-MINUS/EFBC8D     817C     -     −     
    4. FULLWIDTH CENT SIGN/EFBFA0             8191     ¢     \u00A2     
    5. FULLWIDTH POUND SIGN/EFBFA1            8192     £     \u00A3     
    6. FULLWIDTH NOT SIGN/EFBFA2              81CA     ¬     \u00AC     
    7. REVERSE SOLIDUS                             815F     \     \u005C
    The following line of code can solve the problem (either in an individual mapping or in a module)
    String sOUT = myString.replace(\u0027~\u0027,\u0027〜\u0027).replace(\u0027∥\u0027,\u0027‖\u0027).replace(\u0027-\u0027,\u0027−\u0027).replace(\u0027¢\u0027,\u0027\u00A2\u0027).replace(\u0027£\u0027,\u0027\u00A3\u0027).replace(\u0027¬\u0027,\u0027\u00AC\u0027);
    But I would prefer to add a custome Character set to the file encoding. Has anybody tried this ?

  • Customizing Time Stamp In Receiver File Adapter

    Hi,
    I am working in a XI to file adapter scenario.
    The default time stamp in receiver file adapter is yyyyMMdd-HHmmss-SSS.
    I want to time stamp as "ABC_MM_DD_YYYY_HH_MM_SS".
    i searched SDN,but not getting an end to end approach.
    Like...I developed a UDF ,but when I map it to receiver root node..I am getting error.
    Please help.
    Just request for a step by step procedure.
    Also,ASMA is not v clear to me......
    Plzzzzzzzzzzzz help!!
    Regards.

    Hi sriparna,
    The timestamp used by the File Receiver Adapter is a default pattern, to achieve that you have to use a UDF in the middle of the MM and set the receiver file name with the ASMA, read this for further information:
    ´´´´ Dynamic Configuration vs Variable Substitution - The Ultimate Battle for the File Name
    /people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name
    It really helps,
    regards,
    Juan.

  • File adapter custom module problem

    Dear All,
    Currently my file adapter is picking up a flat file and I have writeen a module which will remove junk characters from the start of the file...I have also used FCC to convert the flat file to xml.
    now my question is what is the sequence...
    1. is it that my FCC will convert the flat to xml first and then the module will get xml as input
    2. or is it that module will get the flat file as input , it will perform the maipultaions and then my FCC will be called to convert it to xml
    Actually after running the scenraio what we can see in the audit log is
    1.flat file converted ok and then
    2.processing module
    My requirement : module should get a flat file as input and then that module will remove junk char..after this standard FCC should convert it to XML

    1. is it that my FCC will convert the flat to xml first and then the module will get xml as input
    first FCC will get executed then MODULE
    My requirement : module should get a flat file as input and then that module will remove junk char..after this standard FCC should convert it to XML
    Dont use FCC just read .txt file after removing junk character buid the XML file using DOM parser in the MODULE itself.

  • Custom File name using File Adapter

    Hello All,
    Is it possible to name the file based on a particular XML tag? may be use an xpath expression? My requirement is to create a file name something like PO_<PO-NUM>.xml rather than using any sequence or time stamp.
    Thanks.

    Should i change anything in the file adapter's .jca file? possibly this property?
    <property name="FileNamingConvention" value="PO%SEQ%.xml"/>

  • Custom naming convention with File Adapter

    Within my BPEL process, I am using File Adapter and writing out a file. The current naming convention only all some static string with either a sequence (%SEQ%) or some sort of system timestamp. I wonder if it is possible to use some runtime data (data value within the Process Variables) as part of the file name being written out.

    Hi, the file/FTP adapters support file metadata such as filename and directory to the BPEL process and exclude the payload. set the UseHeaders parameter to true in the file adapter WSDL.
    *<jca:operation*
    PhysicalDirectory=""
    ActivationSpec="oracle.tip.adapter.file.inbound.FileActivationSpec"
    PhysicalArchiveDirectory=""
    DeleteFile="true"
    IncludeFiles=""
    PollingFrequency=""
    MinimumAge="0"
    OpaqueSchema="false" >
    UseHeaders="true"
    *</jca:operation>*
    thanks.

  • File Adapter: need to include filename in content being written

    I want to use the file adapter to write a file, using the filename convention to generate part of the name dynamically.
    However, I need to include the filename used for the output file in the actual content too.
    Any ideas if this can be done?
    Thanks
    Toby

    At a customer we implemented the file adapter to create a file based on a specic name for appending:
    <assign name="AssignStaticFilename">
    <copy>
    <from expression="'Output.csv'"/>
    <to variable="gFileAdapterOutboundHeader" part="outboundHeader" query="/ns2:OutboundFileHeaderType/ns2:fileName"/>
    </copy>
    </assign>
    In de FileAdapter WSDL we set:
    <jca:operation
    LogicalDirectory="OutputDirectory"
    InteractionSpec="oracle.tip.adapter.file.outbound.FileInteractionSpec"
    FileNamingConvention="%SEQ%"
    NumberMessages="1"
    OpaqueSchema="false"
    Append="true" >
    </jca:operation>
    Does this help you, based on a given input to set the filename and this variable to put it into the file?

  • Adapter Module for Sender File Adapter to access a Flat file

    Hi,
    We have a scenario where the source is a flat file.I want to develop an Adapter Module to make a small change to every line in the Flat file.
    Now how do we read a flat file in the Adapter Module?Coz the flat file will be converted to XML file by the Standard Adapter Module of the File adapter.
    Please help me out with this.
    Thank you,
    Anu.

    Hi Anu,
    If you are not using Content Conversion option Standard Adapter Module does not convert the Flat file to XML .
    You can directly access the payload as it is in flat file in the Adapter Module and make changes.
    Use the Standard classes ModuleData & moduleContext to fetch the Payload.
    chk this :
    Customized Sender Adapter Module
    XI: Read data from PDF file in Sender Adapter
    regards
    Ganga

  • File adapter:FizeSize property doesn't effective if choose "Append" propert

    Hi
    I used file adapter to write a file to a Linux box, I use "*Append to existing file*" property, but it seems I can't use FileSize to limit the size of the file?
    I want to use Append to existing file and if the size of the file over than 1M, then generate a another new file, so the same behavior with this new generated new file.
    Any ideas is appreciated.
    Thanks

    This is as per the design. If you choose append to file option, the batching options such as Number of Messages Equals, Elapsed Time Exceeds, File Size Exceeds does not work.
    You may write a custom utility which keep checking the file size and renames it after it exceeds a particular size. You may also raise an enhancement request with support if you have a strong use case where this facility must be there OOB.
    Regards,
    Anuj

  • File Adapter - Exception / Error handling

    We are using File Adapter in BPEL process to read multiple records from the file. Additionally, we have also handled rejectedMessageHandlers & fatalErrorFailoverProcess exception to lunch custom BPEL process. The process is running fine and also successfully launches custom handler processes too.
    Need help / direction in addressing following issues.
    1. While reading from file, if a records errors out, the custom BPEL process is launched (as specified in rejectedMessageHandlers property). In such instance, the previously read valid records are processed but remaining records are marked as errored out. Our requirement is to make entire record set as invalid and would like to perform rollback of entire process.
    2. Whenever an error occurs during reading the records using File adapter, the associated data file is being deleted from the input directory and also NOT available in archive directory also.
    Are we missing any set up ? We are on 10.1.3.1
    thanks
    -Yj
    Sample Log file:
    <2009-04-20 11:46:14,080> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::init - Initializing the JCA activation agent, processId='bpel://localhost/default/TestFileRead~1.0/
    <2009-04-20 11:46:14,080> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> JCAActivationAgent::initiateInboundJcaEndpoint - Creating and initializing inbound JCA endpoint for:
    process='bpel://localhost/default/TestFileRead~1.0/'
    domain='default'
    WSDL location='Read.wsdl'
    portType='Read_ptt'
    operation='Read'
    activation properties={portType=Read_ptt, rejectedMessageHandlers=bpel://default|AdapterError2|initiate|payload}
    <2009-04-20 11:46:14,096> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Adapter Framework instance: OraBPEL - endpointActivation for portType=Read_ptt, operation=Read
    <2009-04-20 11:46:14,143> <INFO> <default.collaxa.cube.activation> <File Adapter::Inbound> Endpoint Activation called in File Adapter for endpoint: c:\temp\yj
    <2009-04-20 11:46:14,143> <INFO> <default.collaxa.cube.activation> <AdapterFramework::Inbound> Adapter Framework instance: OraBPEL - successfully completed endpointActivation for portType=Read_ptt, operation=Read
    <2009-04-20 11:46:30,580> <WARN> <default.collaxa.cube.activation> <File Adapter::Inbound> PollWork::run exiting, Worker thread will die
    <2009-04-20 11:47:14,158> <INFO> <default.collaxa.cube.activation> <File Adapter::Inbound> Translated inbound batch index 1 of file {testdata6.txt} with corrupted message count = 1
    <2009-04-20 11:47:14,158> <INFO> <default.collaxa.cube.activation> <File Adapter::Inbound> Sending message to Adapter Framework for rejection to user-configured rejection handlers : {
    fileName=C:\temp\yj\testdata6.txt, startLine=3, startColumn=1, endLine=-1, endCol=-1, Exception=ORABPEL-11168
    Error while reading native data.
    [Line=3, Col=5] Expected "|" for the data starting at the specified position, while trying to read the data for "element with name C2", using "style" as "terminated" and "terminatedBy" as "|", but not found.
    Ensure that "|", exists for the data starting at the specified position.
    <2009-04-20 11:47:14,158> <WARN> <default.collaxa.cube.activation> <AdapterFramework::Inbound> [Read_ptt::Read(Root-Element)]onReject: Sending invalid inbound message to Exception Handler: bpel://default|AdapterError2|initiate|payload
    <2009-04-20 11:47:14,315> <INFO> <default.collaxa.cube.activation> <File Adapter::Inbound> Setting last error record to : -1
    <2009-04-20 11:47:14,658> <ERROR> <default.collaxa.cube.activation> <AdapterFramework::Inbound> onBatchFailure: Batch 'bpel://localhost/default/TestFileRead~1.0//testdata6.txt_1240205493408' (C:\temp\yj\testdata6.txt) has failed due to: ORABPEL-11168
    Error while reading native data.
    [Line=3, Col=5] Expected "|" for the data starting at the specified position, while trying to read the data for "element with name C2", using "style" as "terminated" and "terminatedBy" as "|", but not found.
    Ensure that "|", exists for the data starting at the specified position.

    Any light / idea on the following issue ?
    1. While reading from file, if a records errors out, the custom BPEL process is launched (as specified in rejectedMessageHandlers property). In such instance, the previously read valid records are processed but remaining records are marked as errored out. Our requirement is to make entire record set as invalid and would like to perform rollback of entire process. Even, if we do not configure rejectedMessageHandlers, the behavior is that valid rows are processed with the rest of BPEL process and for Invalid rows, the records are rejected. Our requirement, is that, even if there is one invalid record, the entire set of record should NOT move ahead with the BPEL process
    2. Whenever an error occurs during reading the records using File adapter, the associated data file is being deleted from the input directory and also NOT available in archive directory also. Note, in case of all valid record the file is available in archive directory

  • Dynamic FTP Directory Address in File Adapter - is this possible?

    We have a customer who would like us to pick up a file via an FTP file adapter once per day. The problem is, they have a different directory each day containing the file. The directory name is of the form YYYY-MM-DD. The name of the file in the directory is always the same.
    Is it possible to dynamically calculate the Source Directory name in the FTP file adapter? If so, how?
    Kind Regards,
    Tony.

    >
    Dharamveer Gaur wrote:
    > Hi
    > Look this same thread:
    > Re: Dynamic folder name (when reading file in file adapter)
    Hi,
    All the examples I have seen are to configure the Receiver File Adapter, not the Sender File Adapter. I don't thinl I have seen one blog yet whereby the source directory of a Sender File Adapter has been dynamically configured. I wonder if it can be done because the sender file adapter does not have Variable Substitution possibilities for filenames and directories.
    So has anybody a link to a blog where this dynamic choice of a source directory has been done for a SENDER file adapter?
    BR,
    Tony.

  • Sender file adapter conversion Error!!

    Hello every one....
    I am stuck with a problem...in my scenario,, there are possiblities that file may contain more than required paramters... in such case,,, paramters defined in conversion should go ahead and others should be ignored...
    for this very purpose i added the paramter:
    row.fieldSeparator                 ,
    row.fieldNames                     orderno,authcode,status
    row.endSeparator                  'nl'
    row.additionalLastFields      ignore
    the scenario works fine if the file contains thrree comma separated values but it raises an error if no of paramters increase as :
    Conversion of file content to XML failed at position 0: java.lang.Exception: ERROR converting
    document line no. 1 according to structure 'row':java.lang.Exception: ERROR in configuration: more
    elements in file csv structure than field names specified!
    we are using PI 7.... does it require some more configuration in additoin to paramter row.additionalLastFields
    any help in this regard would be highly appreciated...
    thanx

    this parameter is already set, and this is the exact behavior i want from adapter engine...  but the problem
    here is different... the exception is raised at communication channel's conversion routine level,,, the retry
    interval is not the one defined in visual admin but infact the interval (polling) time defined in communication
    channel.... the system does'nt stop after 3 attempts,, but infact keep on trying to read it....
    one peice of information i  have found is in sap note:821267 , which states:
    *Q35:*
    Q: I have configured a File Sender channel with File Content
    Conversion or a custom-developed module, which may throw an
    exception. When the File Adapter encounters an invalid file, which
    triggers a conversion error or an exception in a module, the
    adapter will enter a retry interval and upon each following
    processing attempt try to process the faulty file. This basically
    prevents the File Adapter from picking up files that are located
    after the fauilty file according to the configured sort order. How
    can I change this behavior?
    o A: This is by design. When the File Adapter encounters an invalid
    file, manually remove this file from the configured source
    directory. You can configure an alerting rule to get notified each
    time this occurs.
    We are currently evaluating possible solutions that could be used
    to skip this manual interaction.
    now can there be a way around to make communication channel read the file only 3 times (value defined in adapter engine profile in visual admin)
    I have thaught of writing of module.... but the error is raised even before calling module !!
    any further clue ???

  • File Adapter Module - Change name of Generated File

    Hello all,
    My customer has XI v3.0 SP9. For the moment an upgrade is not envisaged.
    Since SP14 it is possible to dynamically change filename generated with receiver File adapter. This is done with a manipulation during mapping and a configuration in adapter.
    As I am in SP9, is there another solution, by example using a module processor ?
    My XML :
    <root>
        <lineFile>....</lineFile>   
        <lineFile>....</lineFile>
        <lineFile>....</lineFile>
        <filename>
    </root>
    Thanks a lot,
    J.C.

    Hi,
    AFAIK - as far as I know
    >>>>(Too much tests to do on other processes)
    it's good this way the customer will learn the need for test tools
    like mercury loadrunner - you can store all the tests inside
    and when an upgreade comes just execute them...
    customers always learn the hard way
    Regards,
    michal

  • Retrieving the file name in the adapter module in the sender file adapter

    hi,
    i need to retrieve the file name, in the adapter module. This module is placed in the sender file channel.
    After the file adapter has picked up the file from the file directory, the file is placed in the archived directory.Custom adapter mofule is place in the file shanel. i need to retrieve the file name of the file in the adapter module. Is it possible to retrieve the file name?
    Also is it possible to retrieve the archive directory path in module?
    Regards,
    Meenkashi

    Hi Meenakshi,
    I guess you are looking for this
    /people/daniel.graversen/blog/2006/10/05/dynamic-configuration-in-adapter-modules
    Regards
    Suraj

Maybe you are looking for