Browse Source

HPCC-17227 AWS SQS Plugin

Merged from pull request from hezouat.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
hezouat 8 years ago
parent
commit
6a8e597ba7

+ 1 - 0
CMakeLists.txt

@@ -155,6 +155,7 @@ if ( PLUGIN )
     HPCC_ADD_SUBDIRECTORY (plugins/redis "REDIS")
     HPCC_ADD_SUBDIRECTORY (plugins/javaembed "JAVAEMBED")
     HPCC_ADD_SUBDIRECTORY (plugins/kafka "KAFKA")
+    HPCC_ADD_SUBDIRECTORY (plugins/sqs "SQS")
     HPCC_ADD_SUBDIRECTORY (plugins/sqlite3 "SQLITE3EMBED")
     HPCC_ADD_SUBDIRECTORY (plugins/mysql "MYSQLEMBED")
     HPCC_ADD_SUBDIRECTORY (plugins/exampleplugin "EXAMPLEPLUGIN")

+ 1 - 1
plugins/CMakeLists.txt

@@ -38,4 +38,4 @@ add_subdirectory (redis)
 add_subdirectory (kafka)
 add_subdirectory (exampleplugin)
 add_subdirectory (couchbase)
-
+add_subdirectory(sqs)

+ 72 - 0
plugins/sqs/CMakeLists.txt

@@ -0,0 +1,72 @@
+# minimal CMakeLists.txt for the AWS SDK for C++
+cmake_minimum_required(VERSION 2.8)
+
+# "my-example" is just an example value.
+project(sqs)
+
+
+if(SQS)
+   ADD_PLUGIN(sqs)
+   if(MAKE_SQS)
+    # Locate the AWS SDK for C++ package.
+    # Requires that you build with:
+    # -Daws-sdk-cpp_DIR=/path/to/sdk_build
+    # or export/set:
+    # CMAKE_PREFIX_PATH=/path/to/sdk_build
+    find_package(aws-sdk-cpp)
+    if(!aws-sdk-cpp_FOUND) 
+         message(FATAL_ERROR
+          "AWS SDK not found and required that you build with: 
+		-Daws-sdk-cpp_DIR=/path/to/sdk_build 
+           or export/set:
+		CMAKE_PREFIX_PATH=/path/to/sdk_buid")
+    endif()	
+
+    # Link to the SDK shared libraries.
+    add_definitions(-DUSE_IMPORT_EXPORT)
+#    add_subdirectory(doc)
+    include_directories (BEFORE ${INCLUDE_DIR})
+    set(
+            SRCS
+            sqs.h
+            sqs.cpp)
+
+   include_directories(
+            ./../../system/include
+            ./../../rtl/eclrtl
+            ./../../rtl/include
+            ./../../common/deftype
+            ./../../system/jlib
+            ${PROJECT_BINARY_DIR}/include
+            ${CMAKE_BINARY_DIR} )
+
+       add_definitions(-D_USRDLL -DECL_SQS_EXPORTS)
+        HPCC_ADD_LIBRARY(sqs SHARED ${SRCS})
+
+        if(${CMAKE_VERSION} VERSION_LESS "2.8.9")
+            message(WARNING "Cannot set NO_SONAME. shlibdeps will give warnings when package is installed")
+        elseif(NOT APPLE)
+            set_target_properties(sqs PROPERTIES NO_SONAME 1)
+        endif()
+
+        install(
+            TARGETS sqs
+            DESTINATION plugins)
+
+
+        target_link_libraries(
+            sqs 
+            aws-cpp-sdk-sqs
+            eclrtl
+            jlib
+            ${ZLIB_LIBRARIES})
+
+   endif()
+endif()
+
+if(PLATFORM OR CLIENTTOOLS_ONLY)
+    install(
+        FILES ${CMAKE_CURRENT_SOURCE_DIR}/sqs.ecllib
+        DESTINATION plugins
+        COMPONENT Runtime)
+endif()

+ 14 - 0
plugins/sqs/README.md

@@ -0,0 +1,14 @@
+#[Description] (SQS plugin allows to push message using ECL code)
+   * First you have to put your aws accessKey in the credential file into .aws folder. This folder is located in HPCC's home dir: "~/hpcc/.aws/" if it doesn't exist, you should create it.
+
+#[Example]
+ * import sqs;
+	publisher:=sqs.SQSPublisher('QueueName');
+	publisher.PublishMessage('Put your message here');
+
+
+
+
+
+
+

+ 44 - 0
plugins/sqs/cmake_install.cmake

@@ -0,0 +1,44 @@
+# Install script for directory: /hpcc/HPCC-Platform/plugins/sqs
+
+# Set the install prefix
+if(NOT DEFINED CMAKE_INSTALL_PREFIX)
+  set(CMAKE_INSTALL_PREFIX "/usr/local")
+endif()
+string(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
+
+# Set the install configuration name.
+if(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
+  if(BUILD_TYPE)
+    string(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
+           CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
+  else()
+    set(CMAKE_INSTALL_CONFIG_NAME "")
+  endif()
+  message(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
+endif()
+
+# Set the component getting installed.
+if(NOT CMAKE_INSTALL_COMPONENT)
+  if(COMPONENT)
+    message(STATUS "Install component: \"${COMPONENT}\"")
+    set(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
+  else()
+    set(CMAKE_INSTALL_COMPONENT)
+  endif()
+endif()
+
+# Install shared libraries without execute permission?
+if(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
+  set(CMAKE_INSTALL_SO_NO_EXE "1")
+endif()
+
+if(CMAKE_INSTALL_COMPONENT)
+  set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt")
+else()
+  set(CMAKE_INSTALL_MANIFEST "install_manifest.txt")
+endif()
+
+string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT
+       "${CMAKE_INSTALL_MANIFEST_FILES}")
+file(WRITE "/hpcc/HPCC-Platform/plugins/sqs/${CMAKE_INSTALL_MANIFEST}"
+     "${CMAKE_INSTALL_MANIFEST_CONTENT}")

+ 451 - 0
plugins/sqs/sqs.cpp

@@ -0,0 +1,451 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2017 HPCC Systems®.
+
+    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.
+############################################################################## */ 
+
+
+#include <aws/core/Aws.h>
+#include <aws/sqs/SQSClient.h>
+#include <aws/sqs/model/CreateQueueRequest.h>
+#include <aws/sqs/model/AddPermissionRequest.h>
+#include <aws/sqs/model/DeleteQueueRequest.h>
+#include <aws/sqs/model/ListQueuesRequest.h>
+#include <aws/sqs/model/ListQueuesResult.h>
+#include <aws/sqs/model/SendMessageRequest.h>
+#include <aws/sqs/model/SendMessageResult.h>
+#include <aws/sqs/model/ReceiveMessageRequest.h>
+#include <aws/sqs/model/ReceiveMessageResult.h>
+#include <aws/sqs/model/GetQueueUrlRequest.h>
+#include <aws/sqs/model/GetQueueUrlResult.h>
+#include "platform.h"
+#include "jexcept.hpp"
+#include "jthread.hpp"
+#include "deftype.hpp"
+#include "eclhelper.hpp"
+#include "eclrtl.hpp"
+#include "eclrtl_imp.hpp"
+#include <iostream>
+#include <string>
+#include <algorithm>
+#include <cstring>
+#include <cctype>
+#include "sqs.h"
+
+using namespace std;
+
+static const char * compatibleVersions[] = {
+  "AWS Amazon SQS based on SDK AWS",
+  NULL };
+
+static const char *version = "SQS Version depends on AWS";
+
+extern "C" DECL_EXPORT bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb)
+{
+  if (pb->size == sizeof(ECLPluginDefinitionBlock))
+    {
+      ECLPluginDefinitionBlockEx * pbx = (ECLPluginDefinitionBlockEx *) pb;
+      pbx->compatibleVersions = compatibleVersions;
+      pb->magicVersion = PLUGIN_VERSION;
+      pb->version = version;
+      pb->moduleName = "SQS";
+      pb->ECL = NULL;
+      pb->flags = PLUGIN_MULTIPLE_VERSIONS;
+      pb->description = "SQS based on AWS SDK";
+      return true;
+    }
+  else
+    {
+      return false;
+    }	
+}
+
+
+/**
+ * This method creates an instance of SQSHPCC
+ * @param _queueName this name gave to queue
+ *
+ */
+
+SQSHPCCPlugin::SQSHPCC::SQSHPCC(const string& _queuename) 
+{
+
+  if(_queuename.empty())
+    {
+      throw runtime_error("QueueName is required");
+    }
+  this->queueName=_queuename;
+  cout << "The queue is " << this->queueName << endl;
+  
+}
+
+
+/**
+ * Destructor  
+ * Release the SQS connection
+ */
+SQSHPCCPlugin::SQSHPCC::~SQSHPCC()
+{
+
+  // Aws::ShutdownAPI(this->options);
+  this->queueName="";
+  delete(this->sqsClient);
+}
+
+/**
+ *  
+ *
+ *
+ **/
+
+SQSHPCCPlugin::Response  SQSHPCCPlugin::SQSHPCC::sendMessage(const char* message) 
+{
+
+  SQSHPCCPlugin::Response ref = {};
+
+  cout << "SendMessage is " << this->queueUrl << endl; 
+
+  try {
+    Aws::SQS::Model::SendMessageRequest sendMessageRequest;
+    sendMessageRequest.SetQueueUrl(this->queueUrl);
+    sendMessageRequest.SetMessageBody(message);
+ 
+    Aws::SQS::Model::SendMessageOutcome sendMessageOutcome = this->sqsClient->SendMessage(sendMessageRequest);
+     
+    if(!sendMessageOutcome.IsSuccess() || sendMessageOutcome.GetResult().GetMessageId().length() == 0 )
+      {
+	cout << "Error occurred during the sending " << endl;
+	ref.code=-1;
+	ref.body="Error occurred during message sending";
+      }
+    else 
+      {
+	ref.code=3;
+	ref.body=convertAwsStringToCharPtr(sendMessageOutcome.GetResult().GetMessageId());
+      }	
+     
+  } catch (const char* message) {
+    cout<< "Error occurred during sending message [ " << message << " ]" << endl;
+  }
+
+  return ref;
+}
+
+
+/**
+ *
+ *  This function allows to disconnect the link with AWS SQS
+ *
+ **/
+
+bool SQSHPCCPlugin::SQSHPCC::disconnect() 
+{
+  try 
+    {
+      Aws::ShutdownAPI(this->options);
+      return true;
+    }
+  catch(...)
+    {
+      return false;
+    }	
+}
+
+
+/**
+ *
+ *
+ */
+bool SQSHPCCPlugin::SQSHPCC::QueueExists() 
+{
+  Aws::SQS::Model::GetQueueUrlRequest gqu_req;
+  gqu_req.SetQueueName(this->queueName.c_str());
+  bool exists=false;
+  try
+    {
+      Aws::SQS::Model::GetQueueUrlOutcome gqu_out = this->sqsClient->GetQueueUrl(gqu_req);
+      exists =gqu_out.IsSuccess(); 
+    }
+  catch(const char* message) 
+    {
+      cout << "Error: " << message << endl;
+    }
+   
+  return exists;
+}
+
+SQSHPCCPlugin::Response SQSHPCCPlugin::SQSHPCC::createQueue()
+{
+
+  SQSHPCCPlugin::Response ref = {};
+
+  Aws::SQS::Model::CreateQueueRequest cq_req;
+  cq_req.SetQueueName(this->queueName.c_str());
+
+  Aws::SQS::Model::CreateQueueOutcome  cq_out = this->sqsClient->CreateQueue(cq_req);
+  if (cq_out.IsSuccess()) 
+    {
+      cout << "Successfully created queue " << this->queueName << std::endl;
+    }
+  else 
+    {
+      cout << "Error creating queue " << this->queueName << ": " <<
+	cq_out.GetError().GetMessage() << std::endl;
+    }
+
+  return ref;
+}
+
+
+SQSHPCCPlugin::Response SQSHPCCPlugin::SQSHPCC::deleteQueue()
+{
+
+  SQSHPCCPlugin::Response ref = {};
+
+  Aws::SQS::Model::DeleteQueueRequest cq_req;
+  cq_req.SetQueueUrl(this->queueUrl);
+
+  auto  cq_out = this->sqsClient->DeleteQueue(cq_req);
+  if (cq_out.IsSuccess()) 
+    {
+      cout << "Successfully deleted queue " << this->queueName << std::endl;
+    } 
+  else 
+    {
+      cout << "Error deleting queue " << this->queueName << ": " <<
+	cq_out.GetError().GetMessage() << std::endl;
+    }
+
+  return ref;
+}
+
+
+SQSHPCCPlugin::Response SQSHPCCPlugin::SQSHPCC::receiveMessage() 
+{
+
+  SQSHPCCPlugin::Response ref = {};
+  try
+    {
+      Aws::SQS::Model::ReceiveMessageRequest receiveMessageRequest;
+      receiveMessageRequest.SetQueueUrl(this->queueUrl);
+      receiveMessageRequest.SetMaxNumberOfMessages(1);
+      receiveMessageRequest.AddMessageAttributeNames("All");
+
+      Aws::SQS::Model::ReceiveMessageOutcome receiveMessageOutcome = this->sqsClient->ReceiveMessage(receiveMessageRequest);
+      if(!receiveMessageOutcome.IsSuccess() || receiveMessageOutcome.GetResult().GetMessages().size() == 0)
+	{
+	  std::cout << "Error on receive: " << receiveMessageOutcome.GetError().GetMessage() << std::endl;
+	  ref.code=2;
+	  return ref;
+	}
+ 
+      Aws::SQS::Model::Message msg = receiveMessageOutcome.GetResult().GetMessages()[0];
+      cout << msg.GetBody() << endl;
+    } 
+  catch(const char* message) 
+    {
+      cout << "Error: " << message << endl; 
+    }
+   
+  return ref;
+}
+
+
+void SQSHPCCPlugin::SQSHPCC::setQueueUrlFromQueueName() 
+{
+
+  Aws::SQS::Model::GetQueueUrlRequest gqu_req;
+  gqu_req.SetQueueName(this->queueName.c_str());
+
+  try 
+    {
+      Aws::SQS::Model::GetQueueUrlOutcome gqu_out = this->sqsClient->GetQueueUrl(gqu_req);
+      if(gqu_out.IsSuccess()) 
+	{
+	  std::cout << "Queue " << this->queueName.c_str() << " has url " << std::endl;
+	  this->queueUrl=gqu_out.GetResult().GetQueueUrl();
+        } 
+      else
+	{
+	  std::cout << "Error getting url for queue " << this->queueName.c_str() << ": " << std::endl;
+	  throw runtime_error(gqu_out.GetError().GetMessage().c_str()) ;
+        }
+
+    } catch(const char* message) {
+    cout << "Error: " << message << endl;
+  }
+
+}
+
+void SQSHPCCPlugin::SQSHPCC::setSQSConfiguration(const string& protocol, const string& region)
+{
+
+  Aws::InitAPI(this->options);
+  Aws::Client::ClientConfiguration config;
+  
+  if(!protocol.empty())
+    {
+      config.scheme = Aws::Http::Scheme::HTTPS;
+    }
+
+  if(region.empty()) throw string("Region mustn't be empty");
+  
+  if(RegionExists(region))
+    {
+      config.region = getRegion(region);
+    }
+
+  this->sqsClient= new Aws::SQS::SQSClient(config);
+
+  cout << "Queue URL is "  << this->queueUrl << endl;
+}
+
+
+bool SQSHPCCPlugin::SQSHPCC::RegionExists(const string& region)
+{
+  
+  if(region.empty())
+    {
+      return false;
+    }
+
+  char *reg = convertStringToChar(region); 
+  
+  return (
+          strieq(reg,"US_EAST_1") ||
+    	  strieq(reg,"US_WEST_1") ||
+    	  strieq(reg,"EU_WEST_1") ||
+    	  strieq(reg,"EU_CENTRAL_1") ||
+    	  strieq(reg,"AP_SOUTHEAST_1") ||
+     	  strieq(reg,"AP_SOUTHEAST_2")
+	  ); 
+}
+
+
+const char *const SQSHPCCPlugin::SQSHPCC::getRegion(const string& region) 
+{
+
+  char *reg = convertStringToChar(region); 
+    
+  if(strieq(reg,"US_EAST_1"))  return Aws::Region::US_EAST_1;
+  if(strieq(reg,"US_WEST_1")) return Aws::Region::US_WEST_1;
+  if(strieq(reg,"EU_WEST_1")) return Aws::Region::EU_WEST_1;
+  if(strieq(reg,"EU_CENTRAL_1")) return Aws::Region::EU_CENTRAL_1;
+  if(strieq(reg,"AP_SOUTHEAST_1")) return Aws::Region::AP_SOUTHEAST_1;
+  if(strieq(reg,"AP_SOUTHEAST_2"))  return Aws::Region::AP_SOUTHEAST_2;
+
+  throw string("Your region must be among these regions [ US_EAST_1, US_WEST_1, EU_WEST_1, EU_CENTRAL_1, AP_SOUTHEAST_1, AP_SOUTHEAST_2 ], please check your region");
+}
+
+
+void SQSHPCCPlugin::SQSHPCC::upstr(char *s)
+{
+  char  *p;
+
+  for (p = s; *p != '\0'; p++) 
+    *p = (char) toupper(*p);
+}
+
+
+
+char*  SQSHPCCPlugin::SQSHPCC::convertStringToChar(const string& str) 
+{
+  char *reg = new char[str.length() +1];
+  strcpy(reg,str.c_str());
+  return reg;
+}
+
+string SQSHPCCPlugin::SQSHPCC::convertAwsStringToCharPtr(Aws::String str)
+{
+  string res(str.c_str());
+  return res;
+}
+
+/**
+ *  These function expose the contract for ECL  
+ *
+ */
+
+namespace SQSHPCCPlugin
+{
+
+  ECL_SQS_API bool ECL_SQS_CALL publishMessage(ICodeContext * ctx,const char* region, const char* queueName, const char* message)
+  {
+
+    if(strlen(queueName) == 0) 
+      {
+	cout << "QueueName is Empty" << endl;
+	throw runtime_error("The queueName mustn't be empty!!!");
+      }
+    try 
+      { 
+	SQSHPCCPlugin::SQSHPCC hpcc(queueName);
+	hpcc.setSQSConfiguration("HTTPS",region);
+	hpcc.setQueueUrlFromQueueName();
+	SQSHPCCPlugin::Response response = hpcc.sendMessage(message);
+	return true;
+      }	
+    catch(...)
+      {
+	throw;
+      }
+	  
+    return false;
+  }
+
+  ECL_SQS_API bool ECL_SQS_CALL QueueExists(ICodeContext* ctx,const char* region, const char* queueName)
+  {
+
+    SQSHPCCPlugin::SQSHPCC hpcc(queueName);
+    hpcc.setSQSConfiguration("HTPPS",region);
+    hpcc.setQueueUrlFromQueueName();
+    bool exists = hpcc.QueueExists();
+    return exists;
+  }
+
+  ECL_SQS_API bool createQueue(ICodeContext* ctx,const char* region, const char* queueName)
+  {
+    SQSHPCCPlugin::SQSHPCC hpcc(queueName);
+    hpcc.setSQSConfiguration("HTTPS",region);
+    try
+      {
+	SQSHPCCPlugin::Response response = hpcc.createQueue();
+	return true;
+      }
+    catch(...)
+      {
+	return false;
+      }	
+	    
+  }
+
+  ECL_SQS_API bool ECL_SQS_CALL deleteQueue(ICodeContext * ctx,const char* region, const char* queueName)
+  {
+
+    SQSHPCCPlugin::SQSHPCC hpcc(queueName);
+    hpcc.setSQSConfiguration("HTTPS",region);
+    hpcc.setQueueUrlFromQueueName();
+    try
+      {
+	hpcc.deleteQueue();
+	return true;
+      }
+    catch(...)
+      {
+	return false;
+      }
+  }
+}
+
+

+ 40 - 0
plugins/sqs/sqs.ecllib

@@ -0,0 +1,40 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2017 HPCC Systems®.
+
+    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.
+############################################################################## */
+
+
+// Service definition
+SHARED sqs := SERVICE : plugin('sqs'), namespace('SQSHPCCPlugin')
+
+    BOOLEAN PublishMessage(CONST VARSTRING region, CONST VARSTRING queueName, CONST VARSTRING message) : cpp,action,context,entrypoint='publishMessage';
+    BOOLEAN IsQueueExist(CONST VARSTRING region,CONST VARSTRING queueName):cpp,action,context,entrypoint='isQueueExist';
+    BOOLEAN CreateQueue(CONST VARSTRING region,CONST VARSTRING queueName):cpp,action,context,entrypoint='createQueue';
+END;
+
+/**
+ * Module wrapping message publishing functions.
+ *
+ * @param   queue           The name of the queue this module will be publishing to;
+ *                          cannot be an empty string; REQUIRED
+ * @param   region          The AWS region is the zone where is the queue SQS is located. By default is "eu_west_1"       
+ */
+EXPORT SQSPublisher(VARSTRING queue, VARSTRING region = 'eu_west_1') := MODULE
+
+
+  EXPORT BOOLEAN PublishMessage(CONST VARSTRING message) := sqs.PublishMessage(region,queue,message);
+  EXPORT BOOLEAN IsQueueExist():= sqs.isQueueExist(region,queue);
+  EXPORT BOOLEAN CreateQueue():= sqs.createQueue(region,queue);
+END;

+ 138 - 0
plugins/sqs/sqs.h

@@ -0,0 +1,138 @@
+
+/*##############################################################################
+
+  HPCC SYSTEMS software Copyright (C) 2017 HPCC Systems®.
+
+  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.
+  ############################################################################## */
+
+#ifndef SQSHPCC_H
+#define SQSHPCC_H
+
+
+
+#ifdef _WIN32
+#define ECL_SQS_CALL _cdecl
+#else
+#define ECL_SQS_CALL
+#endif
+
+#ifdef ECL_SQS_EXPORTS
+#define ECL_SQS_API DECL_EXPORT
+#else
+#define ECL_SQS_API DECL_IMPORT
+#endif
+
+#include "platform.h"
+#include "jthread.hpp"
+#include "hqlplugins.hpp"
+#include "eclrtl_imp.hpp"
+#include "eclhelper.hpp"
+#include <aws/core/Aws.h>
+#include <aws/sqs/SQSClient.h>
+#include <iostream>
+#include <stdio.h>
+#include <string>
+#include <unistd.h>
+#include <libgen.h>
+
+
+#ifdef ECL_SQS_EXPORTS
+
+extern  "C" 
+{
+  ECL_SQS_API bool getECLPluginDefinition(ECLPluginDefinitionBlock *pb);
+  ECL_SQS_API void setPluginContext(IPluginContext * _ctx);
+}
+#endif
+
+extern "C++" 
+{
+  namespace SQSHPCCPlugin
+  {
+    using namespace std;
+    typedef struct {
+      int code;
+      std::string body;
+      bool success;
+    } Response;
+
+
+
+  
+    class SQSHPCC
+    {
+
+    public:
+      explicit SQSHPCC(const std::string& _queueName);
+      ~SQSHPCC();
+ 
+      Response sendMessage(const char* message);
+      Response createQueue();
+      Response deleteQueue();
+      Response deleteMessage(const std::string& message);
+      Response receiveMessage();
+
+      void setSQSConfiguration(const std::string& protocol,
+			       const std::string& region); 
+      void setAwsCredentials(const char* accessKeyId, 
+			     const char* secretKey); 
+      bool disconnect();
+      bool QueueExists();
+
+      void setQueueUrlFromQueueName();
+
+    protected:
+
+    private:
+      std::string queueName;
+      Aws::String queueUrl;
+      Aws::SQS::SQSClient* sqsClient;
+      Aws::SDKOptions options;
+      Aws::Auth::AWSCredentials* credentials;
+      bool RegionExists(const std::string& region);
+      const char *const getRegion(const std::string& region);
+      void upstr(char* s);
+      std::string convertAwsStringToCharPtr(Aws::String str);
+      char*  convertStringToChar(const string& str);
+    };
+
+
+    //----------------------------------------------------------------------
+
+    /**
+     * Queues the message for publishing to aws queue
+     * 
+     * @param   Reqion          
+     * @param   QueueName
+     * @param   message            The message to send
+     *
+     * @return  true if the message was cached successfully
+     */
+    ECL_SQS_API bool ECL_SQS_CALL publishMessage(ICodeContext * ctx,const char* region, const char* queueName, const char* message); 
+
+    //---------------------------------------------------------------------
+
+    /** 
+     *
+     *
+     */
+    ECL_SQS_API bool ECL_SQS_CALL createQueue(ICodeContext * ctx,const char* region, const char* queueName);
+
+    ECL_SQS_API bool ECL_SQS_CALL QueueExists(ICodeContext* ctx,const char* region, const char* queueName);
+     
+    ECL_SQS_API bool ECL_SQS_CALL deleteQueue(ICodeContext * ctx,const char* region, const char* queueName);      
+	
+  }
+}
+#endif

+ 11 - 0
plugins/sqs/sqs.pc

@@ -0,0 +1,11 @@
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: SQSHPCC
+Description: This is a plugin for HPCC allowing to dialog with Amazon's SQS 
+Version: 0.0.1
+Requires:
+Libs: -L${libdir} -lssl -lcrypto -lz
+Cflags: -I${includedir}