This discussion is archived
1 Reply Latest reply: Sep 2, 2013 11:19 AM by 887796 RSS

CEP Custom File Adapter

jeffhaw Newbie
Currently Being Moderated

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

  • 1. Re: CEP Custom File Adapter
    887796 Newbie
    Currently Being Moderated

    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

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points