diff --git a/core-services/egov-notification-sms/pom.xml b/core-services/egov-notification-sms/pom.xml
index 4268b706a..0b85ef8d8 100644
--- a/core-services/egov-notification-sms/pom.xml
+++ b/core-services/egov-notification-sms/pom.xml
@@ -71,6 +71,11 @@
spring-boot-starter-test
test
+
+ org.springframework
+ spring-jdbc
+ 5.3.23
+
diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/config/SMSProperties.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/config/SMSProperties.java
index 6355de06a..223b9e1a3 100644
--- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/config/SMSProperties.java
+++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/config/SMSProperties.java
@@ -90,6 +90,9 @@ public class SMSProperties {
@Value("${save.sms.entity.topic}")
private String saveSmsTopic;
+ @Value("${save.sms.entity.enabled}")
+ private boolean isSaveSmsEnable;
+
@Setter(AccessLevel.PROTECTED) private List whitelistPatterns;
@Setter(AccessLevel.PROTECTED) private List blacklistPatterns;
diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java
index a1e84d7ea..8b3c660c4 100644
--- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java
+++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/models/SmsSaveRequest.java
@@ -12,7 +12,7 @@
@Builder
@ToString
public class SmsSaveRequest {
- private String id;
+ private Long id;
private String mobileNumber;
private String message;
private Category category;
diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/repository/builder/SmsNotificationRepository.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/repository/builder/SmsNotificationRepository.java
new file mode 100644
index 000000000..505990986
--- /dev/null
+++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/repository/builder/SmsNotificationRepository.java
@@ -0,0 +1,22 @@
+package org.egov.web.notification.sms.repository.builder;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Repository;
+import org.springframework.jdbc.core.JdbcTemplate;
+
+@Component
+@Slf4j
+@Repository
+public class SmsNotificationRepository {
+
+ private JdbcTemplate jdbcTemplate;
+
+ public static final String SELECT_NEXT_SEQUENCE_USER = "select nextval('seq_eg_notification_sms')";
+
+ public Long getNextSequence() {
+ return jdbcTemplate.queryForObject(SELECT_NEXT_SEQUENCE_USER, Long.class);
+ }
+
+
+}
diff --git a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java
index 7f221c2e0..4c257ada6 100644
--- a/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java
+++ b/core-services/egov-notification-sms/src/main/java/org/egov/web/notification/sms/service/BaseSMSService.java
@@ -8,6 +8,7 @@
import org.egov.web.notification.sms.config.*;
import org.egov.web.notification.sms.models.*;
import org.egov.web.notification.sms.producer.Producer;
+import org.egov.web.notification.sms.repository.builder.SmsNotificationRepository;
import org.springframework.asm.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.core.*;
@@ -45,6 +46,9 @@ abstract public class BaseSMSService implements SMSService, SMSBodyBuilder {
@Autowired
private Producer producer;
+ @Autowired
+ private SmsNotificationRepository smsNotificationRepository;
+
@PostConstruct
public void init() {
List> converters = restTemplate.getMessageConverters();
@@ -79,10 +83,13 @@ public void sendSMS(Sms sms) {
return;
}
log.info("calling submitToExternalSmsService() method");
- SmsSaveRequest smsSaveRequest = SmsSaveRequest.builder().mobileNumber(sms.getMobileNumber()).message(sms.getMessage())
- .category(sms.getCategory()).templateId(sms.getTemplateId()).tenantId(sms.getTenantId()).createdtime(System.currentTimeMillis()).build();
- log.info("SMS request to save sms topic" +smsSaveRequest );
- producer.push(smsProperties.getSaveSmsTopic(), smsSaveRequest);
+ if(smsProperties.isSaveSmsEnable()) {
+ Long id = smsNotificationRepository.getNextSequence();
+ SmsSaveRequest smsSaveRequest = SmsSaveRequest.builder().id(id).mobileNumber(sms.getMobileNumber()).message(sms.getMessage())
+ .category(sms.getCategory()).templateId(sms.getTemplateId()).tenantId(sms.getTenantId()).createdtime(System.currentTimeMillis()).build();
+ log.info("SMS request to save sms topic" + smsSaveRequest);
+ producer.push(smsProperties.getSaveSmsTopic(), smsSaveRequest);
+ }
submitToExternalSmsService(sms);
}
diff --git a/core-services/egov-notification-sms/src/main/resources/application.properties b/core-services/egov-notification-sms/src/main/resources/application.properties
index a02de326c..b2a4544e7 100644
--- a/core-services/egov-notification-sms/src/main/resources/application.properties
+++ b/core-services/egov-notification-sms/src/main/resources/application.properties
@@ -90,4 +90,5 @@ spring.kafka.consumer.properties.spring.json.type.mapping=smsRequest:org.egov.we
spring.kafka.listener.missing-topics-fatal=false
#persister topic of sms
-save.sms.entity.topic = save-sms-entity-application
\ No newline at end of file
+save.sms.entity.topic = save-sms-entity-application
+save.sms.entity.enabled = true
\ No newline at end of file
diff --git a/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql b/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql
index e5344c243..04ae434f5 100644
--- a/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql
+++ b/core-services/egov-notification-sms/src/main/resources/db/migration.main/V20231005150835_notification_sms_ddl.sql
@@ -1,5 +1,5 @@
CREATE TABLE IF NOT EXISTS eg_notification_sms (
- id SERIAL PRIMARY KEY,
+ id bigint NOT NULL,
mobile_no VARCHAR(20) NOT NULL,
message TEXT,
category VARCHAR(50),
@@ -7,3 +7,11 @@ CREATE TABLE IF NOT EXISTS eg_notification_sms (
createdtime TIMESTAMP,
tenant_id VARCHAR(50)
);
+CREATE SEQUENCE seq_eg_notification_sms
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+ALTER TABLE eg_notification_sms ADD CONSTRAINT eg_notification_sms_pkey PRIMARY KEY (id);
+