use of software.amazon.awssdk.services.sqs.SqsClient in project beam by apache.
the class SqsUnboundedReaderTest method setupMessages.
private void setupMessages(String... messages) {
final SqsClient client = testCase.getClient();
final String queueUrl = testCase.getQueueUrl();
for (String message : messages) {
client.sendMessage(b -> b.queueUrl(queueUrl).messageBody(message));
}
when(mockSource.getRead().sqsClientProvider()).thenReturn(StaticSqsClientProvider.of(client));
when(mockSource.getRead().queueUrl()).thenReturn(queueUrl);
}
use of software.amazon.awssdk.services.sqs.SqsClient in project aws-doc-sdk-examples by awsdocs.
the class SendReceiveMessages method purgeMyQueue.
public void purgeMyQueue() {
SqsClient sqsClient = getClient();
GetQueueUrlRequest getQueueRequest = GetQueueUrlRequest.builder().queueName(QUEUE_NAME).build();
PurgeQueueRequest queueRequest = PurgeQueueRequest.builder().queueUrl(sqsClient.getQueueUrl(getQueueRequest).queueUrl()).build();
sqsClient.purgeQueue(queueRequest);
}
use of software.amazon.awssdk.services.sqs.SqsClient in project aws-doc-sdk-examples by awsdocs.
the class SendReceiveMessages method getMessages.
public String getMessages() {
List attr = new ArrayList<String>();
attr.add("Name");
SqsClient sqsClient = getClient();
try {
GetQueueUrlRequest getQueueRequest = GetQueueUrlRequest.builder().queueName(QUEUE_NAME).build();
String queueUrl = sqsClient.getQueueUrl(getQueueRequest).queueUrl();
// Receive messages from the queue
ReceiveMessageRequest receiveRequest = ReceiveMessageRequest.builder().queueUrl(queueUrl).maxNumberOfMessages(10).messageAttributeNames(attr).build();
List<Message> messages = sqsClient.receiveMessage(receiveRequest).messages();
com.example.Message myMessage;
List allMessages = new ArrayList<com.example.Message>();
// Push the messages to a list
for (Message m : messages) {
myMessage = new com.example.Message();
myMessage.setBody(m.body());
Map map = m.messageAttributes();
MessageAttributeValue val = (MessageAttributeValue) map.get("Name");
myMessage.setName(val.stringValue());
allMessages.add(myMessage);
}
return convertToString(toXml(allMessages));
} catch (SqsException e) {
e.getStackTrace();
}
return "";
}
use of software.amazon.awssdk.services.sqs.SqsClient in project aws-doc-sdk-examples by awsdocs.
the class VideoDetect method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage: " + " <bucket> <video> <queueUrl> <topicArn> <roleArn>\n\n" + "Where:\n" + " bucket - the name of the bucket in which the video is located (for example, (for example, myBucket). \n\n" + " video - the name of the video (for example, people.mp4). \n\n" + " queueUrl- the URL of a SQS queue. \n\n" + " topicArn - the ARN of the Amazon Simple Notification Service (Amazon SNS) topic. \n\n" + " roleArn - the ARN of the AWS Identity and Access Management (IAM) role to use. \n\n";
if (args.length != 5) {
System.out.println(USAGE);
System.exit(1);
}
String bucket = args[0];
String video = args[1];
String queueUrl = args[2];
String topicArn = args[3];
String roleArn = args[4];
Region region = Region.US_EAST_1;
RekognitionClient rekClient = RekognitionClient.builder().region(region).build();
SqsClient sqs = SqsClient.builder().region(Region.US_EAST_1).build();
NotificationChannel channel = NotificationChannel.builder().snsTopicArn(topicArn).roleArn(roleArn).build();
startLabels(rekClient, channel, bucket, video);
getLabelJob(rekClient, sqs, queueUrl);
System.out.println("This example is done!");
sqs.close();
rekClient.close();
}
use of software.amazon.awssdk.services.sqs.SqsClient in project aws-doc-sdk-examples by awsdocs.
the class AddQueueTags method main.
public static void main(String[] args) {
final String USAGE = "\n" + "Usage: " + " <queueName>\n\n" + "Where:\n" + " queueName - the name of the queue to which tags are applied.\n\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String queueName = args[0];
SqsClient sqsClient = SqsClient.builder().region(Region.US_WEST_2).build();
addTags(sqsClient, queueName);
sqsClient.close();
}
Aggregations