Interface Middleware
-
- All Known Subinterfaces:
ContextMiddleware
,LockMiddleware
,PermissionMiddleware
,RateLimiterMiddleware
,TimeProviderMiddleware
- All Known Implementing Classes:
HandlerMiddleware
,LoggingMiddleware
,ProfilerMiddleware
,RedisLockMiddleware
public interface Middleware
Middlewares are used in a chain, at the end of chain listener method is called.Each middleware is called in the order they have been added to Container/ContainerFactory
Any middleware can skip the next middleware call, skipping next middleware call means no further processing of this job, in such case this middleware must either release(put back) or delete this job using one of the methods
Job.release(JobStatus, Serializable)
,Job.release(JobStatus, Serializable, Duration)
Job.delete(JobStatus, Serializable)
.For example three middlewares [m1,m2,m3] are registered than m1 would be called first followed by m2, m3 and message handler
HandlerMiddleware
. Middleware m1 can either call m2 or skip it, skipping call of m2 means this job will not be processed by either m2 or m3 and this job must be either released or deleted. If m2 is called from m1 than m2 can either call m3 or skip it, if m2 is skipping m3 call than it must either release or delete this job. If m3 is called than m3 can either call the next middleware or skip it, the next middleware for m3 would theHandlerMiddleware
that would call the listener method, again if m3 is skipping handler call than it should either release or delete this job.NOTE: Middlewares only called when preprocessor returns true.
It's recommended to use either preprocessor
SimpleRqueueListenerContainerFactory.setPreExecutionMessageProcessor(MessageProcessor)
or middlewares featureSimpleRqueueListenerContainerFactory.setMiddlewares(List)
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
handle(Job job, java.util.concurrent.Callable<java.lang.Void> next)
Middleware handles that would be called
-
-
-
Method Detail
-
handle
void handle(Job job, java.util.concurrent.Callable<java.lang.Void> next) throws java.lang.Exception
Middleware handles that would be called- Parameters:
job
- job objectnext
- next middleware in chain- Throws:
java.lang.Exception
- any exception
-
-