Dynamo DB with Mulesoft

Nebiha

Last Update há 4 anos

Introduction 

DynamoDB provides on demand capacity mode where it scales automatically based on number of requests in given timespan. DynamoDB mainly has Tables,Items and Attributes as we are accustomed of correlating to an Sql database at least initially before getting accustomed to no-sql database Item can be related to rows, Attributes can related to columns here there’s a catch dont completely relate it to an Sql database comparison is just for your understanding and correlation.

DynamoDB doesn’t have any schema attributes and their data types may vary at each item level, but each item uniquely identified by Primary Key(Partition key)  which is mandatory for each item and is predefined while creating a table. We can even have a composite primary key with SortKey let us understand them from below snippets.

Anypoint Connector for Amazon DynamoDB (Amazon DynamoDB Connector) provides connectivity to the Amazon DynamoDB API. Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability. Amazon DynamoDB Connector supports the Basic and Role authentication types.

Common Use Cases for the Connector

Amazon DynamoDB Connector enables you to interact with Amazon DynamoDB to create a database table that can:

    • Store and retrieve any amount of data
    • Serve any level of request traffic
    • Automatically distribute the data and traffic for the table over a sufficient number of servers to manage the request capacity and the amount of data stored.
Amazon Dynamo DB Connector does this while maintaining consistent, fast performance.


On this Article we will demonstrate how can we Retrieve Data From Dynamo DB Using Dynamo DB Connector In Mule 4. The GetItem operation returns a set of attributes for the item with the given primary key. If there is no matching item GetItem does not return any data and there will be no Item element in the response.

GetItem provides an eventually consistent read by default. If your application requires a strongly consistent read, set ConsistentRead to true. Although a strongly consistent read might take more time than an eventually consistent read, it always returns the last updated value

Step1 Create a Mule Project

In Studio, create a new Mule project in which to add and configure the connector:

    • In Anypoint Studio, select File > New > Mule Project.

    • Enter a name for your Mule project and click Finish.
    • configure the listener


Step 2 Add the dynamodb Connector to Your Mule Project

Add Amazon DynamoDB Connector to your Mule project to automatically populate the XML code with the connector’s namespace and schema location, as well as to add the required dependencies to the project’s pom.xml file:

    • In the Mule Palette view, click (X) Search in Exchange.

    • In Add Modules to Project, type amazon dynamodb in the search field.

    • Click Amazon DynamoDB in Available modules.
    • Click Add.
    • Click Finish.


Step 3 Configure a Global Element for the dynamo db and HTTP Listner Connector

Step 4 Create the payload to pass the primary key to query the table


Step 5 Configure the table name,Key, Attributes as shown below

Step 6. Deploy and test the project from POSTMAN, data retrieved successfully from dynamo db table

Was this article helpful?

1 out of 1 liked this article