snmp4j commandresponder as ItemReader for springBatch job - spring

I wanted to have spring batch for alarm received through commandResponder ( processPDU) implements as ItemReader for my springbatch job. I am new to spring , Can someone pls guide me.

The aim of spring-batch is to make a bulk processing. In your case you can have an alarm at any time so the batch should be running and the reader should sleep until receiving a new alarm. So I don't think that Spring-batch is suitable for your case.
You can process the alarms asynchronously through a broker or using #Asynch annotation.

Related

Asynchronous Kafka consumer in Spring Batch Application

In our Spring Batch application workers, item processors are further interacting with another service asynchronously through Kafka. The requirement here is we required an acknowledgement in order to retry failed batches and the condition is to not wait for the acknowledgement.
Is there any mechanism in spring batch by which we can asynchronously consume Kafka ?
Is it possible to rerun specific local worker step in rerun of job?
We implement producers and consumers over same step using Spring batch decider. Thus, during the first run it will only produce Kafka and on second run it will consume the Kafka.
We are looking for solution where we can asynchronously consume Kafka in Spring batch application in order to rerun specific worker step.
Is there any mechanism in spring batch by which we can asynchronously consume Kafka ? Is it possible to rerun specific local worker step in rerun of job?
According to your diagram, you are doing that call from an item processor. The closest "feature" you can get from Spring Batch is the AsyncItemProcessor. This is a special processor that processes items asynchronously in a separate thread. The callback is unwrapped in an AsyncItemWriter with the result of the call.
Other than that, I do not see any other obvious way to do that with a built-in feature from Spring Batch. So you would have to manage that in a custom ItemProcessor.

Spring boot job scheduler start and stop

I am new to spring boot scheduler. I want to schedule multiple jobs to start and stop based on user requirements. The start and stop have to be exposed as a restful service. Is there a way to achieve this using a spring scheduler where I can start a job when the user requests it and stop it when a stop is requested?
If you need to trigger method as new thread annotate with #Async.
If need trigger job based on user trigger and stop based on user trigger spring batch good option if its allowed
running spring batch job
jobLauncher.run(job, jobParameter);
stop running job.
jobexplorer.stop(jobExecution.getId);

Implement runnable to serve a new request in springboot

I have a usecase in a spring boot application, where in we get a request, we send an acknowledgement back and then start a new executor task in background which will do some processing and send back some result.
Now I am having some doubts while creating the runnable task. I want for every request a new instance of this runnable task is submitted to the executor service.
Could some clarify if keeping the scope as "prototype" should resolve my purpose or the scope should be "request". And if the latter is correct, is the default context in spring boot is web-aware?
Also I need to pass in some parameters in the runnable task. Any pointers would be appreciated for both the above problems.
TA
Spring can manage threads for you using the #Async annotation. This can be much simpler than managing them yourself if you are already using Spring.
You can read about it here: https://www.baeldung.com/spring-async

Spring scheduled task with jms

I'm just starting out with Spring (specifically I'm staring with Spring Boot) and want to create long running program that works on a scheduled task (i.e. #Scheduled), e.g. start processing between 7pm and 11pm. I'm ok with this bit.
The task will take a message from an ActiveMQ queue and process it, sleep a little, then get another and repeat.
Being new to JMS/ActiveMQ also, is it possible to use the Spring #JmsListener in conjunction with the scheduler to achieve this, and if so how?
If not, I take it my scheduled task should simply use point to point access to the queue to pull messages off. If so, does anyone have a simple example as I prefer to use Spring boot but can't find any good examples, they all seem to use listeners.
thanks.

Spring #scheduler vs. Quartz Scheduler which one is best

I got in to a task where we have to publish Metadata of one table to another application via REST web services.
Basically need is
It has to be weekly scheduler and every week we push the data to
them.
Synchronous way.
Job scheduler will kick up the job and call REST client.
I am thinking using spring batch scheduler as it is simple and not with Quartz scheduler. Let me know you view and perspectives.

Resources