App

Overview

The Files component is an abstraction of persistent queues with a default implementation using AWS SQS. This also provides a much simplified API while making the underlying implementation swappable.

Status

This component is currently stable. Following limitations, current work, planned features apply.

Feature Status Description
Meta Upcoming Ability to easily default / inject meta data for every entry.
URI Upcoming Ability to use Slate Kit Uri for explicit references to file paths
Errors Upcoming Ability to use a dead-letter queue for failed items.
Batch Upcoming Ability to perform batch insert operations

Back to top



Install

    repositories {
        // other repositories
        maven { url  "http://dl.bintray.com/codehelixinc/slatekit" }
    }

    dependencies {
        // other dependencies ...

        compile 'com.slatekit:slatekit-cloud:1.0.0'
    }
package slatekit.cloud
jar slatekit.cloud.jar
git slatekit/src/lib/kotlin/slatekit-cloud
docs Files
uses slatekit.results, slatekit.core, slatekit.cloud
license Apache 2.0
example Example_Files.kt

Back to top



Requires

This component uses the following other Slate Kit and/or third-party components.

Component Description
Results To model successes and failures with optional status codes
Utils Common utilities for both android + server

Back to top



Imports

         
    import slatekit.cloud.aws.AwsCloudQueue
    import slatekit.common.queues.QueueStringConverter
     

Back to top



Setup

        
    val converter = QueueStringConverter()
    // Not storing any key/secret in source code for security purposes
    // Setup 1: Use the default aws config file in "{user_dir}/.aws/credentials"
    val queue1 = AwsCloudQueue<String>("app1-queue-1", "queue1", converter)

    // Setup 2: Use the type safe config in "{user_id}/myapp/conf/queue.conf"
    // Reads from the section "sqs" by default
    val queue2 = AwsCloudQueue<String>("app1-queue-1", "queue1", converter,"user://myapp/conf/queue.conf")

    // Setup 3: Use the type safe config in "{user_id}/myapp/conf/queue.conf"
    // Reads from the section supplied "sqs-3" ( if you have multiple sqs configurations )
    val queue3 = AwsCloudQueue<String>("app1-queue-1",  "queue1", converter, "user://myapp/conf/queue.conf", "sqs-1")
     

Back to top



Usage

        
    // Use case 1: init()
    queue2.init()

    // Use case 2: send 1 message
    queue2.send("item 1")

    // Use case 3: send multiple messages
    queue2.send("item 2")

    // Use case 4: send message with tags
    queue2.send("user=kishore", tagName="type", tagValue="reg")

    // Use case 5: receive 1 message
    val item1 = queue2.next()
    println(item1?.getValue())
    println(item1?.getTag("type"))

    // Use case 6: recieve 2 messages
    val items = queue2.next(2)

    // Use case 7: delete a message
    queue2.complete(item1)

    // Use case 8: delete many
    queue2.completeAll(items)

    // Use case 9: abandon a message
    queue2.abandon(queue2.next())

    // Use case 10: get count ( approximation )
    val count = queue2.count()
    println(count)
      

Back to top