All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mtnfog.idyl.e3.sdk.IdylE3ClientUtils Maven / Gradle / Ivy

There is a newer version: 2.3.1
Show newest version
/* Copyright 2016 Mountain Fog, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */

package com.mtnfog.idyl.e3.sdk;

import com.amazonaws.services.sqs.AmazonSQSClient;
import com.amazonaws.services.sqs.model.SendMessageRequest;
import com.amazonaws.services.sqs.model.SendMessageResult;
import com.google.gson.Gson;
import com.mtnfog.idyl.e3.sdk.model.QueuedEntityExtractionRequest;

/**
 * Utility functions for use with the Idyl E3 client.
 * 
 * @author Mountain Fog, Inc.
 *
 */
public class IdylE3ClientUtils {

	/**
	 * Sends a {@link QueuedEntityExtractionRequest request} to an AWS SQS queue.
	 * @param client The SQS {@link AmazonSQSClient client}. 
	 * @param queueUrl The URL of the SQS queue.
	 * @param queuedEntityExtractionRequest The entity extraction {@link QueuedEntityExtractionRequest request} to queue.
	 * @return The ID of the queued message.
	 */
	public static String queueExtractionRequest(AmazonSQSClient client, String queueUrl, QueuedEntityExtractionRequest queuedEntityExtractionRequest) {
		
		Gson gson = new Gson();
		String messageBody = gson.toJson(queuedEntityExtractionRequest, QueuedEntityExtractionRequest.class);
		
		SendMessageRequest sendMessageRequest = new SendMessageRequest();
		sendMessageRequest.setQueueUrl(queueUrl);
		sendMessageRequest.setMessageBody(messageBody);
		
		SendMessageResult result = client.sendMessage(sendMessageRequest);
		
		return result.getMessageId();
		
	}
		
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy