java - Spring AMQP take action on message timeout -
i using spring amqp asynchronous messaging. model assumes there 2 applications , b, both producers , consumers.
- a sends job request b , starts listening.
- b listening job request, , when comes, starts job , periodically sends progress messages a.
- b sends job finish message after job finished.
- a consumes progress messages until job finish message comes, exists.
i using @rabbitlistener on class level , @rabbithandler on method level, message consuming. works nice , design clean, spring's solution.
my problem - have no idea how detect, , how act, when expecting receive progress message b (any message) , it's not coming in. there timeout such cases? if so, how implement callback method?
i found timeout settings, works connection itself, or when using rpc pattern (one request 1 response).
desired solution - should receive progress message every minute. if no progress message consumed for, say, 3 minutes, want cancel job.
when using async consumers, there's no mechanism generate event if message not received within time period.
you can schedule own task though , cancel/reschedule task when message arrives.
use taskscheduler
future = schedule(myrunnable, new date(system.currenttimemillis() + 180000));
use future.cancel() when message arrives.
Comments
Post a Comment