Home > Back-end >  Multithreaded timing task how to implement
Multithreaded timing task how to implement

Time:09-24

Seat reservation recently doing, users need to temporarily leave, must leave within 1 hour after come back, the background is springboot how to implement such business scene,

CodePudding user response:

Task scheduling regularly:
QUARTZ framework include:
1. The Scheduler: the Scheduler, control all the scheduling
2. The Trigger, the Trigger condition
3. The JobDetail: to deal with the JOB of
4. Job: perform logical

CodePudding user response:

Put a eye, have the answer tell me

CodePudding user response:

1. The user clicks the left a delay task, new users never come back in 1 hour, release the seat

Or

2. The user clicks the left a delay queue messages sent, users never come back in 1 hour, natural release seats, user is back in an hour, undo queue messages or business processing

CodePudding user response:

ThreadPoolTaskScheduler

CodePudding user response:

refer to the second floor smelly boy handsome reply:
an eye, have the answer tell me down


Professional eye in 100

CodePudding user response:

refer to the second floor smelly boy handsome reply:
an eye, have the answer tell me down

With a dead-letter queue can be implemented

CodePudding user response:

refer to 6th floor weixin_39217544 response:
Quote: refer to the second floor of the smelly boy handsome reply:
an eye, have the answer tell me down

With a dead-letter queue can realize

Go into more detail about thinking

CodePudding user response:

refer to 7th floor smelly boy handsome reply:
Quote: refer to the sixth floor weixin_39217544 response:

Quote: refer to the second floor of the smelly boy handsome reply:
an eye, have the answer tell me down

With a dead-letter queue can realize

Go into more detail about ideas

The rabbitmq dead-letter queue, set the expiration time of queue, specified in the message to the specified time

CodePudding user response:

refer to the eighth floor weixin_39217544 response:
Quote: refer to 7th floor smelly boy handsome reply:
Quote: refer to the sixth floor weixin_39217544 response:

Quote: refer to the second floor of the smelly boy handsome reply:
an eye, have the answer tell me down

With a dead-letter queue can realize

Go into more detail about ideas

The rabbitmq dead-letter queue, set the expiration date of a queue, in the message to the designated time specified operating

So can also, due to execute the business logic

CodePudding user response:

references 9/f, smelly boy handsome reply:
Quote: refer to the eighth floor weixin_39217544 response:

Quote: refer to 7th floor smelly boy handsome reply:
Quote: refer to the sixth floor weixin_39217544 response:

Quote: refer to the second floor of the smelly boy handsome reply:
an eye, have the answer tell me down

With a dead-letter queue can realize

Go into more detail about ideas

The rabbitmq dead-letter queue, set the expiration date of a queue, in the message to the designated time specified operating

So can also, due to execute the business logic

是的

CodePudding user response:

If a lightweight implementation, can be as simple as follows:
 
Public static void main (String [] args) {
System. The out. Println (" leave, execute the following code ");
ScheduledExecutorService durationTimer=Executors. NewSingleThreadScheduledExecutor ();
DurationTimer. The schedule (new Runnable () {
@ Override
Public void the run () {
System. The out. Println (" after 3600 seconds, can trigger here, check people ever come back ");
}
}, 3600, TimeUnit. SECONDS);
}

  • Related