Creating a custom task scheduler in Adobe CQ - quartz-scheduler

We have a specific requirement to create a custom scheduler in CQ to perform some admnistrative tasks based on some parameters specified by the administrator. I have seen the Scheduler service offered by Sling. But wanted to know whether there is any issues in using Quratz APIs direcly rather than using this sling wrapper to schedule the tasks? Wanted to know did any one us alredy has developed such a CQ Component?
Is there any issue in invoking CQ flush agent programatically (as a scheduled Job, which runs periodically based on some configurations)?
Any pointers in this area would help us a lot.
Thanks,
San

Schedulers in CQ are working well. I programmed many in my years as a CQ developer. It is an OSGi service either implementing the java.lang.Runnable or org.apache.sling.commons.scheduler.Job. The former is usually enough. You only have to configure the scheduler.expression property which follows the quartz syntax and implement the run method.
I can't answer that as I never tried it. But I don't see why it shouldn't work. At my customer we have an independent cron job deleting the dispatcher cache instead of using a flush agent.

Related

How can I prevent Service Fabric from generating Default Services for Actors

Everytime I build my Service Fabric solution in Visual Studio, the ApplicationManifest and ServiceManifest are modified and Default Services entries are added for all Reliable Actors in my solution.
How can I prevent that?
Note: Default Services are not created for the Reliable Services which is what I am expecting.
Ultimately, our goal is to create an "empty" Named Application instance every time a new tenant/customer signs up through our Web Portal (one instance of the application type per tenant).
Then the tenant can enable/disable features through our Web Portal which translates to creating/removing an instance of an Actor/Service types inside the tenant's application instance.
Thanks for providing guidance if this is not the right way to implement isolation in multi-tenancy scenario in Service Fabric.
Thanks Kiryl... I finally found an article that explains the way to disable the generation of in the application manifest while building the Service Fabric application in Visual Studio.
Open the .csproj of the Actor project and modify the following property to "false"
<UpdateServiceFabricManifestEnabled>false</UpdateServiceFabricManifestEnabled>
You can find the article here: https://github.com/Azure/service-fabric-issues/issues/271
Cheers!
I'd say you can't... There was a time I was trying to set my own settings for partitioning scheme(switch the default one to Named partitioning or change low/high key for UniformInt64) but VS was overriding them no matter what I did. Turned out it was an expected behavior as I 'misunderstood' how partitioning is applied with actors, so VS gladly was 'fixing' my mistakes. See Can't change partitioning scheme for actors for the reference. The bottom line is, seems like VS adjusts Actors Service manifest to preserve the holy purpose of actors as a pattern.
As for multi-tenant application, consider deploying a separate app type with its own settings per each customer/tenant.
P.S. I was able to get what I want by deploying Actors Service manually rather than via VS, but that's another story.

Advice needed on workflow

We are currently trying to decide how to implement workflow into our enterprise application. We must support very complex workflow scenarios and we must also handle approx 10000 concurrent users. The application domain is healthcare. The client is a WPF application talking to an IIS backend using WCF. The question is: Does anybody have any experience with Windows workflow foundation in such a large enterprise application? From the requirements is seems like WWF fits the bill, but I am worried about performance and scalability. Should I continue to investigate into WWF or is WWF just not suitable for this kind of applications? We also need to let our consultants have the ability to alter workflows and re-hosting the WWF designer certainly sounds tempting. What do you think. Is WWF the way to go? 
You can create a workflow that is directly hosted by IIS. You can use the "Receive" activity to setup the WF to handle requests. You can then attach a "Send" activity to reply back to the client with a response, and even have the workflow continue processing in the background that activity. Hope that provides some direction to get you started. You can achieve this with either the .NET Framework 3.5 or 4.x versions, but .NET 4.0 is much easier to setup.
The performance will rely on the hardware.
Anyway, workflow services are perfectly scalables in IIS. You will be able to set up a server farm that will serve all the request.
Regarding the requirement of altering workflows, always is possible to alter the workflow in a way that future requests will create instances of the new altered workflow. Old and already initiated workflows can not take any variation. So,if I have not understood wrongly, WWF does not fit this requirement.

Searching workflow/process tool based on ZF

Does anyone know a workflow system based on Zend (or php), which is open source and can be integrated in a project? What do I understand as workflow system:
User starts a workflow through submitting some start parameter (e.g. SOAP/HTML request)
Zend runs the workflow in the background (on high server load the operations are lined up in a queue)
Workflow may be build out of several modules/actions e.g. export xml > create pdf > send pdf to user > send email (Backend)
User sees current status of the running workflow online and gets the result as soon as finished through ajax requests to the server. (User Interface)
Admin has a overview of general running workflows (Admin Interface)
Thanks for your hints!
If I understand correctly, the workflow is just a pre-defined set of actions.
I don't believe there is a ready tool for this, but I think you may be interested in running a set of cron jobs from the Zend Framework CLI (e.g. building your own Zend_Tool Provider) and in Zend_Queue.
You might want to use the right tool for such task - eg. Gearman. It is a piece of software solely for the requirements you described. See more here:
http://www.slideshare.net/felixdv/high-gear-php-with-gearman
http://weierophinney.net/matthew/archives/240-Writing-Gearman-Workers-in-PHP.html
You may want to try eZ Components Workflow library: http://www.ezcomponents.org/docs/api/trunk/introduction_Workflow.html
This post describes how to integrate the eZ Components library with Zend:
http://devzone.zend.com/article/156
Other than that I haven't found any real examples of integrating the eZ workflow classes with a Zend MVC application.
Symfony has a component for this. http://symfony.com/doc/current/components/workflow.html
Oro platform has a bundle for this.
https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/WorkflowBundle/Resources/doc/index.md
Otherwise, you could build your own implementation based on maybe the State design pattern. Here is a nice example from Sebastian Bergman.
https://github.com/sebastianbergmann/state

should I invoke Grails controller from Quartz job for REST API calls?

I've seen a number of postings citing that quartz jobs should not invoke controllers. I'm using Grails to use salesforce.com's new support for the REST API. The nightly job would use that API to update customer data from our proprietary DB to the salesforce environment. There is a session that is created using a login id.
So... I would like to use the jobs plug-in for grails to give me the cron-style way to invoke controllers that interact with services in order to send REST API calls via httpclient to update/upsert our objects in salesforce.com land.
It seems like this would be a legitimate reason for invoking controllers from the jobs area in Grails.
Would love any feedback or alternative approaches (within Grails) for handling this.
thx, David
Why have you invoke controllers from Quartz jobs ? This looks whery awkward.
User grails services.
Quartz plugin has dependency injection so it should be easy to invoke service methods.
Even if you invoke a controller from a quartz task, you won't be able to access the session because there will be no authenticated user. If you want to make some complex business logic put it in a service and then call it from your job. Declaring services in quartz jobs is exactly the same as the declaration in the controllers.
I feel the question is a valid one. I had a similar requirement. I used grails rest plugin. A grails controller action that exports some report data into excel and email it to emailing list on daily basis. So I created a method in controller:
def exportToExcel() {
myService.exportToExcel(response)
}
Then besides exportToExcel() implementation in myService.groovy, I created an additional method as under:
def runExportToExcelJob() {
withHttp(uri: "http://localhost:9092/myProject/"){
return get(path: 'myController/exportToExcel')
}
}
And finally, in my grails quartz job, I invoked myService.runExportToExcelJob().
It works fine. But I too wonder, if there is another way of making a rest call from grails job. Any feedback is really appreciated.

Drools 5 exposing it to web application and webservices(SOAP) using jaxb

We have reqmt. where we need to expose drools 5 with ESB and similteniously with the web application.Although i have figured out ways to run drools with eclipse,however finding it difficult to configure Drools 5 with same web-app at the moment and shift it esb in future.
Guvnor and Drool-Server are not just sufficient to help me out neither does googling it helps
,even spring support is also not available.
Any help will be highly appreciated...Thanks
At what level do you need to "expose" Drools within the ESB? I use Drools in an Enterprise solution that uses asynchronous web services; many of my workflows are extremely long running (2 weeks to a month). The key is to temporarily persist the StatefulKnowledgeSession between calls. There is a JPAStatefulKnowledgeSession that serializes the session and stores it as a blob in a relational database. I decided not to use this solution because many of my asynchronous tasks finish within a second of being called. The performance cost of persisting the process in a RDBMS was too much for my needs. My solution was to store the session in an in-memory cache. Infinispan was ridiculously simple to configure and use, and I haven't had a single issue with the framework.
Do you need to have the ESB and Web Application use the same KnowledgeSession? Does it have to be a StatefulKnowledgeSession? If you need to maintain state, you should consider a queue-based system and fireAllRules() at some interval. If your actions are command based (insert object, start process, etc), I believe Drools already has an API for the pattern (I believe this is what Drools Server does under the hood). You could also make the KnowledgeSession a singleton; but consider using a ReentrantLock to prevent concurrent calls on the object. If you are isolating sessions, creating your own repository works best. Infinispan's Cache implements the ConcurrentHashMap, so you could use the ID of the session as the key and KnowledgeSession as the value.