This project is a Spring Boot Starter for QStash. It provides a simple way to integrate QStash into your Spring Boot application. It supports Scheduled, Listener and Client.
- Spring Boot 3.0.0 or later
- Java 21 or later
- org.springframework.boot:spring-boot-starter-web for
@QStashListener
and@QStashScheduler
annotation
Add the following dependency to your pom.xml
:
<dependency>
<groupId>io.github.tdilber</groupId>
<artifactId>upstash-qstash-spring-boot-starter</artifactId>
<version>0.0.1</version>
</dependency>
Add the following properties to your application.yaml
:
spring:
qstash:
endpoint: https://qstash.upstash.io
apiKey: <your-qstash-api-key>
appEndpoint: <your-app-endpoint>
# <your-app-endpoint> => if prod environment then use prod endpoint
# IF u are using localhost then use tunnel like ngrok.
# for more info visit qstash docs How to section
Enable Annotation in your Spring Boot Application:
@EnableQStash
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
import com.beyt.upstash.model.SendProperties;
@Service
public class MyService {
@Autowired
private QStashClient qStashClient;
public void sendQueueMessage(String queueName, Object payload) {
qStashClient.enqueueMessage(QUEUE_NAME, payload, SendProperties.builder().build());
}
}
System automatically sync listeners when app started. When message comes then system automatically call the method.
When u send message like qStashClient.enqueueMessage("my-queue", payload, SendProperties.builder().build());
then system automatically call the method with payload.
import com.beyt.upstash.annotation.QStashListener;
public class MyListener {
/
@QStashListener(queueName = "my-queue")
public void onMessage(Object payload) {
// process the message
}
}
System automatically sync schedules when app started. When trigger schedule then system automatically call the method.
import com.beyt.upstash.annotation.QStashScheduler;
public class MyScheduler {
@QStashSchedule(scheduleName = SCHEDULE_NAME, cron = "* * * * *")
public void schedule() {
// process the message
}
}
Apache License 2.0
- Complete Client
- Create Listener system
- create QStashSchduler annotation (when app started then automatic sync schedules)
- create test
- listen and schedule method find operation make best practice
- Batch requests support
- dead letter queue listener support if exists
- Extend QStashClient for more operations
- REadme.md update