writing ATDDs for batch job - java

I am trying to write ATDDs for a batch job. The job has the following scenario:
It checks the DB and if some event has been recorded 7 days back, it will pick up that event and reprocess. Here, 7 days is the pre-requirement to process it. While reprocessing, the system will interact with multiple services.
So, here I have to create this scenario through my ATDDs and want to verify if the job ran successfully.Means my ATDDs have to create specific data with the creation date as 1 week older.
I have enough experience with ATDDs with Cucumber+Java so want to work on same. Could someone give some idea whether it could be achieved?

Related

AWS and Quartz for running scheduled tasks

Grettings everyone,
We are using AWS as PaaS and we have a couple of microservices deployed there. We got some new requirements to use some sort of cron jobs and schedulers.
For example we have the following scenarios:
A user can set some rules when an event must happen. For example he wants to remove some oudated documents every Friday or once a week or every 2 days
A user can configure creating copies of some objects every day till date A
I used to use Quartz before and it is the first idea that comes in my mind. I think that we can use it in AWS, cause it has RDS(with PostgreSQL for instance).
But I would like to know what sort of other options can I use instead of Quartz(http://www.quartz-scheduler.org) + RDS? May be AWS has something out of the box that can do the same?
What do you think about http://docs.aws.amazon.com/batch/latest/userguide/what-is-batch.html in my case?
Thank you for your time and advice :)
Recently(10-Nov-2022) AWS launched a new service called EventBridge Scheduler and I've already added a detailed answer here, please have a look. So you don't need to handle anything manually Because EventBridge Scheduler is serverless.

File location listener in Java - Spring application

I have a Java - Spring application. I want to set up a feature to listen a file location(Folder) and has to process a file as a file get created in this folder.
My plan is to set up a spring quartz cron job which will run in every five minutes and process the files available.
Please suggest me a better approach.
A choice of solution depends on how quickly an appearance of a waited file must be detected.
If it is not urgently and at least 1 minutes would be OK, then your solution using any kind of cron job would be OK too.
If a file should be detected asap, then you must provide a permanent running program, that detects a file in very short intervals. This can be reached by for this task dedicated daemon. If your program has nothing to do during wait time, then it can contain part for the file detection.
If you have moved on to/are on java8, it provides Watch Service API that allows us to monitor file and folder locations.
Have a look at Watch Service API

Detecting mysql table lock from java

I have a web application based on Java EE and MYSQL.
The problem which I am facing right now is, there is an event getting fired online, which is updating a table entry for a large number of rows.
There is also a batch job scheduled in the environment, say for every 6 minutes, which is also updating the same table entry, as mentioned above.
So the situation is that, when the online event is getting fired in the time range of the batch run, the table is getting locked.
So, experts please provide your ideas, on how to prevent the lock to take place.
Looks like a design issue,take a look at using temporary tables.

How to run program that sends bills to customers once a month?

I have a table in database with users and their expenses for traveling. I am using GWT and want to run a code once a month, that would query the database and send bills as PDFs to customers. I know how to create PDFs and send emails from servlet.
How to run a program in java (or some other script if it isn't possible with java) that would run once a month?
Tnx
Unix and derivatives: use cron -> http://en.wikipedia.org/wiki/Cron
Windows: use task scheduler -> http://support.microsoft.com/kb/308569
If you want to get fancy and do it purely in java: -> http://www.quartz-scheduler.org/, but do consider OS scheduler first.
you have many choices.
If you are under Unix, the simpliest solution is a batch scheduled with a crontab.
If you prefer a 100% java solution, the Quartz framework is a robust a easy to setup solution.
To avoid "re-inventing the wheel" I suggest using http://www.freshbooks.com/ and tying your app into their API to send your bills. You can easily set up recurrence as a billing option so that the bills get re-sent (along with reminders) each month. The user can then grab the PDF version of their bill.

schedule java program

I want to run my java program in regular interval , lets say, in every 3 hours. I am thinking to write a .bat file and put command to call java class. But what is the best way to run .bat regularly in windows xp. Thanks in advance. I dont want to use third party tool.
Windows scheduled tasks are built for exactly that purpose.
You can run things on multiple schedules (so you can get your every-three-hour behaviour) and you can get your code to run whether or not logged in.
The multiple scheduling is a bit tricky. You basically set it up as a daily task to start with but, near the end, it will ask you if you want to do advanced features.
Select yes then you can set up multiple schedules at that point.
If you want a pure Java Based solution you can try QUARTZ SCHEDULER. But as paxdiablo already mentioned, Windows Task Scheduler will do that as well.

Categories