-
Notifications
You must be signed in to change notification settings - Fork 0
/
sqs.java
44 lines (38 loc) · 1.07 KB
/
sqs.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package messageQ;
import com.amazonaws.services.sqs.AmazonSQSClientBuilder;
import com.amazonaws.services.sqs.model.AmazonSQSException;
import com.amazonaws.services.sqs.model.SendMessageBatchRequest;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
class DoLogic{
void execute() {
List<Message> list = read();
if (list != null && list.count() > 0) {
getId(list[0]);
}
}
List<Message> read(){
try{
AmazonSQS sqs = AmazonSQSClientBuilder.defaultClient();
List<Message> messages = sqs.receiveMessage("examplequeue").getMessages();
return messages;
} catch (Exception ex){
//
}
return null;
}
String getId(string data){
try{
Connection con=DriverManager.getConnection("jdbc:mysql://db.com:3306/core", USER, PASS);
Statement stmt = con.createStatement();
rs = stmt.executeQuery("SELECT id FROM t where data = '" + data + "'");
return rs.getString("Id");
} catch (Exception exc){
//
}
return null;
}
}