├── .circleci └── config.yml ├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug-report.md │ ├── feature_request.md │ └── i-m-using-rqueue.md ├── pull_request_template.md └── workflows │ └── pages.yaml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── build.gradle ├── copyright-template ├── create-redis-cluster.sh ├── docs ├── .ruby-version ├── 404.html ├── CHANGELOG.md ├── Gemfile ├── Gemfile.lock ├── _config.yml ├── _includes │ ├── footer_custom.html │ └── head_custom.html ├── callback-and-events.md ├── configuration │ ├── configuration.md │ ├── redis-configuration.md │ └── retry-and-backoff.md ├── dashboard.md ├── faq.md ├── index.md ├── message-handling │ ├── message-deduplication.md │ ├── message-handling.md │ ├── middleware.md │ ├── producer-consumer.md │ └── queue-priority.md ├── migrations.md ├── monitoring.md └── static │ ├── favicon │ ├── android-chrome-192x192.png │ ├── apple-touch-icon.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ └── favicon.ico │ ├── grafana-dashboard.png │ ├── jobs.png │ ├── logo.png │ ├── queue-explore.png │ ├── queues.png │ ├── rqueue-message-flow.jpg │ ├── rqueue-message-flow.svg │ ├── running-tasks.png │ ├── stats-graph.png │ └── users │ ├── airtel-africa.png │ ├── aviva.jpeg │ ├── bitbot.png │ ├── chaoti-info.png │ ├── line.png │ ├── mercedes.png │ ├── opentext.png │ ├── pokerstars.png │ ├── t-mobile.svg │ ├── tuneyou.png │ └── vonage.png ├── gradle.properties ├── gradle ├── code-signing.gradle ├── packaging.gradle ├── test-runner.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lombok.config ├── publish.sh ├── rqueue-core ├── build.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── sonus21 │ │ │ └── rqueue │ │ │ ├── annotation │ │ │ ├── MessageListener.java │ │ │ ├── RqueueHandler.java │ │ │ └── RqueueListener.java │ │ │ ├── common │ │ │ ├── ReactiveRqueueRedisTemplate.java │ │ │ ├── RqueueLockManager.java │ │ │ ├── RqueueRedisTemplate.java │ │ │ └── impl │ │ │ │ └── RqueueLockManagerImpl.java │ │ │ ├── config │ │ │ ├── MetricsProperties.java │ │ │ ├── RqueueConfig.java │ │ │ ├── RqueueListenerBaseConfig.java │ │ │ ├── RqueueSchedulerConfig.java │ │ │ ├── RqueueWebConfig.java │ │ │ └── SimpleRqueueListenerContainerFactory.java │ │ │ ├── converter │ │ │ ├── DefaultMessageConverterProvider.java │ │ │ ├── GenericMessageConverter.java │ │ │ ├── JsonMessageConverter.java │ │ │ ├── MessageConverterProvider.java │ │ │ └── RqueueRedisSerializer.java │ │ │ ├── core │ │ │ ├── DefaultRqueueMessageConverter.java │ │ │ ├── EndpointRegistry.java │ │ │ ├── Job.java │ │ │ ├── MessageScheduler.java │ │ │ ├── ProcessingQueueMessageScheduler.java │ │ │ ├── ReactiveRqueueMessageEnqueuer.java │ │ │ ├── RedisScheduleTriggerHandler.java │ │ │ ├── RedisScriptFactory.java │ │ │ ├── RqueueBeanProvider.java │ │ │ ├── RqueueEndpointManager.java │ │ │ ├── RqueueInternalPubSubChannel.java │ │ │ ├── RqueueMessage.java │ │ │ ├── RqueueMessageEnqueuer.java │ │ │ ├── RqueueMessageManager.java │ │ │ ├── RqueueMessageTemplate.java │ │ │ ├── RqueueRedisListenerContainerFactory.java │ │ │ ├── ScheduledQueueMessageScheduler.java │ │ │ ├── context │ │ │ │ ├── Context.java │ │ │ │ └── DefaultContext.java │ │ │ ├── impl │ │ │ │ ├── BaseMessageSender.java │ │ │ │ ├── MessageSweeper.java │ │ │ │ ├── ReactiveRqueueMessageEnqueuerImpl.java │ │ │ │ ├── RqueueEndpointManagerImpl.java │ │ │ │ ├── RqueueMessageEnqueuerImpl.java │ │ │ │ ├── RqueueMessageManagerImpl.java │ │ │ │ └── RqueueMessageTemplateImpl.java │ │ │ ├── middleware │ │ │ │ ├── ContextMiddleware.java │ │ │ │ ├── HandlerMiddleware.java │ │ │ │ ├── LockMiddleware.java │ │ │ │ ├── LoggingMiddleware.java │ │ │ │ ├── Middleware.java │ │ │ │ ├── PermissionMiddleware.java │ │ │ │ ├── ProfilerMiddleware.java │ │ │ │ ├── RateLimiterMiddleware.java │ │ │ │ ├── RedisLockMiddleware.java │ │ │ │ └── TimeProviderMiddleware.java │ │ │ └── support │ │ │ │ ├── MessageProcessor.java │ │ │ │ └── RqueueMessageUtils.java │ │ │ ├── dao │ │ │ ├── RqueueJobDao.java │ │ │ ├── RqueueMessageMetadataDao.java │ │ │ ├── RqueueQStatsDao.java │ │ │ ├── RqueueStringDao.java │ │ │ ├── RqueueSystemConfigDao.java │ │ │ └── impl │ │ │ │ ├── RqueueJobDaoImpl.java │ │ │ │ ├── RqueueMessageMetadataDaoImpl.java │ │ │ │ ├── RqueueQStatsDaoImpl.java │ │ │ │ ├── RqueueStringDaoImpl.java │ │ │ │ └── RqueueSystemConfigDaoImpl.java │ │ │ ├── exception │ │ │ ├── LockCanNotBeAcquired.java │ │ │ ├── OverrideException.java │ │ │ ├── ProcessingException.java │ │ │ ├── QueueDoesNotExist.java │ │ │ ├── TimedOutException.java │ │ │ └── UnknownSwitchCase.java │ │ │ ├── listener │ │ │ ├── DefaultRqueuePoller.java │ │ │ ├── JobImpl.java │ │ │ ├── MappingInformation.java │ │ │ ├── MessageContainerBase.java │ │ │ ├── MessageProcessorHandler.java │ │ │ ├── PostProcessingHandler.java │ │ │ ├── QueueDetail.java │ │ │ ├── RqueueExecutor.java │ │ │ ├── RqueueMessageHandler.java │ │ │ ├── RqueueMessageHeaders.java │ │ │ ├── RqueueMessageListenerContainer.java │ │ │ ├── RqueueMessagePoller.java │ │ │ ├── StrictPriorityPoller.java │ │ │ └── WeightedPriorityPoller.java │ │ │ ├── metrics │ │ │ ├── QueueCounter.java │ │ │ ├── RqueueCounter.java │ │ │ ├── RqueueMetrics.java │ │ │ ├── RqueueMetricsCounter.java │ │ │ ├── RqueueMetricsRegistry.java │ │ │ └── RqueueQueueMetrics.java │ │ │ ├── models │ │ │ ├── Concurrency.java │ │ │ ├── MessageMoveResult.java │ │ │ ├── MinMax.java │ │ │ ├── Pair.java │ │ │ ├── PubSubMessage.java │ │ │ ├── SerializableBase.java │ │ │ ├── aggregator │ │ │ │ ├── QueueEvents.java │ │ │ │ └── TasksStat.java │ │ │ ├── db │ │ │ │ ├── CheckinMessage.java │ │ │ │ ├── DeadLetterQueue.java │ │ │ │ ├── Execution.java │ │ │ │ ├── JobRunTime.java │ │ │ │ ├── MessageMetadata.java │ │ │ │ ├── QueueConfig.java │ │ │ │ ├── QueueStatistics.java │ │ │ │ └── RqueueJob.java │ │ │ ├── enums │ │ │ │ ├── ActionType.java │ │ │ │ ├── AggregationType.java │ │ │ │ ├── ChartDataType.java │ │ │ │ ├── ChartType.java │ │ │ │ ├── DataType.java │ │ │ │ ├── ExecutionStatus.java │ │ │ │ ├── JobStatus.java │ │ │ │ ├── MessageStatus.java │ │ │ │ ├── NavTab.java │ │ │ │ ├── PriorityMode.java │ │ │ │ ├── PubSubType.java │ │ │ │ ├── RqueueMode.java │ │ │ │ └── TableColumnType.java │ │ │ ├── event │ │ │ │ ├── RqueueBootstrapEvent.java │ │ │ │ ├── RqueueExecutionEvent.java │ │ │ │ ├── RqueuePubSubEvent.java │ │ │ │ └── RqueueQueuePauseEvent.java │ │ │ ├── request │ │ │ │ ├── ChartDataRequest.java │ │ │ │ ├── DataDeleteRequest.java │ │ │ │ ├── DataTypeRequest.java │ │ │ │ ├── DateViewRequest.java │ │ │ │ ├── MessageDeleteRequest.java │ │ │ │ ├── MessageMoveRequest.java │ │ │ │ ├── PauseUnpauseQueueRequest.java │ │ │ │ └── QueueExploreRequest.java │ │ │ └── response │ │ │ │ ├── Action.java │ │ │ │ ├── BaseResponse.java │ │ │ │ ├── BooleanResponse.java │ │ │ │ ├── ChartDataResponse.java │ │ │ │ ├── DataSelectorResponse.java │ │ │ │ ├── DataViewResponse.java │ │ │ │ ├── MessageMoveResponse.java │ │ │ │ ├── RedisDataDetail.java │ │ │ │ ├── RowColumnMeta.java │ │ │ │ ├── RowColumnMetaType.java │ │ │ │ ├── StringResponse.java │ │ │ │ ├── Table.java │ │ │ │ ├── TableColumn.java │ │ │ │ └── TableRow.java │ │ │ ├── utils │ │ │ ├── Constants.java │ │ │ ├── DateTimeUtils.java │ │ │ ├── ExceptionUtils.java │ │ │ ├── HttpUtils.java │ │ │ ├── PrefixLogger.java │ │ │ ├── PriorityUtils.java │ │ │ ├── QueueThreadPool.java │ │ │ ├── RedisUtils.java │ │ │ ├── RetryableRunnable.java │ │ │ ├── SerializationUtils.java │ │ │ ├── StackTraceUtil.java │ │ │ ├── StringUtils.java │ │ │ ├── ThreadUtils.java │ │ │ ├── TimeoutUtils.java │ │ │ ├── Validator.java │ │ │ ├── ValueResolver.java │ │ │ ├── backoff │ │ │ │ ├── ExponentialTaskExecutionBackOff.java │ │ │ │ ├── FixedTaskExecutionBackOff.java │ │ │ │ └── TaskExecutionBackOff.java │ │ │ ├── condition │ │ │ │ ├── ReactiveDisabled.java │ │ │ │ ├── ReactiveEnabled.java │ │ │ │ └── RqueueEnabled.java │ │ │ └── pebble │ │ │ │ ├── DateTimeFunction.java │ │ │ │ ├── DeadLetterQueuesFunction.java │ │ │ │ ├── DefaultFunction.java │ │ │ │ ├── ResourceLoader.java │ │ │ │ └── RqueuePebbleExtension.java │ │ │ └── web │ │ │ ├── controller │ │ │ ├── BaseController.java │ │ │ ├── BaseReactiveController.java │ │ │ ├── ReactiveRqueueRestController.java │ │ │ ├── ReactiveRqueueViewController.java │ │ │ ├── RqueueRestController.java │ │ │ └── RqueueViewController.java │ │ │ └── service │ │ │ ├── RqueueDashboardChartService.java │ │ │ ├── RqueueJobMetricsAggregatorService.java │ │ │ ├── RqueueJobService.java │ │ │ ├── RqueueMessageMetadataService.java │ │ │ ├── RqueueQDetailService.java │ │ │ ├── RqueueSystemManagerService.java │ │ │ ├── RqueueUtilityService.java │ │ │ ├── RqueueViewControllerService.java │ │ │ └── impl │ │ │ ├── RqueueDashboardChartServiceImpl.java │ │ │ ├── RqueueJobServiceImpl.java │ │ │ ├── RqueueMessageMetadataServiceImpl.java │ │ │ ├── RqueueQDetailServiceImpl.java │ │ │ ├── RqueueSystemManagerServiceImpl.java │ │ │ ├── RqueueUtilityServiceImpl.java │ │ │ └── RqueueViewControllerServiceImpl.java │ └── resources │ │ ├── META-INF │ │ └── spring-configuration-metadata.json │ │ ├── public │ │ └── rqueue │ │ │ ├── css │ │ │ └── rqueue.css │ │ │ ├── img │ │ │ ├── android-chrome-192x192.png │ │ │ ├── apple-touch-icon.png │ │ │ ├── favicon-16x16.png │ │ │ ├── favicon-32x32.png │ │ │ └── favicon.ico │ │ │ ├── js │ │ │ └── rqueue.js │ │ │ └── vendor │ │ │ ├── bootstrap │ │ │ ├── css │ │ │ │ ├── bootstrap-grid.css │ │ │ │ ├── bootstrap-grid.css.map │ │ │ │ ├── bootstrap-grid.min.css │ │ │ │ ├── bootstrap-grid.min.css.map │ │ │ │ ├── bootstrap-reboot.css │ │ │ │ ├── bootstrap-reboot.css.map │ │ │ │ ├── bootstrap-reboot.min.css │ │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ │ ├── bootstrap.css │ │ │ │ ├── bootstrap.css.map │ │ │ │ ├── bootstrap.min.css │ │ │ │ └── bootstrap.min.css.map │ │ │ └── js │ │ │ │ ├── bootstrap.bundle.js │ │ │ │ ├── bootstrap.bundle.js.map │ │ │ │ ├── bootstrap.bundle.min.js │ │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ │ ├── bootstrap.js │ │ │ │ ├── bootstrap.js.map │ │ │ │ ├── bootstrap.min.js │ │ │ │ └── bootstrap.min.js.map │ │ │ ├── boxicons │ │ │ ├── css │ │ │ │ ├── animations.css │ │ │ │ ├── boxicons.css │ │ │ │ ├── boxicons.min.css │ │ │ │ └── transformations.css │ │ │ └── fonts │ │ │ │ ├── boxicons.eot │ │ │ │ ├── boxicons.svg │ │ │ │ ├── boxicons.ttf │ │ │ │ ├── boxicons.woff │ │ │ │ └── boxicons.woff2 │ │ │ └── jquery │ │ │ ├── jquery.min.js │ │ │ └── jquery.min.map │ │ ├── rqueue │ │ └── scripts │ │ │ ├── delete_if_same.lua │ │ │ ├── dequeue_message.lua │ │ │ ├── enqueue_message.lua │ │ │ ├── move_expired_message.lua │ │ │ ├── move_message_list.lua │ │ │ ├── move_message_list_to_list.lua │ │ │ ├── move_message_list_to_zset.lua │ │ │ ├── move_message_zset.lua │ │ │ ├── move_message_zset_to_list.lua │ │ │ ├── move_message_zset_to_zset.lua │ │ │ ├── schedule_message.lua │ │ │ └── score_updater.lua │ │ └── templates │ │ └── rqueue │ │ ├── base.html │ │ ├── data_explorer_modal.html │ │ ├── index.html │ │ ├── latency_chart.html │ │ ├── queue_detail.html │ │ ├── queues.html │ │ ├── running.html │ │ ├── stats_chart.html │ │ └── utility.html │ └── test │ └── java │ └── com │ └── github │ └── sonus21 │ └── rqueue │ ├── CoreUnitTest.java │ ├── common │ └── RqueueLockManagerImplTest.java │ ├── config │ ├── RqueueConfigTest.java │ ├── RqueueListenerBaseConfigTest.java │ └── SimpleRqueueListenerContainerFactoryTest.java │ ├── converter │ ├── GenericMessageConverterTest.java │ └── JsonMessageConverterTest.java │ ├── core │ ├── MessageSchedulerDisabledTest.java │ ├── MessageSchedulerTest.java │ ├── MessageSchedulingTest.java │ ├── ProcessingQueueMessageSchedulerTest.java │ ├── RedisAndNormalSchedulingTest.java │ ├── RedisScheduleTriggerHandlerTest.java │ ├── RedisScriptFactoryTest.java │ ├── RqueueEndpointManagerTest.java │ ├── RqueueMessageEnqueuerTest.java │ ├── RqueueMessageTemplateTest.java │ ├── RqueueMessageTest.java │ ├── ScheduledQueueMessageSchedulerTest.java │ ├── context │ │ └── DefaultContextTest.java │ ├── impl │ │ ├── RqueueEndpointManagerImplTest.java │ │ ├── RqueueMessageEnqueuerImplTest.java │ │ └── RqueueMessageManagerImplTest.java │ ├── middleware │ │ ├── ContextMiddlewareTest.java │ │ ├── LockMiddlewareTest.java │ │ ├── LoggingMiddlewareTest.java │ │ └── RedisLockMiddlewareTest.java │ └── support │ │ └── RqueueMessageUtilsTest.java │ ├── dao │ ├── RqueueQStatsDaoTest.java │ └── RqueueSystemConfigDaoTest.java │ ├── listener │ ├── ConcurrentListenerTest.java │ ├── JobImplTest.java │ ├── MappingInformationTest.java │ ├── PriorityGroupListenerTest.java │ ├── QueueDetailTest.java │ ├── RqueueExecutorTest.java │ ├── RqueueMessageHandlerTest.java │ ├── RqueueMessageListenerContainerTest.java │ ├── RqueueMessagePollerTest.java │ └── RqueueMiddlewareTest.java │ ├── metrics │ ├── MetricsPropertiesTest.java │ ├── QueueCounterTest.java │ ├── RqueueCounterTest.java │ ├── RqueueMetricsTest.java │ └── RqueueQueueMetricsTest.java │ ├── models │ ├── db │ │ ├── QueueConfigTest.java │ │ └── QueueStatisticsTest.java │ └── request │ │ ├── ChartDataRequestTest.java │ │ └── MessageMoveRequestTest.java │ ├── utils │ ├── DateTimeUtilsTest.java │ ├── HttpUtilsTest.java │ ├── MessageMetadataTestUtils.java │ ├── RqueueMessageTestUtils.java │ ├── StringUtilsTest.java │ ├── TestUtils.java │ ├── ValidatorTest.java │ └── backoff │ │ ├── ExponentialTaskExecutionBackOffTest.java │ │ └── FixedTaskExecutionBackOffTest.java │ └── web │ ├── service │ ├── RqueueDashboardChartServiceTest.java │ ├── RqueueMessageMetadataServiceTest.java │ ├── RqueueQDetailServiceTest.java │ ├── RqueueSystemManagerServiceTest.java │ ├── RqueueTaskMetricsAggregatorServiceTest.java │ ├── RqueueUtilityServiceTest.java │ └── impl │ │ └── RqueueSystemManagerServiceImplTest.java │ └── view │ └── DateTimeFunctionTest.java ├── rqueue-spring-boot-example ├── Dockerfile ├── JMeter.jmx ├── README.md ├── build.gradle ├── docker-compose.yml ├── grafana.json ├── prometheus.yml └── src │ └── main │ ├── java │ └── com │ │ └── github │ │ └── sonus21 │ │ └── rqueue │ │ └── example │ │ ├── Controller.java │ │ ├── Job.java │ │ ├── MessageListener.java │ │ ├── MvcConfig.java │ │ └── RQueueApplication.java │ └── resources │ ├── application.properties │ └── logback.xml ├── rqueue-spring-boot-reactive-example ├── README.md ├── build.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── sonus21 │ │ │ └── task │ │ │ └── executor │ │ │ ├── Controller.java │ │ │ ├── Job.java │ │ │ ├── MessageListener.java │ │ │ ├── RqueueReactiveApplication.java │ │ │ └── WebFluxConfig.java │ └── resources │ │ ├── application.properties │ │ └── logback.xml │ └── test │ └── java │ └── com │ └── github │ └── sonus21 │ └── task │ └── executor │ └── RqueueReactiveTaskExecutorApplicationTests.java ├── rqueue-spring-boot-starter ├── build.gradle └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── github │ │ │ └── sonus21 │ │ │ └── rqueue │ │ │ └── spring │ │ │ └── boot │ │ │ ├── RqueueListenerAutoConfig.java │ │ │ ├── RqueueMetricsAutoConfig.java │ │ │ └── RqueueMetricsProperties.java │ └── resources │ │ └── META-INF │ │ └── spring │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ └── test │ └── java │ └── com │ └── github │ └── sonus21 │ └── rqueue │ └── spring │ └── boot │ ├── application │ ├── Application.java │ ├── ApplicationListenerDisabled.java │ ├── ApplicationWithCustomConfiguration.java │ ├── ApplicationWithCustomMessageConverter.java │ ├── ApplicationWithMessageProcessor.java │ ├── ApplicationWithRestart.java │ ├── ApplicationWithTaskExecutionBackoff.java │ ├── BootMetricApplication.java │ ├── MultiRedisSetupApplication.java │ ├── ProducerOnlyApplication.java │ └── RedisClusterApplication.java │ ├── reactive │ ├── ReactiveWebApplication.java │ └── WebFluxConfig.java │ └── tests │ ├── SpringBootIntegrationTest.java │ ├── SpringBootUnitTest.java │ ├── integration │ ├── ApplicationTest.java │ ├── BootDoNotRetrySingleAttemptTest.java │ ├── BootDoNotRetryTest.java │ ├── BootMetricsTest.java │ ├── BootProcessingChannelTest.java │ ├── BootRetryTest.java │ ├── BootScheduledChannelTest.java │ ├── CustomMessageConverterTest.java │ ├── JobCheckinTest.java │ ├── ListenerConcurrencyTest.java │ ├── MessageDeduplicationTest.java │ ├── MessageEnqueuerTest.java │ ├── MessageProcessorTest.java │ ├── MultiExecutionTests.java │ ├── MultiRedisSetup.java │ ├── PauseUnpauseTest.java │ ├── PeriodicMessageTest.java │ ├── ProducerOnlyTest.java │ ├── ReactiveRestApiTest.java │ ├── ReactiveWebDisabledTest.java │ ├── ReactiveWebViewTest.java │ ├── RedisClusterTest.java │ ├── RqueueMessageManagerTest.java │ └── RqueueMessageTemplateTest.java │ └── unit │ ├── RqueueListenerAutoConfigTest.java │ └── RqueueMetricsAutoConfigTest.java ├── rqueue-spring-common-test ├── build.gradle └── src │ └── main │ ├── java │ └── com │ │ └── github │ │ └── sonus21 │ │ └── rqueue │ │ └── test │ │ ├── DeleteMessageListener.java │ │ ├── MessageListener.java │ │ ├── PauseUnpauseEventListener.java │ │ ├── UserBannedMessageListener.java │ │ ├── application │ │ ├── ApplicationBasicConfiguration.java │ │ ├── ApplicationWithCustomMessageConverter.java │ │ ├── ApplicationWithMessageProcessor.java │ │ ├── ApplicationWithMiddleware.java │ │ ├── BaseApplication.java │ │ ├── BaseApplicationWithBackoff.java │ │ ├── MultiRedisSprigBaseApplication.java │ │ └── RedisClusterBaseApplication.java │ │ ├── common │ │ ├── SpringTestBase.java │ │ └── SpringWebTestBase.java │ │ ├── dto │ │ ├── BaseQueueMessage.java │ │ ├── ChatIndexing.java │ │ ├── Email.java │ │ ├── FeedGeneration.java │ │ ├── Job.java │ │ ├── LongRunningJob.java │ │ ├── Notification.java │ │ ├── OrderConfirmation.java │ │ ├── PeriodicJob.java │ │ ├── Reservation.java │ │ ├── ReservationRequest.java │ │ ├── Sms.java │ │ └── UserBanned.java │ │ ├── entity │ │ ├── ConsumedMessage.java │ │ └── FailureDetail.java │ │ ├── repository │ │ ├── ConsumedMessageRepository.java │ │ └── FailureDetailRepository.java │ │ ├── service │ │ ├── ConsumedMessageStore.java │ │ ├── FailureManager.java │ │ ├── QueueRegistryUpdater.java │ │ └── RqueueEventListener.java │ │ ├── tests │ │ ├── AllQueueMode.java │ │ ├── BasicListenerTest.java │ │ ├── GroupPriorityTest.java │ │ ├── MessageChannelTests.java │ │ ├── MetricTest.java │ │ ├── MultiLevelQueueTest.java │ │ └── RetryTests.java │ │ └── util │ │ ├── TestMessageConverterProvider.java │ │ └── TestMessageProcessor.java │ └── resources │ └── application.properties ├── rqueue-spring-example ├── README.md ├── build.gradle └── src │ └── main │ └── java │ └── rqueue │ └── spring │ └── example │ ├── AppConfig.java │ ├── AppInitializer.java │ ├── Controller.java │ ├── Job.java │ ├── Main.java │ ├── MessageListener.java │ └── MvcConfig.java ├── rqueue-spring ├── build.gradle └── src │ ├── main │ └── java │ │ └── com │ │ └── github │ │ └── sonus21 │ │ └── rqueue │ │ └── spring │ │ ├── EnableRqueue.java │ │ ├── MetricsEnabled.java │ │ ├── RqueueListenerConfig.java │ │ └── RqueueMetricsProperties.java │ └── test │ └── java │ └── com │ └── github │ └── sonus21 │ └── rqueue │ └── spring │ ├── app │ └── SpringApp.java │ ├── services │ ├── ConsumedMessageRepositoryImpl.java │ └── FailureDetailRepositoryImpl.java │ └── tests │ ├── SpringIntegrationTest.java │ ├── SpringUnitTest.java │ ├── integration │ ├── DefaultListenerGroup.java │ ├── RqueueRestControllerTest.java │ ├── RqueueViewControllerTest.java │ ├── RqueueWebDisabledTest.java │ ├── SpringAppTest.java │ ├── SpringMetricTest.java │ ├── StrictHeterogeneousConcurrencyBasedQueueListener.java │ ├── StrictHeterogeneousQueueListener.java │ ├── StrictMultiLevelQueueListener.java │ ├── StrictPriorityQueueListenerTest.java │ ├── WeightedHeterogeneousConcurrencyBasedQueueListener.java │ ├── WeightedHeterogeneousQueueListener.java │ ├── WeightedMultiLevelQueueListener.java │ └── WeightedPriorityQueueListener.java │ └── unit │ └── RqueueMessageConfigTest.java ├── rqueue-test-util ├── build.gradle └── src │ └── main │ ├── java │ └── com │ │ └── github │ │ └── sonus21 │ │ ├── AtomicValueHolder.java │ │ ├── RandomUtils.java │ │ ├── RedisStarterTest.java │ │ ├── TestBase.java │ │ ├── junit │ │ ├── BootstrapRedis.java │ │ ├── LocalTest.java │ │ ├── RedisAvailable.java │ │ ├── RedisAvailableCondition.java │ │ ├── RedisBootstrapper.java │ │ ├── RedisBootstrapperBase.java │ │ ├── RedisRunning.java │ │ ├── TestQueue.java │ │ ├── TestRunner.java │ │ ├── TestStatLoggerExtension.java │ │ └── TestTracerExtension.java │ │ └── test │ │ ├── ControllerProfiler.java │ │ ├── LoggerInterceptor.java │ │ ├── TestTaskExecutor.java │ │ └── TestTaskScheduler.java │ └── resources │ └── logback.xml ├── settings.gradle └── test.sh /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: sonus21 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: What's not working? 4 | title: '' 5 | labels: '' 6 | assignees: sonus21 7 | 8 | --- 9 | 10 | 13 | 14 | **What's not working?** 15 | 16 | A clear and concise description of what the bug is. 17 | 18 | **What're application dependencies ?** 19 | 20 | - Rqueue Version: 21 | - Spring Boot Version: 22 | - Spring Messaging Version 23 | - Spring Data Redis Version 24 | - Any other spring library dependencies and their version 25 | 26 | **How to Reproduce (optional)?** 27 | 28 | * Steps to reproduce the behaviour 29 | * A sample reproducible code if possible. 30 | 31 | **Additional Details (optional)** 32 | 33 | Add any other context about the problem that would be helpful like OS, Redis, Docker etc 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: Suggest an idea for this project 5 | labels: '' 6 | assignees: sonus21 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/i-m-using-rqueue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: I'm using Rqueue 3 | about: 'Add my organisation in Rqueue Users ' 4 | title: Add my organisation in Rqueue user list 5 | labels: rqueue-user 6 | assignees: sonus21 7 | 8 | --- 9 | 10 | # Organisation Name 11 | 12 | # Organisation link 13 | 14 | # How many messages does Rqueue process daily? (optional) 15 | 16 | # How are you using Rqueue? (optional) 17 | 18 | # Testimonials (optionals) 19 | 20 | # Icon/Logo 21 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change. 4 | 5 | Fixes # (issue) 6 | 7 | ## Type of change 8 | 9 | Please delete options that are not relevant. 10 | 11 | - [ ] Bug fix (non-breaking change which fixes an issue) 12 | - [ ] New feature (non-breaking change which adds functionality) 13 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 14 | - [ ] This change requires a documentation update 15 | 16 | # How Has This Been Tested? 17 | 18 | Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration 19 | 20 | - [ ] Unit Test 21 | - [ ] Integration Test 22 | - [ ] Reactive Integration Test 23 | 24 | 25 | **Test Configuration**: 26 | * Spring Version 27 | * Spring Boot Version 28 | * Redis Driver Version 29 | 30 | 31 | # Checklist: 32 | 33 | - [ ] My code follows the style guidelines of this project 34 | - [ ] I have performed a self-review of my code 35 | - [ ] I have commented my code, particularly in hard-to-understand areas 36 | - [ ] I have made corresponding changes to the documentation 37 | - [ ] I have added tests that prove my fix is effective or that my feature works 38 | - [ ] New and existing unit tests pass locally with my changes 39 | 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Java template 3 | # Compiled class file 4 | *.class 5 | 6 | # Log file 7 | *.log 8 | 9 | # BlueJ files 10 | *.ctxt 11 | 12 | # Mobile Tools for Java (J2ME) 13 | .mtj.tmp/ 14 | 15 | # Package Files # 16 | *.jar 17 | *.war 18 | *.nar 19 | *.ear 20 | *.zip 21 | *.tar.gz 22 | *.rar 23 | 24 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 25 | hs_err_pid* 26 | 27 | 28 | # Project exclude paths 29 | .idea/ 30 | /.gradle/ 31 | /build/ 32 | /*/build/ 33 | /*/log 34 | 35 | .DS_Store -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 3.x | :white_check_mark: | 11 | | 2.x | :white_check_mark: | 12 | 13 | 14 | ## Reporting a Vulnerability 15 | If you find any security vulnuerablity please report to my personal email sonunitw12@gmail.com, ETA is 24 hours. 16 | -------------------------------------------------------------------------------- /copyright-template: -------------------------------------------------------------------------------- 1 | Copyright (c) $originalComment.match("Copyright \(c\) (\d+)", 1, "-", "$today.year")$today.year Sonu Kumar 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | You may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | https://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /docs/.ruby-version: -------------------------------------------------------------------------------- 1 | 3.1.0 2 | -------------------------------------------------------------------------------- /docs/404.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: 404 4 | permalink: /404 5 | nav_exclude: true 6 | search_exclude: true 7 | --- 8 | 9 |

Page not found

10 | 11 |

The page you requested could not be found. Try using the navigation {% if site.search_enabled != false %}or search {% endif %}to find what you're looking for or go to this site's home page.

12 | -------------------------------------------------------------------------------- /docs/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | # Hello! This is where you manage which Jekyll version is used to run. 3 | # When you want to use a different version, change it below, save the 4 | # file and run `bundle install`. Run Jekyll with `bundle exec`, like so: 5 | # 6 | # bundle exec jekyll serve 7 | # 8 | # This will help ensure the proper Jekyll version is running. 9 | # Happy Jekylling! 10 | gem "jekyll", "~> 4.3.2" 11 | gem "just-the-docs", "0.4.0" 12 | group :jekyll_plugins do 13 | gem "jekyll-feed", "~> 0.12" 14 | gem "jekyll-seo-tag" 15 | gem "jekyll-default-layout" 16 | gem "jekyll-sitemap" 17 | gem "jekyll-mermaid" 18 | gem "jekyll-spaceship" 19 | end 20 | 21 | # Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem 22 | # and associated library. 23 | platforms :mingw, :x64_mingw, :mswin, :jruby do 24 | gem "tzinfo", ">= 1", "< 3" 25 | gem "tzinfo-data" 26 | end 27 | 28 | # Performance-booster for watching directories on Windows 29 | gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin] 30 | 31 | # Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem 32 | # do not have a Java counterpart. 33 | gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby] 34 | 35 | gem "webrick", "~> 1.7" 36 | -------------------------------------------------------------------------------- /docs/_includes/footer_custom.html: -------------------------------------------------------------------------------- 1 | Copyright © 2019-{{ "now" | date: "%Y" }} Sonu Kumar. Distributed by an Apache 2.0 license. Build on {{ "now" | date:"%Y-%m-%d %H:%M" }} 2 | -------------------------------------------------------------------------------- /docs/_includes/head_custom.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/message-handling/middleware.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Middleware 4 | nav_order: 3 5 | parent: Producer Consumer 6 | description: Rqueue Middleware 7 | permalink: /middleware 8 | --- 9 | 10 | In many scenarios, there's a need to execute specific blocks of code repetitively. Some common use 11 | cases include: 12 | 13 | - Logging job details 14 | - Profiling listener methods 15 | - Initiating transactions (e.g., New Relic, database, distributed transactions, Micrometer tracer) 16 | - Implementing rate limiting (e.g., restricting a queue to process only 10 jobs per minute) 17 | - Managing concurrent job execution (e.g., ensuring a user's account updater job runs sequentially) 18 | - Handling permission or role changes (e.g., reacting to user bans or role updates) 19 | 20 | Middleware can effectively handle these situations by configuring one or more middlewares through 21 | the `SimpleRqueueListenerContainerFactory` object. These middlewares are invoked in the order they 22 | are added, enabling structured and consistent execution of tasks across different scenarios. 23 | 24 | ```java 25 | public class RqueueConfiguration { 26 | 27 | @Bean 28 | public SimpleRqueueListenerContainerFactory simpleRqueueListenerContainerFactory() { 29 | SimpleRqueueListenerContainerFactory factory = new SimpleRqueueListenerContainerFactory(); 30 | factory.useMiddleware(new LoggingMiddleware()); 31 | // add other middlewares here 32 | return factory; 33 | } 34 | } 35 | ``` 36 | -------------------------------------------------------------------------------- /docs/monitoring.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | nav_order: 7 4 | title: Monitoring and Alerting 5 | description: Rqueue Health Monitoring and Alerting 6 | permalink: /monitoring-alerting 7 | --- 8 | 9 | ## Monitoring Queue Statistics 10 | 11 | {: .note} 12 | 13 | Rqueue supports monitoring via the **Micrometer** library. 14 | 15 | ### Gauge Metrics 16 | 17 | Rqueue provides the following gauge metrics: 18 | 19 | * **queue.size**: Number of tasks waiting to be processed. 20 | * **dead.letter.queue.size**: Number of tasks in the dead letter queue. 21 | * **scheduled.queue.size**: Approximate number of tasks scheduled for future execution. 22 | * **processing.queue.size**: Approximate number of tasks currently being processed. 23 | 24 | ### Execution and Failure Counters 25 | 26 | Execution and failure counters can be enabled (disabled by default) by 27 | configuring `RqueueMetricsProperties`. 28 | 29 | ```properties 30 | rqueue.metrics.count.execution=true 31 | rqueue.metrics.count.failure=true 32 | ``` 33 | 34 | ### Integration 35 | 36 | #### Spring Boot Application 37 | 38 | 1. Include Micrometer dependencies and relevant exporters. 39 | 2. Set tags using `rqueue.metrics.tags. = ` if needed. 40 | 3. Enable counting features as required. 41 | 42 | #### Spring Application 43 | 44 | 1. Include Micrometer dependencies and provide `MeterRegistry` as a bean. 45 | 2. Configure a `RqueueMetricsProperties` bean with necessary settings. 46 | 47 | ### Example Grafana Dashboard 48 | 49 | [![Grafana Dashboard](https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/grafana-dashboard.png)](https://raw.githubusercontent.com/sonus21/rqueue/master/docs/static/grafana-dashboard.png) 50 | -------------------------------------------------------------------------------- /docs/static/favicon/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/favicon/android-chrome-192x192.png -------------------------------------------------------------------------------- /docs/static/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /docs/static/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /docs/static/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /docs/static/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/favicon/favicon.ico -------------------------------------------------------------------------------- /docs/static/grafana-dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/grafana-dashboard.png -------------------------------------------------------------------------------- /docs/static/jobs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/jobs.png -------------------------------------------------------------------------------- /docs/static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/logo.png -------------------------------------------------------------------------------- /docs/static/queue-explore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/queue-explore.png -------------------------------------------------------------------------------- /docs/static/queues.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/queues.png -------------------------------------------------------------------------------- /docs/static/rqueue-message-flow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/rqueue-message-flow.jpg -------------------------------------------------------------------------------- /docs/static/running-tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/running-tasks.png -------------------------------------------------------------------------------- /docs/static/stats-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/stats-graph.png -------------------------------------------------------------------------------- /docs/static/users/airtel-africa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/users/airtel-africa.png -------------------------------------------------------------------------------- /docs/static/users/aviva.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/users/aviva.jpeg -------------------------------------------------------------------------------- /docs/static/users/bitbot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/users/bitbot.png -------------------------------------------------------------------------------- /docs/static/users/chaoti-info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/users/chaoti-info.png -------------------------------------------------------------------------------- /docs/static/users/line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/users/line.png -------------------------------------------------------------------------------- /docs/static/users/mercedes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/users/mercedes.png -------------------------------------------------------------------------------- /docs/static/users/opentext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/users/opentext.png -------------------------------------------------------------------------------- /docs/static/users/pokerstars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/users/pokerstars.png -------------------------------------------------------------------------------- /docs/static/users/t-mobile.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /docs/static/users/tuneyou.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/users/tuneyou.png -------------------------------------------------------------------------------- /docs/static/users/vonage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/docs/static/users/vonage.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021-2023 Sonu Kumar 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # You may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and limitations under the License. 14 | # 15 | # 16 | org.gradle.caching=true 17 | org.gradle.parallel=true 18 | org.gradle.jvmargs='-Dfile.encoding=UTF-8' 19 | org.gradle.workers.max=3 -------------------------------------------------------------------------------- /gradle/packaging.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | tasks.named('jar') { 18 | manifest { 19 | attributes( 20 | "Built-By": "Sonu Kumar", 21 | "Build-Timestamp": new java.text.SimpleDateFormat("yyyy-MM-dd HH:mmZ").format(new Date()), 22 | "Build-Revision": version, 23 | "Created-By": "Gradle ${gradle.gradleVersion}", 24 | "Build-Jdk": "${System.properties["java.version"]} (${System.properties["java.vendor"]} ${System.properties["java.vm.version"]})", 25 | "Build-OS": "${System.properties["os.name"]} ${System.properties["os.arch"]} ${System.properties["os.version"]}", 26 | "Spring-Version": "${springVersion}", 27 | "Spring-Boot-Version": "${springBootVersion}" 28 | ) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2023 Sonu Kumar 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # You may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and limitations under the License. 14 | # 15 | # 16 | distributionBase=GRADLE_USER_HOME 17 | distributionPath=wrapper/dists 18 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip 19 | zipStoreBase=GRADLE_USER_HOME 20 | zipStorePath=wrapper/dists 21 | -------------------------------------------------------------------------------- /lombok.config: -------------------------------------------------------------------------------- 1 | lombok.addLombokGeneratedAnnotation = true -------------------------------------------------------------------------------- /publish.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright (c) 2022-2023 Sonu Kumar 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # You may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and limitations under the License. 15 | # 16 | # 17 | 18 | ./gradlew rqueue-core:publish 19 | ./gradlew rqueue-spring:publish 20 | ./gradlew rqueue-spring-boot-starter:publish 21 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/annotation/RqueueHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.annotation; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * This designated any public method as listener given the containing method is also annotated with 27 | * {@link RqueueListener}. In a class there must be exactly one primary one handler. 28 | * 29 | *

Registering more than one primary handler is not allowed. 30 | */ 31 | @Target({ElementType.METHOD}) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | @Documented 34 | public @interface RqueueHandler { 35 | 36 | /** 37 | * When true, designate that this is the default method only one method can be so designated. 38 | * 39 | * @return true if this is the default method. 40 | */ 41 | boolean primary() default false; 42 | } 43 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/common/ReactiveRqueueRedisTemplate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.common; 18 | 19 | import com.github.sonus21.rqueue.utils.RedisUtils; 20 | import java.io.Serializable; 21 | import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory; 22 | import org.springframework.data.redis.core.ReactiveRedisTemplate; 23 | 24 | public class ReactiveRqueueRedisTemplate { 25 | 26 | protected ReactiveRedisTemplate redisTemplate; 27 | 28 | public ReactiveRqueueRedisTemplate(ReactiveRedisConnectionFactory redisConnectionFactory) { 29 | this.redisTemplate = RedisUtils.getReactiveRedisTemplate(redisConnectionFactory); 30 | } 31 | 32 | public ReactiveRedisTemplate template() { 33 | return redisTemplate; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/common/RqueueLockManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.common; 18 | 19 | import java.time.Duration; 20 | 21 | public interface RqueueLockManager { 22 | 23 | boolean acquireLock(String lockKey, String lockValue, Duration duration); 24 | 25 | boolean releaseLock(String lockKey, String lockValue); 26 | } 27 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/converter/DefaultMessageConverterProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.converter; 18 | 19 | import com.github.sonus21.rqueue.core.DefaultRqueueMessageConverter; 20 | import org.springframework.messaging.converter.MessageConverter; 21 | 22 | public class DefaultMessageConverterProvider implements MessageConverterProvider { 23 | 24 | @Override 25 | public MessageConverter getConverter() { 26 | return new DefaultRqueueMessageConverter(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/core/context/Context.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.core.context; 18 | 19 | import com.github.sonus21.rqueue.core.middleware.ContextMiddleware; 20 | 21 | /** 22 | * A context that supports getValue method. Context is used inside job and middleware 23 | * 24 | * @see DefaultContext 25 | * @see ContextMiddleware 26 | */ 27 | public interface Context { 28 | 29 | /** 30 | * Return value form the context. 31 | * 32 | * @param key context key to be searched. 33 | * @return value or null 34 | */ 35 | Object getValue(Object key); 36 | } 37 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/core/middleware/LoggingMiddleware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.core.middleware; 18 | 19 | import com.github.sonus21.rqueue.core.Job; 20 | import java.util.concurrent.Callable; 21 | import lombok.extern.slf4j.Slf4j; 22 | 23 | /** 24 | * A simple logging middleware that logs queue and job id for visibility 25 | */ 26 | @Slf4j 27 | public class LoggingMiddleware implements Middleware { 28 | 29 | @Override 30 | public void handle(Job job, Callable next) throws Exception { 31 | log.info("Queue: {}, JobId: {}", job.getRqueueMessage().getQueueName(), job.getId()); 32 | next.call(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/core/middleware/RateLimiterMiddleware.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.core.middleware; 18 | 19 | import com.github.sonus21.rqueue.core.Job; 20 | import com.github.sonus21.rqueue.models.enums.JobStatus; 21 | import java.util.concurrent.Callable; 22 | 23 | public interface RateLimiterMiddleware extends TimeProviderMiddleware { 24 | 25 | boolean isThrottled(Job job); 26 | 27 | @Override 28 | default void handle(Job job, Callable callable) throws Exception { 29 | if (isThrottled(job)) { 30 | job.release(JobStatus.FAILED, "Throttled", releaseIn(job)); 31 | } else { 32 | callable.call(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/dao/RqueueJobDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.dao; 18 | 19 | import com.github.sonus21.rqueue.models.db.RqueueJob; 20 | import java.time.Duration; 21 | import java.util.Collection; 22 | import java.util.List; 23 | 24 | public interface RqueueJobDao { 25 | 26 | void createJob(RqueueJob rqueueJob, Duration expiry); 27 | 28 | void save(RqueueJob rqueueJob, Duration expiry); 29 | 30 | RqueueJob findById(String jobId); 31 | 32 | List findJobsByIdIn(Collection jobIds); 33 | 34 | List finByMessageIdIn(List messageIds); 35 | 36 | List finByMessageId(String messageId); 37 | 38 | void delete(String jobId); 39 | } 40 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/dao/RqueueMessageMetadataDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.dao; 18 | 19 | import com.github.sonus21.rqueue.models.db.MessageMetadata; 20 | import java.time.Duration; 21 | import java.util.Collection; 22 | import java.util.List; 23 | import reactor.core.publisher.Mono; 24 | 25 | public interface RqueueMessageMetadataDao { 26 | 27 | MessageMetadata get(String id); 28 | 29 | List findAll(Collection ids); 30 | 31 | void save(MessageMetadata messageMetadata, Duration ttl); 32 | 33 | void delete(String id); 34 | 35 | void deleteAll(Collection ids); 36 | 37 | Mono saveReactive(MessageMetadata messageMetadata, Duration duration); 38 | } 39 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/dao/RqueueQStatsDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.dao; 18 | 19 | import com.github.sonus21.rqueue.models.db.QueueStatistics; 20 | import java.util.Collection; 21 | import java.util.List; 22 | 23 | public interface RqueueQStatsDao { 24 | 25 | QueueStatistics findById(String id); 26 | 27 | List findAll(Collection ids); 28 | 29 | void save(QueueStatistics queueStatistics); 30 | } 31 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/dao/RqueueSystemConfigDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.dao; 18 | 19 | import com.github.sonus21.rqueue.models.db.QueueConfig; 20 | import java.util.Collection; 21 | import java.util.List; 22 | 23 | public interface RqueueSystemConfigDao { 24 | 25 | QueueConfig getConfigByName(String name); 26 | 27 | List getConfigByNames(Collection names); 28 | 29 | QueueConfig getConfigByName(String name, boolean cached); 30 | 31 | QueueConfig getQConfig(String id, boolean cached); 32 | 33 | List findAllQConfig(Collection ids); 34 | 35 | void saveQConfig(QueueConfig queueConfig); 36 | 37 | void saveAllQConfig(List newConfigs); 38 | 39 | void clearCacheByName(String name); 40 | } 41 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/exception/LockCanNotBeAcquired.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.exception; 18 | 19 | /** 20 | * Whenever a lock can not be acquired cause some other process/thread is holding lock then this 21 | * error would be thrown. The application should retry once this error occurs. 22 | */ 23 | public class LockCanNotBeAcquired extends RuntimeException { 24 | 25 | private static final long serialVersionUID = 598739372785907190L; 26 | 27 | public LockCanNotBeAcquired(String name) { 28 | super(name); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/exception/OverrideException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.exception; 18 | 19 | public class OverrideException extends RuntimeException { 20 | 21 | private static final long serialVersionUID = 598739372785907190L; 22 | 23 | public OverrideException(String name) { 24 | super(name); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/exception/ProcessingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.exception; 18 | 19 | public class ProcessingException extends Exception { 20 | 21 | private static final long serialVersionUID = 9003794852942108696L; 22 | private final Object data; 23 | 24 | public ProcessingException(String message) { 25 | this(message, null); 26 | } 27 | 28 | public ProcessingException(String message, Object data) { 29 | super(message); 30 | this.data = null; 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | if (data == null) { 36 | return super.toString(); 37 | } 38 | return super.toString() + data; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/exception/QueueDoesNotExist.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.exception; 18 | 19 | /** 20 | * This exception is raised, when a queue is not registered in 21 | * {@link com.github.sonus21.rqueue.core.EndpointRegistry}, to register a queue use 22 | * {@link com.github.sonus21.rqueue.core.RqueueEndpointManager#registerQueue(String, String...)} 23 | */ 24 | public class QueueDoesNotExist extends RuntimeException { 25 | 26 | private static final long serialVersionUID = 598739372785907190L; 27 | 28 | public QueueDoesNotExist(String name) { 29 | super(name); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/exception/TimedOutException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.exception; 18 | 19 | public class TimedOutException extends Exception { 20 | 21 | private static final long serialVersionUID = 132943639600997783L; 22 | 23 | public TimedOutException(String message) { 24 | super(message); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/exception/UnknownSwitchCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.exception; 18 | 19 | public class UnknownSwitchCase extends RuntimeException { 20 | 21 | private static final long serialVersionUID = -363842614000049763L; 22 | 23 | public UnknownSwitchCase(String message) { 24 | super(message); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/metrics/RqueueCounter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.metrics; 18 | 19 | /** 20 | * Rqueue counter counts the different types of events related to a queue. It's used to count how 21 | * many messages have been processed and how many of them have been failed. In the case of failure 22 | * count increases. 23 | */ 24 | public class RqueueCounter implements RqueueMetricsCounter { 25 | 26 | private final QueueCounter queueCounter; 27 | 28 | public RqueueCounter(QueueCounter queueCounter) { 29 | this.queueCounter = queueCounter; 30 | } 31 | 32 | @Override 33 | public void updateFailureCount(String queueName) { 34 | queueCounter.updateFailureCount(queueName); 35 | } 36 | 37 | @Override 38 | public void updateExecutionCount(String queueName) { 39 | queueCounter.updateExecutionCount(queueName); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/metrics/RqueueMetricsCounter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.metrics; 18 | 19 | public interface RqueueMetricsCounter { 20 | 21 | void updateFailureCount(String queueName); 22 | 23 | void updateExecutionCount(String queueName); 24 | } 25 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/metrics/RqueueMetricsRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.metrics; 18 | 19 | import com.github.sonus21.rqueue.models.event.RqueueBootstrapEvent; 20 | import org.springframework.context.ApplicationListener; 21 | 22 | public interface RqueueMetricsRegistry extends ApplicationListener { 23 | 24 | QueueCounter getQueueCounter(); 25 | } 26 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/Concurrency.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models; 18 | 19 | import com.fasterxml.jackson.annotation.JsonIgnore; 20 | import lombok.AllArgsConstructor; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | 24 | @Getter 25 | @AllArgsConstructor 26 | @EqualsAndHashCode(callSuper = true) 27 | public class Concurrency extends SerializableBase { 28 | 29 | private static final long serialVersionUID = 3165194419314698068L; 30 | private final int min; 31 | private final int max; 32 | 33 | public MinMax toMinMax() { 34 | return new MinMax<>(min, max); 35 | } 36 | 37 | @JsonIgnore 38 | public boolean isValid() { 39 | return min > 0; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/MessageMoveResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | 22 | @Getter 23 | @AllArgsConstructor 24 | public class MessageMoveResult { 25 | 26 | private final int numberOfMessages; 27 | private final boolean success; 28 | } 29 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/MinMax.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models; 18 | 19 | import java.io.Serializable; 20 | import lombok.AllArgsConstructor; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | import lombok.Setter; 25 | 26 | @Getter 27 | @Setter 28 | @AllArgsConstructor 29 | @EqualsAndHashCode(callSuper = false) 30 | @NoArgsConstructor 31 | public class MinMax extends SerializableBase { 32 | 33 | private static final long serialVersionUID = 455990603344829053L; 34 | private T min; 35 | private T max; 36 | } 37 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Getter; 21 | import lombok.NoArgsConstructor; 22 | import lombok.Setter; 23 | 24 | @AllArgsConstructor 25 | @NoArgsConstructor 26 | @Setter 27 | @Getter 28 | public class Pair { 29 | 30 | private S first; 31 | private T second; 32 | } 33 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/PubSubMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models; 18 | 19 | import java.io.Serializable; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.ToString; 24 | 25 | @Getter 26 | @NoArgsConstructor 27 | @ToString(callSuper = true) 28 | @EqualsAndHashCode(callSuper = true) 29 | public class PubSubMessage extends SerializableBase { 30 | 31 | private static final long serialVersionUID = 780914041036616260L; 32 | private String senderId; 33 | private Serializable data; 34 | } 35 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/SerializableBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models; 18 | 19 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 20 | import com.fasterxml.jackson.annotation.JsonInclude; 21 | import com.fasterxml.jackson.annotation.JsonInclude.Include; 22 | import java.io.Serializable; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.NoArgsConstructor; 25 | 26 | @JsonIgnoreProperties(ignoreUnknown = true) 27 | @NoArgsConstructor 28 | @EqualsAndHashCode 29 | @JsonInclude(Include.NON_NULL) 30 | public abstract class SerializableBase implements Serializable { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/aggregator/TasksStat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.aggregator; 18 | 19 | import com.github.sonus21.rqueue.models.db.JobRunTime; 20 | import lombok.ToString; 21 | 22 | @ToString 23 | public class TasksStat { 24 | 25 | public long discarded = 0; 26 | public long success = 0; 27 | public long movedToDlq = 0; 28 | public long retried = 0; 29 | public long jobCount; 30 | public long minExecution = Long.MAX_VALUE; 31 | public long maxExecution = 0; 32 | public long totalExecutionTime; 33 | 34 | public JobRunTime jobRunTime() { 35 | return new JobRunTime(minExecution, maxExecution, jobCount, totalExecutionTime); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/db/CheckinMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.db; 18 | 19 | import com.github.sonus21.rqueue.models.SerializableBase; 20 | import java.io.Serializable; 21 | import lombok.AllArgsConstructor; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NoArgsConstructor; 25 | import lombok.Setter; 26 | 27 | @Getter 28 | @Setter 29 | @NoArgsConstructor 30 | @AllArgsConstructor 31 | @EqualsAndHashCode(callSuper = false) 32 | public class CheckinMessage extends SerializableBase { 33 | 34 | private static final long serialVersionUID = 4727068901984917510L; 35 | private Serializable message; 36 | private long at; 37 | } 38 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/db/DeadLetterQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.db; 18 | 19 | import com.github.sonus21.rqueue.models.SerializableBase; 20 | import lombok.AllArgsConstructor; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | import lombok.Setter; 25 | import lombok.ToString; 26 | 27 | @Getter 28 | @Setter 29 | @AllArgsConstructor 30 | @NoArgsConstructor 31 | @EqualsAndHashCode(callSuper = false) 32 | @ToString 33 | public class DeadLetterQueue extends SerializableBase { 34 | 35 | private static final long serialVersionUID = 2632111672508854121L; 36 | private String name; 37 | private boolean consumerEnabled; 38 | } 39 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/db/Execution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.db; 18 | 19 | import com.fasterxml.jackson.annotation.JsonIgnore; 20 | import com.github.sonus21.rqueue.models.SerializableBase; 21 | import com.github.sonus21.rqueue.models.enums.ExecutionStatus; 22 | import lombok.AllArgsConstructor; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NoArgsConstructor; 26 | import lombok.Setter; 27 | import lombok.ToString; 28 | 29 | @AllArgsConstructor 30 | @NoArgsConstructor 31 | @Getter 32 | @Setter 33 | @EqualsAndHashCode(callSuper = true) 34 | @ToString(callSuper = true) 35 | public class Execution extends SerializableBase { 36 | 37 | private static final long serialVersionUID = 3893537050761142817L; 38 | private long startTime; 39 | private long endTime; 40 | private String error; 41 | @JsonIgnore 42 | private Throwable exception; 43 | private ExecutionStatus status; 44 | } 45 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/db/JobRunTime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.db; 18 | 19 | import com.github.sonus21.rqueue.models.SerializableBase; 20 | import lombok.AllArgsConstructor; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | import lombok.Setter; 25 | 26 | @Getter 27 | @Setter 28 | @NoArgsConstructor 29 | @AllArgsConstructor 30 | @EqualsAndHashCode(callSuper = false) 31 | public class JobRunTime extends SerializableBase { 32 | 33 | private static final long serialVersionUID = 6219118148061766036L; 34 | private long min; 35 | private long max; 36 | private long jobCount; 37 | private long totalExecutionTime; 38 | } 39 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/enums/ActionType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.enums; 18 | 19 | public enum ActionType { 20 | DELETE, 21 | NONE 22 | } 23 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/enums/AggregationType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.enums; 18 | 19 | import lombok.AccessLevel; 20 | import lombok.AllArgsConstructor; 21 | import lombok.Getter; 22 | 23 | @AllArgsConstructor(access = AccessLevel.PRIVATE) 24 | @Getter 25 | public enum AggregationType { 26 | DAILY("Daily"), 27 | WEEKLY("Weekly"), 28 | MONTHLY("Monthly"); 29 | private final String description; 30 | } 31 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/enums/ChartDataType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.enums; 18 | 19 | import java.util.Arrays; 20 | import java.util.List; 21 | import java.util.stream.Collectors; 22 | import lombok.AllArgsConstructor; 23 | import lombok.Getter; 24 | 25 | @AllArgsConstructor 26 | @Getter 27 | public enum ChartDataType { 28 | SUCCESSFUL("Successful execution", true), 29 | DISCARDED("Message discarded", true), 30 | MOVED_TO_DLQ("Moved to dead letter queue messages", true), 31 | RETRIED("Retried at least once", true), 32 | EXECUTION("Min Execution time", false); 33 | private final String description; 34 | private final boolean userView; 35 | 36 | public static List getActiveCharts() { 37 | return Arrays.stream(values()).filter(ChartDataType::isUserView).collect(Collectors.toList()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/enums/ChartType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.enums; 18 | 19 | import lombok.AccessLevel; 20 | import lombok.AllArgsConstructor; 21 | import lombok.Getter; 22 | 23 | @AllArgsConstructor(access = AccessLevel.PRIVATE) 24 | @Getter 25 | public enum ChartType { 26 | LATENCY, 27 | STATS 28 | } 29 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/enums/ExecutionStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.enums; 18 | 19 | public enum ExecutionStatus { 20 | IN_PROGRESS, 21 | SUCCESSFUL, 22 | THROTTLED, 23 | DELETED, 24 | FAILED, 25 | IGNORED, 26 | OLD_MESSAGE, 27 | QUEUE_INACTIVE, 28 | } 29 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/enums/JobStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.enums; 18 | 19 | public enum JobStatus { 20 | UNKNOWN, 21 | CREATED, 22 | PROCESSING, 23 | FAILED, 24 | SUCCESS 25 | } 26 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/enums/NavTab.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.enums; 18 | 19 | import lombok.AccessLevel; 20 | import lombok.AllArgsConstructor; 21 | import lombok.Getter; 22 | 23 | @AllArgsConstructor(access = AccessLevel.PRIVATE) 24 | @Getter 25 | public enum NavTab { 26 | QUEUES("Queues"), 27 | DEAD("Dead"), 28 | RUNNING("Running"), 29 | PENDING("Pending"), 30 | SCHEDULED("Scheduled"), 31 | COMPLETED("Completed"), 32 | UTILITY("Utility"); 33 | private final String description; 34 | } 35 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/enums/PriorityMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.enums; 18 | 19 | public enum PriorityMode { 20 | STRICT, 21 | WEIGHTED 22 | } 23 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/enums/PubSubType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.enums; 18 | 19 | public enum PubSubType { 20 | PAUSE_QUEUE, 21 | QUEUE_CRUD; 22 | } 23 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/enums/RqueueMode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.enums; 18 | 19 | public enum RqueueMode { 20 | PRODUCER, 21 | CONSUMER, 22 | BOTH, 23 | } 24 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/enums/TableColumnType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.enums; 18 | 19 | public enum TableColumnType { 20 | DISPLAY, 21 | ACTION 22 | } 23 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/event/RqueueQueuePauseEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.event; 18 | 19 | import lombok.Getter; 20 | import org.springframework.context.ApplicationEvent; 21 | 22 | @Getter 23 | public class RqueueQueuePauseEvent extends ApplicationEvent { 24 | 25 | private final String queue; 26 | 27 | private final boolean paused; 28 | 29 | /** 30 | * Create a new ApplicationEvent. 31 | * 32 | * @param source the object on which the event initially occurred (never {@code null}) 33 | * @param queue queue that's getting (un)paused 34 | * @param paused a boolean flag that indicates whether it's going to paused or otherwise 35 | */ 36 | public RqueueQueuePauseEvent(Object source, String queue, boolean paused) { 37 | super(source); 38 | this.queue = queue; 39 | this.paused = paused; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/request/DataDeleteRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.request; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | import com.github.sonus21.rqueue.models.SerializableBase; 21 | import jakarta.validation.constraints.NotEmpty; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NoArgsConstructor; 25 | import lombok.Setter; 26 | import lombok.ToString; 27 | 28 | @Getter 29 | @Setter 30 | @NoArgsConstructor 31 | @ToString 32 | @EqualsAndHashCode(callSuper = true) 33 | public class DataDeleteRequest extends SerializableBase { 34 | 35 | @JsonProperty("queue") 36 | @NotEmpty 37 | private String queueName; 38 | 39 | @JsonProperty("data_set") 40 | @NotEmpty 41 | private String datasetName; 42 | } 43 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/request/DataTypeRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.request; 18 | 19 | import com.github.sonus21.rqueue.models.SerializableBase; 20 | import jakarta.validation.constraints.NotEmpty; 21 | import lombok.AllArgsConstructor; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NoArgsConstructor; 25 | import lombok.Setter; 26 | import lombok.ToString; 27 | 28 | @Getter 29 | @Setter 30 | @NoArgsConstructor 31 | @ToString 32 | @EqualsAndHashCode(callSuper = true) 33 | @AllArgsConstructor 34 | public class DataTypeRequest extends SerializableBase { 35 | 36 | @NotEmpty 37 | private String name; 38 | } 39 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/request/DateViewRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.request; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | import com.github.sonus21.rqueue.models.SerializableBase; 21 | import com.github.sonus21.rqueue.models.enums.DataType; 22 | import jakarta.validation.constraints.NotEmpty; 23 | import jakarta.validation.constraints.NotNull; 24 | import lombok.EqualsAndHashCode; 25 | import lombok.Getter; 26 | import lombok.NoArgsConstructor; 27 | import lombok.Setter; 28 | import lombok.ToString; 29 | 30 | @Getter 31 | @Setter 32 | @NoArgsConstructor 33 | @ToString 34 | @EqualsAndHashCode(callSuper = true) 35 | public class DateViewRequest extends SerializableBase { 36 | 37 | private @NotNull DataType type; 38 | private @NotEmpty String name; 39 | private String key; 40 | 41 | @JsonProperty("page") 42 | private int pageNumber = 0; 43 | 44 | @JsonProperty("count") 45 | private int itemPerPage = 20; 46 | } 47 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/request/MessageDeleteRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.request; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | import com.github.sonus21.rqueue.models.SerializableBase; 21 | import jakarta.validation.constraints.NotEmpty; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NoArgsConstructor; 25 | import lombok.Setter; 26 | import lombok.ToString; 27 | 28 | @Getter 29 | @Setter 30 | @NoArgsConstructor 31 | @ToString 32 | @EqualsAndHashCode(callSuper = true) 33 | public class MessageDeleteRequest extends SerializableBase { 34 | 35 | @JsonProperty("queue") 36 | @NotEmpty 37 | private String queueName; 38 | 39 | @JsonProperty("message_id") 40 | @NotEmpty 41 | private String messageId; 42 | } 43 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/request/PauseUnpauseQueueRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.request; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.Setter; 24 | 25 | @Getter 26 | @Setter 27 | @NoArgsConstructor 28 | @EqualsAndHashCode(callSuper = true) 29 | @AllArgsConstructor 30 | public class PauseUnpauseQueueRequest extends DataTypeRequest { 31 | 32 | private boolean pause; 33 | 34 | @Override 35 | public String toString() { 36 | return "PauseUnpauseQueueRequest{" + "queue=" + getName() + ", pause=" + pause + '}'; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/request/QueueExploreRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.request; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | import com.github.sonus21.rqueue.models.SerializableBase; 21 | import com.github.sonus21.rqueue.models.enums.DataType; 22 | import jakarta.validation.constraints.NotEmpty; 23 | import jakarta.validation.constraints.NotNull; 24 | import lombok.EqualsAndHashCode; 25 | import lombok.Getter; 26 | import lombok.NoArgsConstructor; 27 | import lombok.Setter; 28 | import lombok.ToString; 29 | 30 | @Getter 31 | @Setter 32 | @NoArgsConstructor 33 | @ToString 34 | @EqualsAndHashCode(callSuper = true) 35 | public class QueueExploreRequest extends SerializableBase { 36 | 37 | private @NotNull DataType type; 38 | private @NotEmpty String name; 39 | private @NotEmpty String src; 40 | 41 | @JsonProperty("page") 42 | private int pageNumber = 0; 43 | 44 | @JsonProperty("count") 45 | private int itemPerPage = 20; 46 | } 47 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/response/Action.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.response; 18 | 19 | import com.github.sonus21.rqueue.models.SerializableBase; 20 | import com.github.sonus21.rqueue.models.enums.ActionType; 21 | import lombok.AllArgsConstructor; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NoArgsConstructor; 25 | import lombok.Setter; 26 | import lombok.ToString; 27 | 28 | @Getter 29 | @Setter 30 | @AllArgsConstructor 31 | @NoArgsConstructor 32 | @ToString 33 | @EqualsAndHashCode(callSuper = true) 34 | public class Action extends SerializableBase { 35 | 36 | private static final long serialVersionUID = 7809140410366162600L; 37 | private ActionType type; 38 | private String description; 39 | } 40 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/response/BaseResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.response; 18 | 19 | import com.fasterxml.jackson.annotation.JsonIgnore; 20 | import com.github.sonus21.rqueue.models.SerializableBase; 21 | import lombok.AllArgsConstructor; 22 | import lombok.Builder; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.Getter; 25 | import lombok.NoArgsConstructor; 26 | import lombok.Setter; 27 | import lombok.ToString; 28 | 29 | @AllArgsConstructor 30 | @NoArgsConstructor 31 | @Getter 32 | @Setter 33 | @ToString 34 | @EqualsAndHashCode(callSuper = false) 35 | @Builder 36 | public class BaseResponse extends SerializableBase { 37 | 38 | private static final long serialVersionUID = 4830863373464370840L; 39 | private int code; 40 | private String message; 41 | 42 | @JsonIgnore 43 | public void set(int code, String message) { 44 | this.code = code; 45 | this.message = message; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/response/BooleanResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.response; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.Setter; 24 | import lombok.ToString; 25 | 26 | @Getter 27 | @AllArgsConstructor 28 | @NoArgsConstructor 29 | @Setter 30 | @ToString(callSuper = true) 31 | @EqualsAndHashCode(callSuper = true) 32 | public class BooleanResponse extends BaseResponse { 33 | 34 | private static final long serialVersionUID = 3137908352960413849L; 35 | private boolean value; 36 | } 37 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/response/ChartDataResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.response; 18 | 19 | import com.fasterxml.jackson.annotation.JsonProperty; 20 | import java.io.Serializable; 21 | import java.util.List; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | import lombok.Setter; 25 | import lombok.ToString; 26 | 27 | @Getter 28 | @Setter 29 | @ToString(callSuper = true) 30 | @SuppressWarnings("java:S2160") 31 | @NoArgsConstructor 32 | public class ChartDataResponse extends BaseResponse { 33 | 34 | private static final long serialVersionUID = -7881568871822217801L; 35 | private List> data; 36 | private String title; 37 | 38 | @JsonProperty("hTitle") 39 | private String hTitle; 40 | 41 | @JsonProperty("vTitle") 42 | private String vTitle; 43 | } 44 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/response/DataSelectorResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.response; 18 | 19 | import com.github.sonus21.rqueue.models.Pair; 20 | import java.util.List; 21 | import lombok.AllArgsConstructor; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | import lombok.Setter; 25 | import lombok.ToString; 26 | 27 | @Getter 28 | @Setter 29 | @ToString(callSuper = true) 30 | @SuppressWarnings("java:S2160") 31 | @NoArgsConstructor 32 | @AllArgsConstructor 33 | public class DataSelectorResponse extends BaseResponse { 34 | 35 | private String title; 36 | private List> data; 37 | } 38 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/response/MessageMoveResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.response; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.Setter; 24 | import lombok.ToString; 25 | 26 | @Getter 27 | @NoArgsConstructor 28 | @Setter 29 | @ToString(callSuper = true) 30 | @AllArgsConstructor 31 | @EqualsAndHashCode(callSuper = true) 32 | public class MessageMoveResponse extends BooleanResponse { 33 | 34 | private static final long serialVersionUID = 4070425131282033429L; 35 | private int numberOfMessageTransferred; 36 | } 37 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/response/RedisDataDetail.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.response; 18 | 19 | import com.github.sonus21.rqueue.models.SerializableBase; 20 | import com.github.sonus21.rqueue.models.enums.DataType; 21 | import lombok.AllArgsConstructor; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NoArgsConstructor; 25 | import lombok.Setter; 26 | import lombok.ToString; 27 | 28 | @Getter 29 | @Setter 30 | @AllArgsConstructor 31 | @NoArgsConstructor 32 | @ToString(callSuper = true) 33 | @EqualsAndHashCode(callSuper = false) 34 | public class RedisDataDetail extends SerializableBase { 35 | 36 | private static final long serialVersionUID = 1056616946630817927L; 37 | private String name; 38 | private DataType type; 39 | private long size; 40 | } 41 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/response/RowColumnMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.response; 18 | 19 | import com.github.sonus21.rqueue.models.SerializableBase; 20 | import java.io.Serializable; 21 | import lombok.AllArgsConstructor; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.Getter; 24 | import lombok.NoArgsConstructor; 25 | import lombok.ToString; 26 | 27 | @Getter 28 | @AllArgsConstructor 29 | @ToString(callSuper = true) 30 | @EqualsAndHashCode(callSuper = true) 31 | @NoArgsConstructor 32 | public class RowColumnMeta extends SerializableBase { 33 | 34 | private static final long serialVersionUID = 7727947329124106340L; 35 | private RowColumnMetaType type; 36 | private Serializable data; 37 | 38 | public RowColumnMeta(RowColumnMetaType type) { 39 | this(type, null); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/response/RowColumnMetaType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.response; 18 | 19 | public enum RowColumnMetaType { 20 | JOBS_BUTTON 21 | } 22 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/response/StringResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.response; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.Setter; 24 | import lombok.ToString; 25 | 26 | @Getter 27 | @Setter 28 | @AllArgsConstructor 29 | @EqualsAndHashCode(callSuper = true) 30 | @ToString(callSuper = true) 31 | @NoArgsConstructor 32 | public class StringResponse extends BaseResponse { 33 | 34 | private static final long serialVersionUID = -5110084277095370843L; 35 | private String val; 36 | } 37 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/models/response/Table.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.models.response; 18 | 19 | import java.util.List; 20 | import lombok.AllArgsConstructor; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | import lombok.Setter; 25 | import lombok.ToString; 26 | 27 | @Getter 28 | @Setter 29 | @AllArgsConstructor 30 | @NoArgsConstructor 31 | @ToString(callSuper = true) 32 | @EqualsAndHashCode(callSuper = true) 33 | public class Table extends BaseResponse { 34 | 35 | private static final long serialVersionUID = -7188146334911288456L; 36 | private List headers; 37 | private List rows; 38 | } 39 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/utils/ExceptionUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.utils; 18 | 19 | import java.io.PrintWriter; 20 | import java.io.StringWriter; 21 | 22 | public final class ExceptionUtils { 23 | 24 | private ExceptionUtils() { 25 | } 26 | 27 | public static String getTraceback(Throwable e, int maxLength) { 28 | if (e == null) { 29 | return null; 30 | } 31 | StringWriter sw = new StringWriter(); 32 | PrintWriter pw = new PrintWriter(sw); 33 | e.printStackTrace(pw); 34 | String stacktrace = sw.toString(); 35 | if (stacktrace.length() > maxLength + 3) { 36 | stacktrace = stacktrace.substring(0, maxLength) + "..."; 37 | } 38 | return stacktrace; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/utils/PriorityUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.utils; 18 | 19 | import java.util.HashSet; 20 | import java.util.Map; 21 | import java.util.Set; 22 | 23 | public final class PriorityUtils { 24 | 25 | private PriorityUtils() { 26 | } 27 | 28 | public static Set getNamesFromPriority(String queueName, Map priority) { 29 | Set keys = new HashSet<>(); 30 | for (String key : priority.keySet()) { 31 | if (!key.equals(Constants.DEFAULT_PRIORITY_KEY)) { 32 | keys.add(getQueueNameForPriority(queueName, key)); 33 | } 34 | } 35 | return keys; 36 | } 37 | 38 | public static String getQueueNameForPriority(String queueName, String priority) { 39 | Validator.validateQueue(queueName); 40 | Validator.validatePriority(priority); 41 | return queueName + getSuffix(priority); 42 | } 43 | 44 | public static String getSuffix(String priority) { 45 | return "_" + priority; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/utils/SerializationUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.utils; 18 | 19 | import com.fasterxml.jackson.databind.DeserializationFeature; 20 | import com.fasterxml.jackson.databind.ObjectMapper; 21 | 22 | public final class SerializationUtils { 23 | 24 | public static final byte[] EMPTY_ARRAY = new byte[0]; 25 | 26 | private SerializationUtils() { 27 | } 28 | 29 | public static boolean isEmpty(byte[] bytes) { 30 | return bytes == null || bytes.length == 0; 31 | } 32 | 33 | public static boolean isJson(String data) { 34 | return !StringUtils.isEmpty(data) 35 | && data.charAt(0) == '{' 36 | && data.charAt(data.length() - 1) == '}'; 37 | } 38 | 39 | public static ObjectMapper createObjectMapper() { 40 | ObjectMapper mapper = new ObjectMapper(); 41 | mapper = mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); 42 | return mapper; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/utils/condition/ReactiveDisabled.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.utils.condition; 18 | 19 | import org.springframework.context.annotation.Condition; 20 | import org.springframework.context.annotation.ConditionContext; 21 | import org.springframework.core.type.AnnotatedTypeMetadata; 22 | 23 | public class ReactiveDisabled implements Condition { 24 | 25 | @Override 26 | public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { 27 | Boolean reactiveEnabled = 28 | context.getEnvironment().getProperty("rqueue.reactive.enabled", Boolean.class); 29 | return !Boolean.TRUE.equals(reactiveEnabled); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/utils/condition/ReactiveEnabled.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.utils.condition; 18 | 19 | import org.springframework.context.annotation.Condition; 20 | import org.springframework.context.annotation.ConditionContext; 21 | import org.springframework.core.type.AnnotatedTypeMetadata; 22 | 23 | public class ReactiveEnabled implements Condition { 24 | 25 | @Override 26 | public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { 27 | Boolean reactiveEnabled = 28 | context.getEnvironment().getProperty("rqueue.reactive.enabled", Boolean.class); 29 | return Boolean.TRUE.equals(reactiveEnabled); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/utils/condition/RqueueEnabled.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.utils.condition; 18 | 19 | import org.springframework.context.annotation.Condition; 20 | import org.springframework.context.annotation.ConditionContext; 21 | import org.springframework.core.type.AnnotatedTypeMetadata; 22 | 23 | public class RqueueEnabled implements Condition { 24 | 25 | @Override 26 | public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { 27 | Boolean enabled = context.getEnvironment().getProperty("rqueue.enabled", Boolean.class); 28 | return enabled == null || Boolean.TRUE.equals(enabled); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/utils/pebble/DateTimeFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.utils.pebble; 18 | 19 | import com.github.sonus21.rqueue.utils.DateTimeUtils; 20 | import io.pebbletemplates.pebble.extension.Function; 21 | import io.pebbletemplates.pebble.template.EvaluationContext; 22 | import io.pebbletemplates.pebble.template.PebbleTemplate; 23 | import java.util.Collections; 24 | import java.util.List; 25 | import java.util.Map; 26 | 27 | public class DateTimeFunction implements Function { 28 | 29 | public static final String FUNCTION_NAME = "time"; 30 | 31 | @Override 32 | public Object execute( 33 | Map args, PebbleTemplate self, EvaluationContext context, int lineNumber) { 34 | Long milli = (Long) args.get("milli"); 35 | return DateTimeUtils.formatMilliToString(milli); 36 | } 37 | 38 | @Override 39 | public List getArgumentNames() { 40 | return Collections.singletonList("milli"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/utils/pebble/DefaultFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.utils.pebble; 18 | 19 | import io.pebbletemplates.pebble.extension.Function; 20 | import io.pebbletemplates.pebble.template.EvaluationContext; 21 | import io.pebbletemplates.pebble.template.PebbleTemplate; 22 | import java.util.Arrays; 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | public class DefaultFunction implements Function { 27 | 28 | public static final String FUNCTION_NAME = "default"; 29 | 30 | @Override 31 | public Object execute( 32 | Map args, PebbleTemplate self, EvaluationContext context, int lineNumber) { 33 | Object src = args.get("src"); 34 | Object dst = args.get("dst"); 35 | if (src == null) { 36 | return dst; 37 | } 38 | return src; 39 | } 40 | 41 | @Override 42 | public List getArgumentNames() { 43 | return Arrays.asList("src", "dst"); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/utils/pebble/RqueuePebbleExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.utils.pebble; 18 | 19 | import io.pebbletemplates.pebble.extension.AbstractExtension; 20 | import io.pebbletemplates.pebble.extension.Function; 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | 24 | public class RqueuePebbleExtension extends AbstractExtension { 25 | 26 | @Override 27 | public Map getFunctions() { 28 | Map map = new HashMap<>(); 29 | map.put(DeadLetterQueuesFunction.FUNCTION_NAME, new DeadLetterQueuesFunction()); 30 | map.put(DateTimeFunction.FUNCTION_NAME, new DateTimeFunction()); 31 | map.put(DefaultFunction.FUNCTION_NAME, new DefaultFunction()); 32 | return map; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/web/controller/BaseController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.web.controller; 18 | 19 | import com.github.sonus21.rqueue.config.RqueueWebConfig; 20 | import jakarta.servlet.http.HttpServletResponse; 21 | 22 | public class BaseController { 23 | 24 | private final RqueueWebConfig rqueueWebConfig; 25 | 26 | public BaseController(RqueueWebConfig rqueueWebConfig) { 27 | this.rqueueWebConfig = rqueueWebConfig; 28 | } 29 | 30 | protected boolean isEnable(HttpServletResponse response) { 31 | if (!rqueueWebConfig.isEnable()) { 32 | response.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); 33 | } 34 | return rqueueWebConfig.isEnable(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/web/controller/BaseReactiveController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.web.controller; 18 | 19 | import com.github.sonus21.rqueue.config.RqueueWebConfig; 20 | import org.springframework.http.HttpStatus; 21 | import org.springframework.http.server.reactive.ServerHttpResponse; 22 | 23 | public class BaseReactiveController { 24 | 25 | protected final RqueueWebConfig rqueueWebConfig; 26 | 27 | public BaseReactiveController(RqueueWebConfig rqueueWebConfig) { 28 | this.rqueueWebConfig = rqueueWebConfig; 29 | } 30 | 31 | protected boolean isEnabled(ServerHttpResponse response) { 32 | if (!rqueueWebConfig.isEnable()) { 33 | response.setStatusCode(HttpStatus.SERVICE_UNAVAILABLE); 34 | } 35 | return rqueueWebConfig.isEnable(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/web/service/RqueueDashboardChartService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.web.service; 18 | 19 | import com.github.sonus21.rqueue.models.request.ChartDataRequest; 20 | import com.github.sonus21.rqueue.models.response.ChartDataResponse; 21 | import reactor.core.publisher.Mono; 22 | 23 | public interface RqueueDashboardChartService { 24 | 25 | ChartDataResponse getDashboardChartData(ChartDataRequest chartDataRequest); 26 | 27 | Mono getReactiveDashBoardData(ChartDataRequest chartDataRequest); 28 | } 29 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/web/service/RqueueJobService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.web.service; 18 | 19 | import com.github.sonus21.rqueue.exception.ProcessingException; 20 | import com.github.sonus21.rqueue.models.response.DataViewResponse; 21 | import reactor.core.publisher.Mono; 22 | 23 | public interface RqueueJobService { 24 | 25 | DataViewResponse getJobs(String messageId) throws ProcessingException; 26 | 27 | Mono getReactiveJobs(String messageId) throws ProcessingException; 28 | } 29 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/web/service/RqueueSystemManagerService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.web.service; 18 | 19 | import com.github.sonus21.rqueue.models.db.QueueConfig; 20 | import com.github.sonus21.rqueue.models.event.RqueueBootstrapEvent; 21 | import com.github.sonus21.rqueue.models.response.BaseResponse; 22 | import java.util.Collection; 23 | import java.util.List; 24 | import org.springframework.context.ApplicationListener; 25 | import reactor.core.publisher.Mono; 26 | 27 | public interface RqueueSystemManagerService extends ApplicationListener { 28 | 29 | BaseResponse deleteQueue(String queueName); 30 | 31 | List getQueues(); 32 | 33 | List getQueueConfigs(Collection queues); 34 | 35 | List getQueueConfigs(); 36 | 37 | List getSortedQueueConfigs(); 38 | 39 | QueueConfig getQueueConfig(String queueName); 40 | 41 | Mono deleteReactiveQueue(String queueName); 42 | } 43 | -------------------------------------------------------------------------------- /rqueue-core/src/main/java/com/github/sonus21/rqueue/web/service/RqueueViewControllerService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.web.service; 18 | 19 | import org.springframework.ui.Model; 20 | 21 | public interface RqueueViewControllerService { 22 | 23 | void index(Model model, String forwardedFor); 24 | 25 | void queues(Model model, String xForwardedPrefix); 26 | 27 | void queueDetail(Model model, String xForwardedPrefix, String queueName); 28 | 29 | void running(Model model, String xForwardedPrefix); 30 | 31 | void scheduled(Model model, String xForwardedPrefix); 32 | 33 | void dead(Model model, String xForwardedPrefix); 34 | 35 | void pending(Model model, String xForwardedPrefix); 36 | 37 | void utility(Model model, String xForwardedPrefix); 38 | } 39 | -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/public/rqueue/img/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/rqueue-core/src/main/resources/public/rqueue/img/android-chrome-192x192.png -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/public/rqueue/img/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/rqueue-core/src/main/resources/public/rqueue/img/apple-touch-icon.png -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/public/rqueue/img/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/rqueue-core/src/main/resources/public/rqueue/img/favicon-16x16.png -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/public/rqueue/img/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/rqueue-core/src/main/resources/public/rqueue/img/favicon-32x32.png -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/public/rqueue/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/rqueue-core/src/main/resources/public/rqueue/img/favicon.ico -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/public/rqueue/vendor/boxicons/css/transformations.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | .bx-rotate-90 { 18 | transform: rotate(90deg); 19 | 20 | -ms-filter: 'progid:DXImageTransform.Microsoft.BasicImage(rotation=1)'; 21 | } 22 | 23 | .bx-rotate-180 { 24 | transform: rotate(180deg); 25 | 26 | -ms-filter: 'progid:DXImageTransform.Microsoft.BasicImage(rotation=2)'; 27 | } 28 | 29 | .bx-rotate-270 { 30 | transform: rotate(270deg); 31 | 32 | -ms-filter: 'progid:DXImageTransform.Microsoft.BasicImage(rotation=3)'; 33 | } 34 | 35 | .bx-flip-horizontal { 36 | transform: scaleX(-1); 37 | 38 | -ms-filter: 'progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)'; 39 | } 40 | 41 | .bx-flip-vertical { 42 | transform: scaleY(-1); 43 | 44 | -ms-filter: 'progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)'; 45 | } 46 | -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/public/rqueue/vendor/boxicons/fonts/boxicons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/rqueue-core/src/main/resources/public/rqueue/vendor/boxicons/fonts/boxicons.eot -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/public/rqueue/vendor/boxicons/fonts/boxicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/rqueue-core/src/main/resources/public/rqueue/vendor/boxicons/fonts/boxicons.ttf -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/public/rqueue/vendor/boxicons/fonts/boxicons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/rqueue-core/src/main/resources/public/rqueue/vendor/boxicons/fonts/boxicons.woff -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/public/rqueue/vendor/boxicons/fonts/boxicons.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sonus21/rqueue/f04317b2155b4bd43460536296a1f3c4f0a4f8be/rqueue-core/src/main/resources/public/rqueue/vendor/boxicons/fonts/boxicons.woff2 -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/rqueue/scripts/delete_if_same.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2021 Sonu Kumar 2 | -- 3 | -- Licensed under the Apache License, Version 2.0 (the "License"); 4 | -- you may not use this file except in compliance with the License. 5 | -- You may obtain a copy of the License at 6 | -- 7 | -- https://www.apache.org/licenses/LICENSE-2.0 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, software 10 | -- distributed under the License is distributed on an "AS IS" BASIS, 11 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | -- See the License for the specific language governing permissions and limitations under the License. 13 | -- 14 | 15 | -- get current value 16 | local value = redis.call('GET', KEYS[1]) 17 | if not value then 18 | return true 19 | end 20 | if value == ARGV[1] then 21 | local val = redis.call('DEL', KEYS[1]) 22 | if val == 1 then 23 | return true 24 | end 25 | end 26 | return false 27 | 28 | -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/rqueue/scripts/dequeue_message.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2021 Sonu Kumar 2 | -- 3 | -- Licensed under the Apache License, Version 2.0 (the "License"); 4 | -- you may not use this file except in compliance with the License. 5 | -- You may obtain a copy of the License at 6 | -- 7 | -- https://www.apache.org/licenses/LICENSE-2.0 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, software 10 | -- distributed under the License is distributed on an "AS IS" BASIS, 11 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | -- See the License for the specific language governing permissions and limitations under the License. 13 | -- 14 | 15 | -- get head of queue 16 | local values = redis.call('LRANGE', KEYS[1], 0, tonumber(ARGV[3]) - 1) 17 | 18 | if #values > 0 then 19 | for _, value in ipairs(values) do 20 | -- push to processing set 21 | redis.call('ZADD', KEYS[2], ARGV[2], value) 22 | -- remove from the queue 23 | redis.call('LPOP', KEYS[1]) 24 | end 25 | end ; 26 | 27 | --if elements with lower priority are on the head of processing queue 28 | local v = redis.call('ZRANGE', KEYS[2], 0, 0, 'WITHSCORES') 29 | if v[1] ~= nil and tonumber(v[2]) < tonumber(ARGV[1]) then 30 | redis.call('PUBLISH', KEYS[3], v[2]) 31 | end 32 | return values; -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/rqueue/scripts/enqueue_message.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2021 Sonu Kumar 2 | -- 3 | -- Licensed under the Apache License, Version 2.0 (the "License"); 4 | -- you may not use this file except in compliance with the License. 5 | -- You may obtain a copy of the License at 6 | -- 7 | -- https://www.apache.org/licenses/LICENSE-2.0 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, software 10 | -- distributed under the License is distributed on an "AS IS" BASIS, 11 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | -- See the License for the specific language governing permissions and limitations under the License. 13 | -- 14 | 15 | local count = redis.call('ZADD', KEYS[1], ARGV[2], ARGV[1]) 16 | --if elements with lower priority are on head 17 | local v = redis.call('ZRANGE', KEYS[1], 0, 0, 'WITHSCORES') 18 | if v[1] ~= nil and tonumber(v[2]) < tonumber(ARGV[3]) then 19 | redis.call('PUBLISH', KEYS[2], v[2]) 20 | end 21 | return count; -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/rqueue/scripts/move_message_list.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2021-2023 Sonu Kumar 2 | -- 3 | -- Licensed under the Apache License, Version 2.0 (the "License"); 4 | -- you may not use this file except in compliance with the License. 5 | -- You may obtain a copy of the License at 6 | -- 7 | -- https://www.apache.org/licenses/LICENSE-2.0 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, software 10 | -- distributed under the License is distributed on an "AS IS" BASIS, 11 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | -- See the License for the specific language governing permissions and limitations under the License. 13 | -- 14 | 15 | local score = redis.call('ZSCORE', KEYS[1], ARGV[1]) 16 | if score then 17 | redis.call('RPUSH', KEYS[2], ARGV[2]) 18 | redis.call('ZREM', KEYS[1], ARGV[1]) 19 | end 20 | score = tonumber(score) 21 | return score -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/rqueue/scripts/move_message_list_to_list.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2021-2023 Sonu Kumar 2 | -- 3 | -- Licensed under the Apache License, Version 2.0 (the "License"); 4 | -- you may not use this file except in compliance with the License. 5 | -- You may obtain a copy of the License at 6 | -- 7 | -- https://www.apache.org/licenses/LICENSE-2.0 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, software 10 | -- distributed under the License is distributed on an "AS IS" BASIS, 11 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | -- See the License for the specific language governing permissions and limitations under the License. 13 | -- 14 | 15 | for i = tonumber(ARGV[1]), 1, -1 16 | do 17 | local msg = redis.call('LRANGE', KEYS[1], 0, 0)[1] 18 | if msg ~= nil then 19 | redis.call("RPUSH", KEYS[2], msg) 20 | redis.call("LPOP", KEYS[1]) 21 | else 22 | break 23 | end 24 | end 25 | local remainingMessage = redis.call("LLEN", KEYS[1]) 26 | return remainingMessage 27 | 28 | -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/rqueue/scripts/move_message_list_to_zset.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2021-2023 Sonu Kumar 2 | -- 3 | -- Licensed under the Apache License, Version 2.0 (the "License"); 4 | -- you may not use this file except in compliance with the License. 5 | -- You may obtain a copy of the License at 6 | -- 7 | -- https://www.apache.org/licenses/LICENSE-2.0 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, software 10 | -- distributed under the License is distributed on an "AS IS" BASIS, 11 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | -- See the License for the specific language governing permissions and limitations under the License. 13 | -- 14 | 15 | for i = tonumber(ARGV[1]), 1, -1 16 | do 17 | local msg = redis.call('LRANGE', KEYS[1], 0, 0)[1] 18 | if msg ~= nil then 19 | redis.call("ZADD", KEYS[2], ARGV[2], msg) 20 | redis.call("LPOP", KEYS[1]) 21 | else 22 | break 23 | end 24 | end 25 | local remainingMessage = redis.call("LLEN", KEYS[1]) 26 | return remainingMessage 27 | 28 | -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/rqueue/scripts/move_message_zset.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2021-2023 Sonu Kumar 2 | -- 3 | -- Licensed under the Apache License, Version 2.0 (the "License"); 4 | -- you may not use this file except in compliance with the License. 5 | -- You may obtain a copy of the License at 6 | -- 7 | -- https://www.apache.org/licenses/LICENSE-2.0 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, software 10 | -- distributed under the License is distributed on an "AS IS" BASIS, 11 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | -- See the License for the specific language governing permissions and limitations under the License. 13 | -- 14 | 15 | local score = redis.call('ZSCORE', KEYS[1], ARGV[1]) 16 | if score then 17 | redis.call('ZADD', KEYS[2], ARGV[3], ARGV[2]) 18 | redis.call('ZREM', KEYS[1], ARGV[1]) 19 | end 20 | score = tonumber(score) 21 | return score -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/rqueue/scripts/move_message_zset_to_list.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2021-2023 Sonu Kumar 2 | -- 3 | -- Licensed under the Apache License, Version 2.0 (the "License"); 4 | -- you may not use this file except in compliance with the License. 5 | -- You may obtain a copy of the License at 6 | -- 7 | -- https://www.apache.org/licenses/LICENSE-2.0 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, software 10 | -- distributed under the License is distributed on an "AS IS" BASIS, 11 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | -- See the License for the specific language governing permissions and limitations under the License. 13 | -- 14 | 15 | for i = tonumber(ARGV[1]), 1, -1 16 | do 17 | local msg = redis.call('ZRANGE', KEYS[1], 0, 0, 'WITHSCORES')[1] 18 | if msg ~= nil then 19 | redis.call('RPUSH', KEYS[2], msg) 20 | redis.call('ZREM', KEYS[1], msg) 21 | else 22 | break 23 | end 24 | end 25 | local size = redis.call('ZCARD', KEYS[1]) 26 | return size -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/rqueue/scripts/move_message_zset_to_zset.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2021-2023 Sonu Kumar 2 | -- 3 | -- Licensed under the Apache License, Version 2.0 (the "License"); 4 | -- you may not use this file except in compliance with the License. 5 | -- You may obtain a copy of the License at 6 | -- 7 | -- https://www.apache.org/licenses/LICENSE-2.0 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, software 10 | -- distributed under the License is distributed on an "AS IS" BASIS, 11 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | -- See the License for the specific language governing permissions and limitations under the License. 13 | -- 14 | 15 | local srcValues = redis.call('ZRANGE', KEYS[1], 0, ARGV[1]) 16 | if #srcValues > 0 then 17 | local delta = tonumber(ARGV[2]) 18 | local op = tonumber(ARGV[3]) 19 | for existing_score, v in ipairs(srcValues) do 20 | local score = delta 21 | if op == 0 then 22 | score = score + existing_score 23 | end 24 | redis.call('ZADD', KEYS[2], score, v) 25 | end 26 | redis.call('ZREM', KEYS[1], unpack(srcValues)) 27 | end ; 28 | local size = redis.call('ZCARD', KEYS[1]) 29 | return size -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/rqueue/scripts/schedule_message.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2021-2023 Sonu Kumar 2 | -- 3 | -- Licensed under the Apache License, Version 2.0 (the "License"); 4 | -- you may not use this file except in compliance with the License. 5 | -- You may obtain a copy of the License at 6 | -- 7 | -- https://www.apache.org/licenses/LICENSE-2.0 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, software 10 | -- distributed under the License is distributed on an "AS IS" BASIS, 11 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | -- See the License for the specific language governing permissions and limitations under the License. 13 | -- 14 | 15 | -- get current value 16 | local value = redis.call('GET', KEYS[1]) 17 | if value then 18 | return 0 19 | end 20 | redis.call('SET', KEYS[1], '1', 'EX', ARGV[1]) 21 | redis.call('ZADD', KEYS[2], ARGV[3], ARGV[2]) 22 | return 1 23 | -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/rqueue/scripts/score_updater.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2021-2023 Sonu Kumar 2 | -- 3 | -- Licensed under the Apache License, Version 2.0 (the "License"); 4 | -- you may not use this file except in compliance with the License. 5 | -- You may obtain a copy of the License at 6 | -- 7 | -- https://www.apache.org/licenses/LICENSE-2.0 8 | -- 9 | -- Unless required by applicable law or agreed to in writing, software 10 | -- distributed under the License is distributed on an "AS IS" BASIS, 11 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | -- See the License for the specific language governing permissions and limitations under the License. 13 | -- 14 | 15 | local score = redis.call('ZSCORE', KEYS[1], ARGV[1]) 16 | if score then 17 | redis.call('ZADD', KEYS[1], tonumber(ARGV[2]) + tonumber(score), ARGV[1]) 18 | return true 19 | end 20 | return false -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/templates/rqueue/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'base' %} 2 | {% block main %} 3 | {% include 'stats_chart' %} 4 | 19 | 20 |


21 | {% include 'latency_chart' %} 22 | {% endblock %} 23 | 24 | {% block additional_script %} 25 | 40 | {% endblock %} 41 | 42 | -------------------------------------------------------------------------------- /rqueue-core/src/main/resources/templates/rqueue/running.html: -------------------------------------------------------------------------------- 1 | {% extends 'base' %} 2 | {% block main %} 3 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | {% for h in header %} 25 | 26 | {% endfor %} 27 | 28 | 29 | 30 | {% for task in tasks %} 31 | 32 | {% for td in task %} 33 | 34 | {% endfor %} 35 | 36 | {% endfor %} 37 | 38 |
{{h}}
{{td}}
39 |
40 |
41 | {% endblock %} -------------------------------------------------------------------------------- /rqueue-core/src/test/java/com/github/sonus21/rqueue/CoreUnitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue; 18 | 19 | import com.github.sonus21.junit.TestTracerExtension; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | import org.junit.jupiter.api.Tag; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | import org.mockito.junit.jupiter.MockitoExtension; 27 | 28 | 29 | @Target({ElementType.TYPE}) 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Tag("unit") 32 | @Tag("core") 33 | @ExtendWith({MockitoExtension.class, TestTracerExtension.class}) 34 | public @interface CoreUnitTest { 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /rqueue-core/src/test/java/com/github/sonus21/rqueue/listener/RqueueMessagePollerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.listener; 18 | 19 | import com.github.sonus21.TestBase; 20 | import com.github.sonus21.rqueue.CoreUnitTest; 21 | import org.junit.jupiter.api.BeforeEach; 22 | 23 | @CoreUnitTest 24 | class RqueueMessagePollerTest extends TestBase { 25 | // DefaultRqueuePoller poller = new DefaultRqueuePoller(); 26 | 27 | @BeforeEach 28 | void setUp() { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /rqueue-core/src/test/java/com/github/sonus21/rqueue/utils/HttpUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.utils; 18 | 19 | import static org.junit.jupiter.api.Assertions.assertEquals; 20 | 21 | import com.github.sonus21.TestBase; 22 | import com.github.sonus21.rqueue.CoreUnitTest; 23 | import org.junit.jupiter.api.Test; 24 | 25 | @CoreUnitTest 26 | class HttpUtilsTest extends TestBase { 27 | 28 | @Test 29 | void joinPath() { 30 | assertEquals("/", HttpUtils.joinPath(null, null)); 31 | assertEquals("/", HttpUtils.joinPath(null, "/")); 32 | assertEquals("/foo/", HttpUtils.joinPath(null, "/foo")); 33 | assertEquals("/foo/bar/", HttpUtils.joinPath(null, "/foo/", "/bar")); 34 | assertEquals("/foo/bar/", HttpUtils.joinPath("/foo/", null, "/bar")); 35 | assertEquals("/foo/bar/", HttpUtils.joinPath("/foo/", "/", "/bar")); 36 | assertEquals("/foo/bar/", HttpUtils.joinPath("foo", "/", "bar")); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /rqueue-core/src/test/java/com/github/sonus21/rqueue/utils/RqueueMessageTestUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.utils; 18 | 19 | import com.github.sonus21.rqueue.core.DefaultRqueueMessageConverter; 20 | import com.github.sonus21.rqueue.core.RqueueMessage; 21 | import com.github.sonus21.rqueue.core.support.RqueueMessageUtils; 22 | import lombok.AccessLevel; 23 | import lombok.NoArgsConstructor; 24 | import org.springframework.messaging.converter.MessageConverter; 25 | 26 | @NoArgsConstructor(access = AccessLevel.PRIVATE) 27 | public class RqueueMessageTestUtils { 28 | 29 | public static RqueueMessage createMessage(String queueName) { 30 | return createMessage(new DefaultRqueueMessageConverter(), queueName); 31 | } 32 | 33 | 34 | public static RqueueMessage createMessage(MessageConverter messageConverter, String queue) { 35 | return RqueueMessageUtils.generateMessage(messageConverter, queue); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /rqueue-spring-boot-example/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM tomcat:8.0.51-jre8-alpine 2 | RUN rm -rf /usr/local/tomcat/webapps/* 3 | ARG WAR_FILE=build/libs/*.war 4 | COPY ${WAR_FILE} /usr/local/tomcat/webapps/ROOT.war 5 | CMD ["catalina.sh","run"] -------------------------------------------------------------------------------- /rqueue-spring-boot-example/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "org.springframework.boot" version "${springBootVersion}" 3 | id "io.spring.dependency-management" version "${springDepManagementVersion}" 4 | id "war" 5 | } 6 | dependencies { 7 | implementation project(":rqueue-spring-boot-starter") 8 | implementation "org.springframework.boot:spring-boot-starter-data-redis" 9 | implementation "org.springframework.boot:spring-boot-starter-web" 10 | // https://mvnrepository.com/artifact/ch.qos.logback/logback-core 11 | implementation "ch.qos.logback:logback-core:${logbackVersion}" 12 | // https://mvnrepository.com/artifact/ch.qos.logback/logback-classic 13 | implementation "ch.qos.logback:logback-classic:${logbackVersion}" 14 | implementation "io.lettuce:lettuce-core" 15 | annotationProcessor "org.springframework.boot:spring-boot-configuration-processor" 16 | providedRuntime "org.springframework.boot:spring-boot-starter-tomcat" 17 | } 18 | -------------------------------------------------------------------------------- /rqueue-spring-boot-example/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | prometheus: 4 | ports: 5 | - "9090:9090" 6 | volumes: 7 | - ./prometheus.yml:/etc/prometheus/prometheus.yml 8 | image: prom/prometheus 9 | 10 | grafana: 11 | ports: 12 | - "3000:3000" 13 | image: grafana/grafana 14 | 15 | redis: 16 | ports: 17 | - "6379:6379" 18 | image: redis 19 | rqueue: 20 | container_name: rqueue 21 | build: 22 | dockerfile: Dockerfile 23 | context: . 24 | environment: 25 | - spring.data.redis.host=redis 26 | ports: 27 | - "8080:8080" 28 | image: rqueue 29 | depends_on: 30 | - redis 31 | - prometheus 32 | - grafana 33 | 34 | -------------------------------------------------------------------------------- /rqueue-spring-boot-example/prometheus.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 15s 3 | 4 | scrape_configs: 5 | - job_name: 'prometheus' 6 | scrape_interval: 10s 7 | scrape_timeout: 5s 8 | metrics_path: '/actuator/prometheus' 9 | static_configs: 10 | - targets: [ 'rqueue:8080' ] 11 | -------------------------------------------------------------------------------- /rqueue-spring-boot-example/src/main/java/com/github/sonus21/rqueue/example/Job.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.example; 18 | 19 | import lombok.Getter; 20 | import lombok.Setter; 21 | import lombok.ToString; 22 | 23 | @Getter 24 | @Setter 25 | @ToString 26 | public class Job { 27 | 28 | private String id; 29 | private String message; 30 | private String messageId; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /rqueue-spring-boot-example/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2019-2023 Sonu Kumar 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # You may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and limitations under the License. 14 | # 15 | # 16 | spring.data.redis.database=0 17 | spring.data.redis.host=localhost 18 | spring.data.redis.port=6379 19 | rqueue.simple.queue=simple-queue 20 | rqueue.delay.queue=delay-queue 21 | rqueue.delay.queue.scheduled-queue=true 22 | rqueue.delay.queue.retries=3 23 | rqueue.delay2.queue=delay-queue2 24 | job.fail.percentage=30 25 | job.execution.interval=2000 26 | # Enable prometheus exporter 27 | rqueue.metrics.tags.suite=JMeter 28 | rqueue.metrics.count.failure=true 29 | rqueue.metrics.count.execution=true 30 | management.prometheus.metrics.export.enabled=true 31 | management.endpoints.web.exposure.include=* 32 | management.endpoint.beans.enabled=true 33 | management.endpoint.health.enabled=true 34 | rqueue.scheduler.scheduled.message.time.interval=5000 35 | workers.count=100 36 | scale.enabled=true 37 | -------------------------------------------------------------------------------- /rqueue-spring-boot-reactive-example/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "org.springframework.boot" version "${springBootVersion}" 3 | id "io.spring.dependency-management" version "${springDepManagementVersion}" 4 | id "war" 5 | } 6 | dependencies { 7 | implementation project(":rqueue-spring-boot-starter") 8 | implementation "org.springframework.boot:spring-boot-starter-data-redis-reactive" 9 | implementation "org.springframework.boot:spring-boot-starter-webflux" 10 | implementation "io.lettuce:lettuce-core" 11 | // https://mvnrepository.com/artifact/ch.qos.logback/logback-core 12 | implementation "ch.qos.logback:logback-core:${logbackVersion}" 13 | // https://mvnrepository.com/artifact/ch.qos.logback/logback-classic 14 | implementation "ch.qos.logback:logback-classic:${logbackVersion}" 15 | } 16 | -------------------------------------------------------------------------------- /rqueue-spring-boot-reactive-example/src/main/java/com/github/sonus21/task/executor/Job.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.task.executor; 18 | 19 | public class Job { 20 | 21 | private String id; 22 | private String message; 23 | 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | public void setId(String id) { 29 | this.id = id; 30 | } 31 | 32 | public String getMessage() { 33 | return message; 34 | } 35 | 36 | public void setMessage(String message) { 37 | this.message = message; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "Job[id=" + id + " , message=" + message + "]"; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /rqueue-spring-boot-reactive-example/src/main/java/com/github/sonus21/task/executor/WebFluxConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.task.executor; 18 | 19 | import org.springframework.context.annotation.Configuration; 20 | import org.springframework.web.reactive.config.EnableWebFlux; 21 | import org.springframework.web.reactive.config.ResourceHandlerRegistry; 22 | import org.springframework.web.reactive.config.WebFluxConfigurer; 23 | 24 | @EnableWebFlux 25 | @Configuration 26 | public class WebFluxConfig implements WebFluxConfigurer { 27 | 28 | @Override 29 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 30 | if (!registry.hasMappingForPattern("/**")) { 31 | registry.addResourceHandler("/**").addResourceLocations("classpath:/public/"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /rqueue-spring-boot-reactive-example/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2021-2023 Sonu Kumar 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # You may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # https://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and limitations under the License. 14 | # 15 | # 16 | spring.data.redis.database=0 17 | spring.data.redis.host=localhost 18 | spring.data.redis.port=6379 19 | rqueue.simple.queue=simple-queue 20 | rqueue.delay.queue=delay-queue 21 | rqueue.delay.queue.scheduled-queue=true 22 | rqueue.delay.queue.retries=3 23 | rqueue.delay2.queue=delay-queue2 24 | delay.queue.fail.percentage=30 25 | # Enable prometheus exporter 26 | rqueue.metrics.tags.suite=JMeter 27 | rqueue.metrics.count.failure=true 28 | rqueue.metrics.count.execution=true 29 | management.prometheus.metrics.export.enabled=true 30 | management.endpoints.web.exposure.include=* 31 | management.endpoint.beans.enabled=true 32 | management.endpoint.health.enabled=true 33 | rqueue.scheduler.scheduled.message.time.interval=5000 34 | workers.count=5 35 | spring.main.web-application-type=reactive 36 | rqueue.reactive.enabled=true -------------------------------------------------------------------------------- /rqueue-spring-boot-reactive-example/src/test/java/com/github/sonus21/task/executor/RqueueReactiveTaskExecutorApplicationTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.task.executor; 18 | 19 | import org.junit.jupiter.api.Test; 20 | import org.springframework.boot.test.context.SpringBootTest; 21 | 22 | @SpringBootTest 23 | class RqueueReactiveTaskExecutorApplicationTests { 24 | 25 | @Test 26 | void contextLoads() { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /rqueue-spring-boot-starter/build.gradle: -------------------------------------------------------------------------------- 1 | ext.projectDescription = "Asynchronous and Scheduled task executor for spring boot framework" 2 | ext.name = "Rqueue Spring Boot Java" 3 | buildscript { 4 | apply from: "${rootDir}/gradle/code-signing.gradle" 5 | apply from: "${rootDir}/gradle/packaging.gradle" 6 | apply from: "${rootDir}/gradle/test-runner.gradle" 7 | } 8 | 9 | dependencies { 10 | api project(":rqueue-core") 11 | api "org.springframework.boot:spring-boot-starter-data-redis:${springBootVersion}" 12 | // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator 13 | api "org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}", optional 14 | testImplementation project(":rqueue-spring-common-test") 15 | testImplementation "org.springframework.boot:spring-boot-starter-test:${springBootVersion}" 16 | testImplementation "org.springframework.boot:spring-boot-starter-webflux:${springBootVersion}" 17 | testImplementation "org.springframework.boot:spring-boot-starter-data-redis-reactive:${springBootVersion}" 18 | testImplementation "org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}" 19 | testImplementation "org.springframework.boot:spring-boot-devtools:${springBootVersion}" 20 | } 21 | -------------------------------------------------------------------------------- /rqueue-spring-boot-starter/src/main/java/com/github/sonus21/rqueue/spring/boot/RqueueMetricsProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.spring.boot; 18 | 19 | import com.github.sonus21.rqueue.config.MetricsProperties; 20 | import org.springframework.boot.context.properties.ConfigurationProperties; 21 | import org.springframework.context.annotation.Configuration; 22 | 23 | @Configuration 24 | @ConfigurationProperties(prefix = "rqueue.metrics") 25 | public class RqueueMetricsProperties extends MetricsProperties { 26 | 27 | } 28 | -------------------------------------------------------------------------------- /rqueue-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | com.github.sonus21.rqueue.spring.boot.RqueueListenerAutoConfig 2 | com.github.sonus21.rqueue.spring.boot.RqueueMetricsAutoConfig -------------------------------------------------------------------------------- /rqueue-spring-boot-starter/src/test/java/com/github/sonus21/rqueue/spring/boot/application/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.spring.boot.application; 18 | 19 | import com.github.sonus21.rqueue.test.application.BaseApplication; 20 | import org.springframework.boot.SpringApplication; 21 | import org.springframework.boot.autoconfigure.SpringBootApplication; 22 | import org.springframework.context.annotation.PropertySource; 23 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 24 | import org.springframework.transaction.annotation.EnableTransactionManagement; 25 | 26 | @PropertySource("classpath:application.properties") 27 | @SpringBootApplication(scanBasePackages = {"com.github.sonus21.rqueue.test"}) 28 | @EnableJpaRepositories(basePackages = {"com.github.sonus21.rqueue.test.repository"}) 29 | @EnableTransactionManagement 30 | public class Application extends BaseApplication { 31 | 32 | public static void main(String[] args) { 33 | SpringApplication.run(Application.class, args); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /rqueue-spring-boot-starter/src/test/java/com/github/sonus21/rqueue/spring/boot/reactive/WebFluxConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.spring.boot.reactive; 18 | 19 | import org.springframework.context.annotation.Configuration; 20 | import org.springframework.web.reactive.config.EnableWebFlux; 21 | import org.springframework.web.reactive.config.ResourceHandlerRegistry; 22 | import org.springframework.web.reactive.config.WebFluxConfigurer; 23 | 24 | @EnableWebFlux 25 | @Configuration 26 | public class WebFluxConfig implements WebFluxConfigurer { 27 | 28 | @Override 29 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 30 | if (!registry.hasMappingForPattern("/**")) { 31 | registry.addResourceHandler("/**").addResourceLocations("classpath:/public/"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /rqueue-spring-boot-starter/src/test/java/com/github/sonus21/rqueue/spring/boot/tests/SpringBootIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.spring.boot.tests; 18 | 19 | import com.github.sonus21.junit.TestTracerExtension; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | import org.junit.jupiter.api.Tag; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | 27 | @Target({ElementType.TYPE}) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Tag("springBootIntegration") 30 | @Tag("integration") 31 | @Tag("springBoot") 32 | @ExtendWith({TestTracerExtension.class}) 33 | public @interface SpringBootIntegrationTest { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /rqueue-spring-boot-starter/src/test/java/com/github/sonus21/rqueue/spring/boot/tests/SpringBootUnitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.spring.boot.tests; 18 | 19 | import com.github.sonus21.junit.TestTracerExtension; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | import org.junit.jupiter.api.Tag; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | import org.mockito.junit.jupiter.MockitoExtension; 27 | 28 | @Target({ElementType.TYPE}) 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Tag("springBoot") 31 | @Tag("unit") 32 | @Tag("springBootUnit") 33 | @ExtendWith({MockitoExtension.class, TestTracerExtension.class}) 34 | public @interface SpringBootUnitTest { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | implementation project(":rqueue-core") 3 | api project(":rqueue-test-util") 4 | // https://mvnrepository.com/artifact/io.micrometer/micrometer-registry-prometheus 5 | api "io.micrometer:micrometer-registry-prometheus:${microMeterVersion}" 6 | api "io.projectreactor:reactor-test:${projectReactorReactorTestVersion}" 7 | } 8 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/DeleteMessageListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test; 18 | 19 | import com.github.sonus21.rqueue.core.Job; 20 | import com.github.sonus21.rqueue.core.support.MessageProcessor; 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | public class DeleteMessageListener implements MessageProcessor { 25 | 26 | private List messages = new ArrayList<>(); 27 | 28 | @Override 29 | public boolean process(Job message) { 30 | messages.add(message.getMessage()); 31 | return true; 32 | } 33 | 34 | public List getMessages() { 35 | return messages; 36 | } 37 | 38 | public void clear() { 39 | this.messages = new ArrayList<>(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/PauseUnpauseEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test; 18 | 19 | import com.github.sonus21.rqueue.models.event.RqueueQueuePauseEvent; 20 | import java.util.LinkedList; 21 | import java.util.List; 22 | import lombok.Getter; 23 | import org.springframework.context.ApplicationListener; 24 | import org.springframework.stereotype.Component; 25 | 26 | @Component 27 | @Getter 28 | public class PauseUnpauseEventListener implements ApplicationListener { 29 | 30 | private final List eventList = new LinkedList<>(); 31 | 32 | @Override 33 | public void onApplicationEvent(RqueueQueuePauseEvent event) { 34 | eventList.add(event); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/dto/BaseQueueMessage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.dto; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.Setter; 24 | import lombok.ToString; 25 | 26 | @Getter 27 | @Setter 28 | @AllArgsConstructor 29 | @ToString 30 | @EqualsAndHashCode(callSuper = false) 31 | @NoArgsConstructor 32 | public abstract class BaseQueueMessage { 33 | 34 | private String id; 35 | } 36 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/dto/ChatIndexing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.dto; 18 | 19 | import java.util.UUID; 20 | import lombok.AllArgsConstructor; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | import lombok.Setter; 25 | import lombok.ToString; 26 | import org.apache.commons.lang3.RandomUtils; 27 | 28 | @AllArgsConstructor 29 | @NoArgsConstructor 30 | @Getter 31 | @Setter 32 | @ToString 33 | @EqualsAndHashCode(callSuper = true) 34 | public class ChatIndexing extends BaseQueueMessage { 35 | 36 | private int userId; 37 | private Long timestamp; 38 | 39 | public static ChatIndexing newInstance() { 40 | ChatIndexing chatIndexing = 41 | new ChatIndexing(RandomUtils.nextInt(100000, 1000000), System.currentTimeMillis()); 42 | chatIndexing.setId(UUID.randomUUID().toString()); 43 | return chatIndexing; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/dto/FeedGeneration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.dto; 18 | 19 | import java.util.UUID; 20 | import lombok.AllArgsConstructor; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | import lombok.Setter; 25 | import lombok.ToString; 26 | import org.apache.commons.lang3.RandomUtils; 27 | 28 | @Getter 29 | @Setter 30 | @AllArgsConstructor 31 | @NoArgsConstructor 32 | @ToString 33 | @EqualsAndHashCode(callSuper = true) 34 | public class FeedGeneration extends BaseQueueMessage { 35 | 36 | private int userId; 37 | private Long timestamp; 38 | 39 | public static FeedGeneration newInstance() { 40 | FeedGeneration feedGeneration = 41 | new FeedGeneration(RandomUtils.nextInt(1000, 1000000), System.currentTimeMillis()); 42 | feedGeneration.setId(UUID.randomUUID().toString()); 43 | return feedGeneration; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/dto/LongRunningJob.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.dto; 18 | 19 | import java.util.UUID; 20 | import lombok.AllArgsConstructor; 21 | import lombok.Data; 22 | import lombok.EqualsAndHashCode; 23 | import lombok.NoArgsConstructor; 24 | 25 | @Data 26 | @NoArgsConstructor 27 | @EqualsAndHashCode(callSuper = true) 28 | @AllArgsConstructor 29 | public class LongRunningJob extends BaseQueueMessage { 30 | 31 | private long runTime; 32 | 33 | public static LongRunningJob newInstance(long runTime) { 34 | LongRunningJob longRunningJob = new LongRunningJob(runTime); 35 | longRunningJob.setId(UUID.randomUUID().toString()); 36 | return longRunningJob; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/dto/OrderConfirmation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.dto; 18 | 19 | import java.util.UUID; 20 | import lombok.AllArgsConstructor; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | import lombok.Setter; 25 | import lombok.ToString; 26 | 27 | @AllArgsConstructor 28 | @NoArgsConstructor 29 | @Getter 30 | @Setter 31 | @ToString 32 | @EqualsAndHashCode(callSuper = true) 33 | public class OrderConfirmation extends BaseQueueMessage { 34 | 35 | private String orderId; 36 | private String userId; 37 | private long timestamp; 38 | 39 | public static OrderConfirmation newInstance() { 40 | OrderConfirmation orderConfirmation = 41 | new OrderConfirmation( 42 | UUID.randomUUID().toString(), UUID.randomUUID().toString(), System.currentTimeMillis()); 43 | orderConfirmation.setId(UUID.randomUUID().toString()); 44 | return orderConfirmation; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/dto/PeriodicJob.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.dto; 18 | 19 | import java.util.UUID; 20 | import lombok.Data; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.NoArgsConstructor; 23 | import org.apache.commons.lang3.RandomStringUtils; 24 | 25 | @Data 26 | @NoArgsConstructor 27 | @EqualsAndHashCode(callSuper = true) 28 | public class PeriodicJob extends BaseQueueMessage { 29 | 30 | private String jobName; 31 | private int executionTime; 32 | 33 | public static PeriodicJob newInstance() { 34 | PeriodicJob job = new PeriodicJob(); 35 | job.setId(UUID.randomUUID().toString()); 36 | job.setJobName(RandomStringUtils.randomAlphabetic(10)); 37 | job.setExecutionTime(1 + (int) (Math.random() * 5)); 38 | return job; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/dto/ReservationRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.dto; 18 | 19 | import java.util.UUID; 20 | import lombok.EqualsAndHashCode; 21 | import lombok.Getter; 22 | import lombok.NoArgsConstructor; 23 | import lombok.Setter; 24 | import lombok.ToString; 25 | 26 | @NoArgsConstructor 27 | @Getter 28 | @Setter 29 | @ToString(callSuper = true) 30 | @EqualsAndHashCode(callSuper = true) 31 | public class ReservationRequest extends BaseQueueMessage { 32 | 33 | public static ReservationRequest newInstance() { 34 | ReservationRequest reservationRequest = new ReservationRequest(); 35 | reservationRequest.setId(UUID.randomUUID().toString()); 36 | return reservationRequest; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/dto/Sms.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.dto; 18 | 19 | import java.util.UUID; 20 | import lombok.AllArgsConstructor; 21 | import lombok.EqualsAndHashCode; 22 | import lombok.Getter; 23 | import lombok.NoArgsConstructor; 24 | import lombok.Setter; 25 | import lombok.ToString; 26 | import org.apache.commons.lang3.RandomStringUtils; 27 | 28 | @AllArgsConstructor 29 | @NoArgsConstructor 30 | @Getter 31 | @Setter 32 | @ToString 33 | @EqualsAndHashCode(callSuper = true) 34 | public class Sms extends BaseQueueMessage { 35 | 36 | private String phoneNumber; 37 | private String sms; 38 | 39 | public static Sms newInstance() { 40 | String txt = "Dear Dev, Version 2.0 of Rqueue is released."; 41 | Sms sms = new Sms("+91" + RandomStringUtils.randomNumeric(10), txt); 42 | sms.setId(UUID.randomUUID().toString()); 43 | return sms; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/dto/UserBanned.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.dto; 18 | 19 | import com.github.sonus21.RandomUtils; 20 | import java.util.UUID; 21 | import lombok.AllArgsConstructor; 22 | import lombok.Data; 23 | import lombok.EqualsAndHashCode; 24 | import lombok.NoArgsConstructor; 25 | import lombok.ToString; 26 | 27 | @AllArgsConstructor 28 | @NoArgsConstructor 29 | @Data 30 | @EqualsAndHashCode(callSuper = true) 31 | @ToString(callSuper = true) 32 | public class UserBanned extends BaseQueueMessage { 33 | 34 | private Integer userId; 35 | 36 | public static UserBanned newInstance() { 37 | UserBanned userBanned = new UserBanned(RandomUtils.random.nextInt()); 38 | userBanned.setId(UUID.randomUUID().toString()); 39 | return userBanned; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/entity/FailureDetail.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.entity; 18 | 19 | import jakarta.persistence.Column; 20 | import jakarta.persistence.Entity; 21 | import jakarta.persistence.Id; 22 | import lombok.AllArgsConstructor; 23 | import lombok.Getter; 24 | import lombok.NoArgsConstructor; 25 | import lombok.Setter; 26 | 27 | @Getter 28 | @Setter 29 | @AllArgsConstructor 30 | @NoArgsConstructor 31 | @Entity 32 | public class FailureDetail { 33 | 34 | @Id 35 | private String id; 36 | // if minFailureCount is -1 then fail always 37 | @Column 38 | private int minFailureCount; 39 | @Column 40 | private int maxFailureCount; 41 | @Column 42 | private int failureCount; 43 | } 44 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/repository/ConsumedMessageRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.repository; 18 | 19 | import com.github.sonus21.rqueue.test.entity.ConsumedMessage; 20 | import java.util.Collection; 21 | import java.util.List; 22 | import org.springframework.data.repository.CrudRepository; 23 | 24 | public interface ConsumedMessageRepository extends CrudRepository { 25 | 26 | List findByQueueName(String queueName); 27 | 28 | List findByMessageId(String messageId); 29 | 30 | List findByMessageIdIn(Collection messageIds); 31 | 32 | ConsumedMessage findByMessageIdAndTag(String messageId, String tag); 33 | 34 | void deleteAllByIdIn(Collection ids); 35 | } 36 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/repository/FailureDetailRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.repository; 18 | 19 | import com.github.sonus21.rqueue.test.entity.FailureDetail; 20 | import org.springframework.data.repository.CrudRepository; 21 | 22 | public interface FailureDetailRepository extends CrudRepository { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/service/RqueueEventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | package com.github.sonus21.rqueue.test.service; 17 | 18 | import com.github.sonus21.rqueue.models.event.RqueueExecutionEvent; 19 | import java.util.Queue; 20 | import java.util.concurrent.ConcurrentLinkedQueue; 21 | import org.springframework.context.event.EventListener; 22 | import org.springframework.stereotype.Component; 23 | 24 | @Component 25 | public class RqueueEventListener { 26 | 27 | private Queue executionEvents = new ConcurrentLinkedQueue<>(); 28 | 29 | public void clearQueue() { 30 | executionEvents.clear(); 31 | } 32 | 33 | public int getEventCount() { 34 | return executionEvents.size(); 35 | } 36 | 37 | @EventListener 38 | public void listen(RqueueExecutionEvent event) { 39 | executionEvents.add(event); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /rqueue-spring-common-test/src/main/java/com/github/sonus21/rqueue/test/util/TestMessageConverterProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.test.util; 18 | 19 | import com.github.sonus21.rqueue.converter.MessageConverterProvider; 20 | import org.springframework.messaging.converter.MappingJackson2MessageConverter; 21 | import org.springframework.messaging.converter.MessageConverter; 22 | 23 | public class TestMessageConverterProvider implements MessageConverterProvider { 24 | 25 | @Override 26 | public MessageConverter getConverter() { 27 | return new MappingJackson2MessageConverter(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /rqueue-spring-example/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "application" 3 | } 4 | 5 | mainClassName = "rqueue.spring.example.Main" 6 | 7 | 8 | dependencies { 9 | implementation project(":rqueue-spring") 10 | implementation project(":rqueue-spring-common-test") 11 | // https://mvnrepository.com/artifact/io.lettuce/lettuce-core 12 | implementation "io.lettuce:lettuce-core:${lettuceVersion}" 13 | // https://mvnrepository.com/artifact/org.slf4j/slf4j-simple 14 | implementation "org.slf4j:slf4j-simple:${sl4jVersion}" 15 | implementation "org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}" 16 | // https://mvnrepository.com/artifact/io.micrometer/micrometer-registry-prometheus 17 | implementation "io.micrometer:micrometer-registry-prometheus:${microMeterVersion}" 18 | } 19 | -------------------------------------------------------------------------------- /rqueue-spring-example/src/main/java/rqueue/spring/example/AppInitializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package rqueue.spring.example; 18 | 19 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 20 | 21 | public class AppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 22 | 23 | @Override 24 | protected Class[] getRootConfigClasses() { 25 | return new Class[]{AppConfig.class}; 26 | } 27 | 28 | @Override 29 | protected Class[] getServletConfigClasses() { 30 | return null; 31 | } 32 | 33 | @Override 34 | protected String[] getServletMappings() { 35 | return new String[]{"/"}; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /rqueue-spring-example/src/main/java/rqueue/spring/example/Job.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package rqueue.spring.example; 18 | 19 | public class Job { 20 | 21 | private String id; 22 | private String message; 23 | 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | public void setId(String id) { 29 | this.id = id; 30 | } 31 | 32 | public String getMessage() { 33 | return message; 34 | } 35 | 36 | public void setMessage(String message) { 37 | this.message = message; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "Job[id=" + id + " , message=" + message + "]"; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /rqueue-spring/build.gradle: -------------------------------------------------------------------------------- 1 | ext.projectDescription = "Asynchronous and Scheduled task executor for spring framework" 2 | ext.name = "Rqueue Spring Java" 3 | buildscript { 4 | apply from: "${rootDir}/gradle/code-signing.gradle" 5 | apply from: "${rootDir}/gradle/packaging.gradle" 6 | apply from: "${rootDir}/gradle/test-runner.gradle" 7 | } 8 | 9 | dependencies { 10 | api project(":rqueue-core") 11 | testImplementation project(":rqueue-spring-common-test") 12 | } 13 | -------------------------------------------------------------------------------- /rqueue-spring/src/main/java/com/github/sonus21/rqueue/spring/MetricsEnabled.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.spring; 18 | 19 | import org.springframework.context.annotation.Condition; 20 | import org.springframework.context.annotation.ConditionContext; 21 | import org.springframework.core.type.AnnotatedTypeMetadata; 22 | import org.springframework.util.ClassUtils; 23 | 24 | /** 25 | * Checks whether MeterRegistry bean is present it or not. if MeterRegistry bean is founds then it's 26 | * assumed that Metric feature is enables. It's essential to restrict the bean creation otherwise 27 | * can lead to error in bootstrap process. 28 | */ 29 | public class MetricsEnabled implements Condition { 30 | 31 | @Override 32 | public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { 33 | return ClassUtils.isPresent( 34 | "io.micrometer.core.instrument.MeterRegistry", context.getClassLoader()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /rqueue-spring/src/main/java/com/github/sonus21/rqueue/spring/RqueueMetricsProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.spring; 18 | 19 | import com.github.sonus21.rqueue.config.MetricsProperties; 20 | import org.springframework.context.annotation.Configuration; 21 | 22 | @Configuration 23 | public class RqueueMetricsProperties extends MetricsProperties { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /rqueue-spring/src/test/java/com/github/sonus21/rqueue/spring/tests/SpringIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.spring.tests; 18 | 19 | import com.github.sonus21.junit.TestTracerExtension; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | import org.junit.jupiter.api.Tag; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | 27 | @Target({ElementType.TYPE}) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Tag("springIntegration") 30 | @Tag("integration") 31 | @Tag("spring") 32 | @ExtendWith(TestTracerExtension.class) 33 | public @interface SpringIntegrationTest { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /rqueue-spring/src/test/java/com/github/sonus21/rqueue/spring/tests/SpringUnitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.rqueue.spring.tests; 18 | 19 | import com.github.sonus21.junit.TestTracerExtension; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | import org.junit.jupiter.api.Tag; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | import org.mockito.junit.jupiter.MockitoExtension; 27 | 28 | @Target({ElementType.TYPE}) 29 | @Retention(RetentionPolicy.RUNTIME) 30 | @Tag("spring") 31 | @Tag("unit") 32 | @Tag("springUnit") 33 | @ExtendWith({MockitoExtension.class, TestTracerExtension.class}) 34 | public @interface SpringUnitTest { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /rqueue-test-util/src/main/java/com/github/sonus21/AtomicValueHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.NoArgsConstructor; 21 | 22 | @AllArgsConstructor 23 | @NoArgsConstructor 24 | public class AtomicValueHolder { 25 | 26 | private T t; 27 | 28 | public synchronized void set(T t) { 29 | this.t = t; 30 | } 31 | 32 | public T get() { 33 | return t; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /rqueue-test-util/src/main/java/com/github/sonus21/RandomUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21; 18 | 19 | import java.util.Random; 20 | import lombok.extern.slf4j.Slf4j; 21 | 22 | @Slf4j 23 | public abstract class RandomUtils { 24 | 25 | public static Random random; 26 | 27 | static { 28 | String seed = System.getenv("TEST_SEED"); 29 | long randomSeed = 0; 30 | if (seed != null) { 31 | try { 32 | randomSeed = Long.parseLong(seed); 33 | } catch (NumberFormatException e) { 34 | log.error("Invalid number format for log seed {}", seed); 35 | } 36 | } 37 | if (randomSeed == 0) { 38 | randomSeed = System.currentTimeMillis(); 39 | } 40 | random = new Random(randomSeed); 41 | log.error("Test random seed is {}", randomSeed); 42 | } 43 | 44 | public static long randomTime(long min, long max) { 45 | return min + random.nextInt((int) (max - min)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /rqueue-test-util/src/main/java/com/github/sonus21/RedisStarterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21; 18 | 19 | import org.junit.jupiter.api.BeforeAll; 20 | 21 | public abstract class RedisStarterTest extends TestBase { 22 | 23 | public String getRedisHost() { 24 | return "localhost"; 25 | } 26 | 27 | public int getRedisPort() { 28 | return 6379; 29 | } 30 | 31 | @BeforeAll 32 | public void init() { 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /rqueue-test-util/src/main/java/com/github/sonus21/TestBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21; 18 | 19 | import lombok.extern.slf4j.Slf4j; 20 | 21 | @Slf4j 22 | public abstract class TestBase extends RandomUtils { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /rqueue-test-util/src/main/java/com/github/sonus21/junit/BootstrapRedis.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.junit; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | 26 | @ExtendWith(RedisBootstrapper.class) 27 | @Target({ElementType.TYPE}) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Documented 30 | public @interface BootstrapRedis { 31 | 32 | String host() default "localhost"; 33 | 34 | int port() default 6379; 35 | 36 | boolean systemRedis() default false; 37 | 38 | boolean monitorRedis() default false; 39 | 40 | int monitorThreadsCount() default 0; 41 | } 42 | -------------------------------------------------------------------------------- /rqueue-test-util/src/main/java/com/github/sonus21/junit/LocalTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.junit; 18 | 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | import org.junit.jupiter.api.Tag; 24 | 25 | @Target({ElementType.TYPE}) 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Tag("local") 28 | public @interface LocalTest { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /rqueue-test-util/src/main/java/com/github/sonus21/junit/RedisAvailable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.junit; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | 26 | @ExtendWith(RedisAvailableCondition.class) 27 | @Target({ElementType.TYPE}) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Documented 30 | public @interface RedisAvailable { 31 | 32 | String[] nodes() default {}; 33 | } 34 | -------------------------------------------------------------------------------- /rqueue-test-util/src/main/java/com/github/sonus21/junit/TestQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.junit; 18 | 19 | import java.lang.annotation.Documented; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | @Target({ElementType.TYPE, ElementType.METHOD}) 26 | @Retention(RetentionPolicy.RUNTIME) 27 | @Documented 28 | public @interface TestQueue { 29 | 30 | String[] value() default {}; 31 | 32 | boolean clearQueueBefore() default true; 33 | 34 | boolean clearQueueAfter() default true; 35 | 36 | boolean flushAll() default false; 37 | } 38 | -------------------------------------------------------------------------------- /rqueue-test-util/src/main/java/com/github/sonus21/junit/TestTracerExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2023 Sonu Kumar 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * You may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and limitations under the License. 14 | * 15 | */ 16 | 17 | package com.github.sonus21.junit; 18 | 19 | import java.lang.reflect.Method; 20 | import org.junit.jupiter.api.extension.ExtensionContext; 21 | import org.springframework.test.context.junit.jupiter.SpringExtension; 22 | 23 | public class TestTracerExtension extends SpringExtension { 24 | 25 | @Override 26 | public void beforeAll(ExtensionContext context) throws Exception { 27 | super.beforeAll(context); 28 | System.setProperty("testClass", context.getRequiredTestClass().getSimpleName()); 29 | } 30 | 31 | @Override 32 | public void beforeEach(ExtensionContext context) throws Exception { 33 | super.beforeEach(context); 34 | Method testMethod = context.getRequiredTestMethod(); 35 | System.setProperty("testName", testMethod.getName()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = "Rqueue" 2 | include "rqueue-test-util" 3 | include "rqueue-core" 4 | include "rqueue-spring-common-test" 5 | include "rqueue-spring" 6 | include "rqueue-spring-boot-starter" 7 | include "rqueue-spring-example" 8 | include "rqueue-spring-boot-example" 9 | include "rqueue-spring-boot-reactive-example" 10 | 11 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/zsh 2 | # 3 | # Copyright (c) 2021-2023 Sonu Kumar 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # You may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and limitations under the License. 15 | # 16 | # 17 | 18 | function runTests(){ 19 | ./gradlew codeCoverageReport -DincludeTags=unit 20 | ./gradlew codeCoverageReport -DincludeTags=producerOnly 21 | ./gradlew codeCoverageReport -DincludeTags=integration -DexcludeTags=redisCluster,producerOnly,local 22 | ./gradlew codeCoverageReport -DincludeTags=redisCluster 23 | ./gradlew codeCoverageReport -DincludeTags=local 24 | 25 | } 26 | echo "Starting to run tests $(date)" 27 | runTests 28 | echo "Ended run tests $(date)" 29 | 30 | export RQUEUE_REACTIVE_ENABLED=true 31 | echo "Starting to run reactive redis tests $(date)" 32 | runTests 33 | echo "ended reactive redis tests $(date)" 34 | --------------------------------------------------------------------------------