javabpeljboss-eap-6switchyardjboss-developer-studio

BPEL Process to Monitor a directory


I am trying to write a BPEL process to monitor a local directory for a file arrival, and do certain things with that file. I am using Jboss EAP 6.4 as my server, Switchyard as my BPEL runtime and Jboss Developer Studio for my IDE. I am extremely new to BPEL and Web services in general. I've spent the last couple weeks trying to understand what I need to do, but to no avail. My initial thought was to create a java web service to monitor the directory, then have it invoke a BPEL process to do certain things with the file. I'm wondering if I even need a service to do it or if you can do It within BPEL itself. I will be using BPEL to invoke the service that will utilize the file. Any Help would be much appreciated.


Solution

  • BPEL has the notion of event to trigger a given processing. There are timers, alarms and incoming messages. Incoming messages act like a switch statement in usual programming languages.

    So, you cannot directly listen to the file system in a BPEL process. What you would have to do would be creating a listener (in any language you want) and that invokes your BPEL process when a new file appears. BPEL is only about chaining invocations to web services. Or if you prefer, BPEL is just a way of implementing web services that make the glue between other web services. The logic behind a BPEL process is only about creating, transforming and routing messages to the right "recipients". Apart passing the file (name, reference, content...) to other web services, your BPEL process would not be able to do more. If the file content is XML, you might perform some operations on its content (thanks to XPath), but I do not know whether it is your use case or not.

    Looking at Switchyard, I see that they use Apache Camel. So, I guess you must be able to configure Camel components to achieve what you want. The editor they provide looks like the SCA editor at Eclipse.org. I do not know this solution, but I would try to create a component in this editor, have a reference (an invocation entry-point) with the "file" binding and see what we can do of this invocation. I suspect Switchyard to be able to "generate" both the listener and the process that is invoked when a new file appears. But in this case, we are not really doing BPEL anymore. It goes beyond.