aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/sms
diff options
context:
space:
mode:
authorSubodh Ranadive <subodh.ranadive@ekzero.com>2021-03-17 12:58:37 +0530
committerSubodh Ranadive <subodh.ranadive@ekzero.com>2021-03-24 15:30:32 +0530
commit8f6c0ca2d62f608c5acf370f460c553974aa29d4 (patch)
tree49b4ff57b35a159f583fa4b5ffc926f3424cb0eb /src/main/java/org/traccar/sms
parentd3a4ce4c83da1062b4cfc2f983150a827b3db389 (diff)
downloadtrackermap-server-8f6c0ca2d62f608c5acf370f460c553974aa29d4.tar.gz
trackermap-server-8f6c0ca2d62f608c5acf370f460c553974aa29d4.tar.bz2
trackermap-server-8f6c0ca2d62f608c5acf370f460c553974aa29d4.zip
Async changes
Diffstat (limited to 'src/main/java/org/traccar/sms')
-rw-r--r--src/main/java/org/traccar/sms/SnsSmsClient.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/sms/SnsSmsClient.java b/src/main/java/org/traccar/sms/SnsSmsClient.java
index af52315e0..e59f42753 100644
--- a/src/main/java/org/traccar/sms/SnsSmsClient.java
+++ b/src/main/java/org/traccar/sms/SnsSmsClient.java
@@ -17,11 +17,11 @@ package org.traccar.sms;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
-import com.amazonaws.services.sns.AmazonSNS;
-import com.amazonaws.services.sns.AmazonSNSClientBuilder;
+import com.amazonaws.services.sns.*;
import com.amazonaws.services.sns.model.MessageAttributeValue;
import com.amazonaws.services.sns.model.PublishRequest;
+import com.amazonaws.services.sns.model.PublishResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.Context;
@@ -29,11 +29,12 @@ import org.traccar.config.Keys;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.Future;
public class SnsSmsClient implements SmsManager {
private static final Logger LOGGER = LoggerFactory.getLogger(SnsSmsClient.class);
- private final AmazonSNS snsClient;
+ private final AmazonSNSAsync snsClient;
public SnsSmsClient() {
if (Context.getConfig().hasKey(Keys.SMS_AWS_REGION)
@@ -45,10 +46,10 @@ public class SnsSmsClient implements SmsManager {
}
}
- public AmazonSNS awsSNSClient() {
+ public AmazonSNSAsync awsSNSClient() {
BasicAWSCredentials awsCredentials = new BasicAWSCredentials(Context.getConfig().getString(Keys.SMS_AWS_ACCESS),
Context.getConfig().getString(Keys.SMS_AWS_SECRET));
- return AmazonSNSClientBuilder.standard().withRegion(Context.getConfig().getString(Keys.SMS_AWS_REGION))
+ return AmazonSNSAsyncClientBuilder.standard().withRegion(Context.getConfig().getString(Keys.SMS_AWS_REGION))
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials)).build();
}
@@ -59,12 +60,12 @@ public class SnsSmsClient implements SmsManager {
new MessageAttributeValue().withStringValue("SNS").withDataType("String"));
smsAttributes.put("AWS.SNS.SMS.SMSType",
new MessageAttributeValue().withStringValue("Transactional").withDataType("String"));
- snsClient.publish(new PublishRequest().withMessage(message)
+ snsClient.publishAsync(new PublishRequest().withMessage(message)
.withPhoneNumber(destAddress).withMessageAttributes(smsAttributes));
}
@Override
public void sendMessageAsync(String destAddress, String message, boolean command) {
- new Thread(() -> sendMessageSync(destAddress, message, command));
+ sendMessageSync(destAddress, message, command);
}
}