rqueue icon indicating copy to clipboard operation
rqueue copied to clipboard

Best practice of initializing a queue (producer only)

Open stefan-g opened this issue 10 months ago • 1 comments

I have 2 different instances. One instance produces jobs and one consumes it. It does only work correct when i register the queue manually by the manager. Is that the way how it should be?

@log4j2
@service
public class RQueueMessageService {

private final RqueueMessageEnqueuer rqueueMessageEnqueuer;
private final RqueueEndpointManager manager;

public RQueueMessageService(final RqueueMessageEnqueuer rqueueMessageEnqueuer, final RqueueEndpointManager manager) {
this.rqueueMessageEnqueuer = rqueueMessageEnqueuer;
this.manager = manager;
this.manager.registerQueue("import-job");
}

public void createJOB(ImportMessage message) {
rqueueMessageEnqueuer.enqueueWithRetry("import-job", message,3);
}

}

stefan-g avatar Apr 16 '24 12:04 stefan-g

Hi @stefan-g Which version of Rqueue do you have?
In this doc, we've explained a different way to use it, https://sonus21.github.io/rqueue/producer-consumer

If you're using the same application code for producer and consumer in that case you don't have to call register queue method.

You can just rqueue.scheduler.enabled=false and rqueue.system.mode=PRODUCER in the producer application instance. In consumer you can let it be default behaviour.

A sample test app https://github.com/sonus21/rqueue/blob/a8cb236161eecb35f121544dc422e92c19ccc96e/rqueue-spring-boot-starter/src/test/java/com/github/sonus21/rqueue/spring/boot/tests/integration/ProducerOnlyTest.java#L53

sonus21 avatar May 07 '24 18:05 sonus21