13 Replies Latest reply on Jul 25, 2007 2:02 AM by beve

    Scheduling of services

    beve

      Hi,

      I've been working on creating a Web Service Listener that will poll a web service and then execute an action pipeline. We have no option but to poll very frequently to have a good enough response time, so the need to be able have a little more control over when a service is triggered emerged.
      After having refactored the polling to be able to use it for the WSListener, I had a chat with TomF about this matter and this a suggestion for scheduling of services.

      Below is an example of what a configuration of scheduling could look like (example is from the helloworld_file_action quickstart):

      <fs-listener name="FileGateway"
       busidref="helloFileChannel"
       maxThreads="1"
       is-gateway="true">
       <property name="cronExpression" value="0/30 * * * * ?" />
       <property name="startDate" value="07-07-08 19:17:00" />
       <property name="endDate" value="07-07-08 19:20:00" />
      
       <!-- or simply specify
       <property name="pollLatencySeconds" value="10" />
       <property name="repeatCount" value="6" />
       -->
      
      </fs-listener>
      

      The properties startDate and endDate are optional, aswell as the repeatCount if one want's to specify a pollLatencySeconds like you can do in the current code base.
      The scheduling uses Quartz and the cronExpression is a Quartz CronExpression.

      An AbstractScheduler that extends AbstractThreadedManagedLifecycle has been created which can be "inserted" into the inheritence chain, which is what has been done for AbstractFileGateway. I didn't want to have to refactor too much of the code and this felt like way to not have to.
      This is the first time I've used Quartz so if anyone has used it before it would be great if you could take a look:)

      This would not only let services like gateways and listener so be scheduled, it should be usable for other types of service that to not need to call an action pipeline, like BAM services for gathering statistics for example.

      This can be found in the workspace http://anonsvn.jboss.org/repos/labs/labs/jbossesb/workspace/dbevenius/wslistener if anyone feels like trying it out. Just do a normal build and then start the jbossesb-server, then run the helloworld_file_action quickstart.

      Any suggestions, additional requirements and comments are welcome.

      Thanks,

      Daniel


        • 1. Re: Scheduling of services
          marklittle

          Any chance you could create a diagram illustrating the components (services etc.) in your use case? Stick it on the wiki and then refer to it here. That'd make any discussion easier and less prone to misinterpretation of what you're doing. Thanks.

          • 2. Re: Scheduling of services
            beve

            Yeah sure, I'll see what I can do.

            /Daniel

            • 3. Re: Scheduling of services
              beve

              I've added a wiki page that can be found here http://wiki.jboss.org/wiki/Wiki.jsp?page=SchedulingOfServicesDesignNotes

              /Daniel

              • 4. Re: Scheduling of services
                marklittle

                Looks good to me.

                • 5. Re: Scheduling of services
                  tfennelly

                  To add another twist to this....

                  What I was thinking re scheduling was to have a "ScheduledEventProvider" (e.g. <sevent-provider> that generates scheduled events). With that, you could then have a "ScheduledEventListener" (<sevent-listener>) which listens to the <sevent-provider>.

                  The <sevent-listener> could be configured with a MessageComposer in the same way all (or at least some) of the other listeners can be configured with a composer (org.jboss.soa.esb.listeners.message.MessageComposer impl) that does whatever is needed.

                  So, taking the WSListener as an example, it would actually be implemented as a MessageComposer that sits on a <sevent-listener> and when triggered (asked to "compose"), it goes off and makes the SOAP invocation and uses the result to compose the org.jboss.soa.esb.message.Message payload to be processed by the service pipeline (or whatever).

                  Just another option :-)

                  • 6. Re: Scheduling of services
                    marklittle

                    I like that option. I think it's more extensible too. However, it sounds like more of a re-working of the architecture would be required to do that.

                    • 7. Re: Scheduling of services
                      tfennelly

                      Well, it's based on the same architecture - providers, listeners, composers etc. I really think it'd mostly be a case of moving code around (and removing code). Anyway, the existing candidates for this model (FileGatewayListener etc) could be converted over time i.e. they'll still work as is. New ones can be based on whatever we do now.

                      On the existing ones... I think we all agree that most of these require a rework/rewrite anyway coz they're a bit of an unmaintainable mess. I know what yer going to say... post GA ;-)

                      • 8. Re: Scheduling of services
                        marklittle

                         

                        "tfennelly" wrote:
                        Well, it's based on the same architecture - providers, listeners, composers etc. I really think it'd mostly be a case of moving code around (and removing code). Anyway, the existing candidates for this model (FileGatewayListener etc) could be converted over time i.e. they'll still work as is. New ones can be based on whatever we do now.


                        I know there's a JIRA associated with what Daniel has already done, but can you create a separate JIRA around your other suggestion: 5.0 timeframe?


                        On the existing ones... I think we all agree that most of these require a rework/rewrite anyway coz they're a bit of an unmaintainable mess. I know what yer going to say... post GA ;-)


                        You read my mind! ;-)

                        • 9. Re: Scheduling of services
                          tfennelly

                           

                          "mark.little@jboss.com" wrote:
                          I know there's a JIRA associated with what Daniel has already done, but can you create a separate JIRA around your other suggestion: 5.0 timeframe?


                          I create the JIRA (JBESB-725) and it's in for 5.0 MR1.

                          • 10. Re: Scheduling of services
                            beve

                            Hi,

                            I've updated the wiki page with the suggestion given here.
                            Tom, could you take a look an make sure that this is what you meant?

                            I might need this sooner that I had previously thought. For our WSGateway we need to perform an additional task before creating the SOAP message as we need to pass variable arguments to the web service. We need to maintain state between calls and we also need to perform a task after the message has been retreived to update the state.

                            The way I've been doing it was letting the WSGateway have an abstract method so that subclasses can perform tasks prior to invoking the web service.
                            And subclasses can also implement a method that will be invoked after the action processing pipleline is completed by waiting for a reply like this:

                            TwoWayCourier replyCourier = CourierFactory.getPickupCourier( replyEpr );
                            try
                            {
                             Message replyMessage = replyCourier.pickup( maxMillisForResponse );
                             responseMethod.invoke( responseObject, new Object[] { replyMessage });
                            }
                            



                            I think I'm instead going to use the a scheduling listener only to trigger an action pipeline process that starts a jBPM process, so the compose method will simply create an empty ESB Message object. The jBPM process will perform the first task which will add information to the ESB Message object and then invoke a service that sends the message to the web service(using a SOAPClient action). The final step in the process will be the updating of the state which will complete the jBPM process.

                            Any comments or suggestion on this are welcome?

                            Thanks,

                            Daniel


                            • 11. Re: Scheduling of services
                              tfennelly

                              Dan, I definitely think that if you've got state to manage in this, you should be using a BPM tool of some sort (jBPM, ActiveBPEL etc). These would also be able to perform the SOAP invocation (and probably even the scheduling of that).

                              So, I think your new approach is def better :-)

                              • 12. Re: Scheduling of services
                                tcunning

                                Are there any plans to tie the ESB into something like Quartz as a scheduler?

                                • 13. Re: Scheduling of services
                                  beve

                                  Hi Tom,

                                  yes there are. TomF is currently working on this for http://jira.jboss.com/jira/browse/JBESB-725

                                  Some more info can be found on this wiki page : http://wiki.jboss.org/wiki/Wiki.jsp?page=SchedulingOfServicesDesignNotes.

                                  /Daniel