Is there a way to trigger batch consumer at a specific time in MassTransit?

81 views
Skip to first unread message

Namik Baris Idil

unread,
Mar 10, 2021, 3:43:31 AM3/10/21
to masstransit-discuss

Hello,

I created a batch consumer which responsible for deleting some data. I know that we can configure this batch consumer to use a time limit and message limit. What I am trying to do is to configure this batch consumer to start consuming message at a specific time (like at 03:00 AM every two days for example). Is there any way to do this?

Thanks in advance.

Eric Piraux

unread,
Mar 10, 2021, 4:26:27 AM3/10/21
to masstrans...@googlegroups.com
You can use https://masstransit-project.com/advanced/scheduling/ to send a command at scheduled time in order to trigger the batch consumer


--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/8ab2a0b7-a614-4985-a767-4b699f637dbfn%40googlegroups.com.

Namik Baris Idil

unread,
Mar 10, 2021, 5:09:32 AM3/10/21
to masstrans...@googlegroups.com
Hey Eric,

Thanks for the reply. I thought the same thing but how can I trigger a batch consumer externally?

Thanks.


Eric Piraux

unread,
Mar 10, 2021, 5:34:09 AM3/10/21
to masstrans...@googlegroups.com


The batch consumer will fire when there are messages to consume, isn'it ? Therefore triggering the process consists to trigger the production of messages that are going to be consumed by the batch consumer. 


Namik Baris Idil

unread,
Mar 10, 2021, 5:47:00 AM3/10/21
to masstrans...@googlegroups.com
I am not sure I am following. Batch consumer will not be triggered until specific conditions met (time or message limit). For example, if my message limit is 200 and the queue already has 175 messages, it will not trigger and consume the messages, right? What I want is to consume messages at a specific time. I think subject is misleading, I do not want to trigger the batch consumer to start (which is already done by the messages themselves), I want to trigger the batch consumer to get all the related messages at a specific time. Am I missing something here?

Eric Piraux

unread,
Mar 10, 2021, 5:57:43 AM3/10/21
to masstrans...@googlegroups.com

maybe put the batch consumer in a specific instance that is scheduled to start on time ?


Namik Baris Idil

unread,
Mar 10, 2021, 6:33:45 AM3/10/21
to masstrans...@googlegroups.com
Could work but it is an overkill for such an ordinary task, right? Do you know if we can have a custom implementation of batch consumer, using consumer factories?


Eric Piraux

unread,
Mar 10, 2021, 6:35:27 AM3/10/21
to masstrans...@googlegroups.com

Namik Baris Idil

unread,
Mar 10, 2021, 6:36:47 AM3/10/21
to masstrans...@googlegroups.com
Ok, thanks for the help, Eric!

On 10. Mar 2021, at 11:57, Eric Piraux <epi...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages