ninja.seibert:sqsconnect

A JCA adapter for Amazon SQS

License

License

Categories

Categories

Ninja User Interface Web Frameworks
GroupId

GroupId

ninja.seibert
ArtifactId

ArtifactId

sqsconnect
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

pom
Description

Description

ninja.seibert:sqsconnect
A JCA adapter for Amazon SQS
Project URL

Project URL

https://github.com/se1by/SQS-Connect
Source Code Management

Source Code Management

http://github.com/se1by/SQS-Connect/tree/master

Download sqsconnect

Filename Size
sqsconnect-1.0.pom 4 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/ninja.seibert/sqsconnect/ -->
<dependency>
    <groupId>ninja.seibert</groupId>
    <artifactId>sqsconnect</artifactId>
    <version>1.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/ninja.seibert/sqsconnect/
implementation 'ninja.seibert:sqsconnect:1.0'
// https://jarcasting.com/artifacts/ninja.seibert/sqsconnect/
implementation ("ninja.seibert:sqsconnect:1.0")
'ninja.seibert:sqsconnect:pom:1.0'
<dependency org="ninja.seibert" name="sqsconnect" rev="1.0">
  <artifact name="sqsconnect" type="pom" />
</dependency>
@Grapes(
@Grab(group='ninja.seibert', module='sqsconnect', version='1.0')
)
libraryDependencies += "ninja.seibert" % "sqsconnect" % "1.0"
[ninja.seibert/sqsconnect "1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
com.amazonaws : aws-java-sdk-sqs jar 1.11.192

provided (1)

Group / Artifact Type Version
javax : javaee-api jar 6.0

Project Modules

  • api
  • impl

SQS-Connect

is a JCA adapter for Amazon SQS.


Using

To use the connector in your project add the following dependency to your pom.xml:

<dependency>
    <groupid>ninja.seibert</groupid>
    <artifactId>sqsconnect-api</artifactId>
    <version>1.0</version>
</dependency>

After that you should deploy the rar archive to your application server.

Inbound

To receive messages you have to create an MDB like this:

@MessageDriven(activationConfig = {
	@ActivationConfigProperty(propertyName = "accessKeyId", propertyValue = "<yourAccessKeyId>"),
   	@ActivationConfigProperty(propertyName = "secretAccessKey", propertyValue = "<yourSecretAccessKey>"),
  	@ActivationConfigProperty(propertyName = "region", propertyValue = "<yourRegion>"),
    @ActivationConfigProperty(propertyName = "queueURL", propertyValue = "<yourQueueUrl>")
})
public class SqsMessageReceiver implements SqsListener {

    @Override
    public void onMessage(Message message) {
    	//Your message processing code here
    }
}

If you already set accessKeyId, secretAccessKey or region in the resource adapter config you can omit them here.

Outbound

You can create an outbound connection by creating an SqsConnectionFactory (either in your application server or by using the @ConnectionDefinition annotation). After that you can send messages like this:

try (SqsConnection connection = factory.getConnection()) {
    connection.sendMessage(new SendMessageRequest("<yourQueueUrl>", "<yourContent>"));
} catch (ResourceException e) {
    //Problem while allocating the connection
} catch (Exception e) {
    //General problem while sending the message or closing the connection
}

Configuration Properties

You can define the following configuration properties in the resource adapter config or ConnectionFactory setup of your application server to be able to omit them in the annotations.

Property Type Default Description
accessKeyId String none The accessKeyId used to connect to SQS.
secretAccessKey String none The secretAccessKey used to connect to SQS.
maxMessages Integer 10 Maximum number of messages to pull at once (min. 1, max. 10).
pollInterval Integer 30 Number of seconds to wait between polls.
region String none Region your queue is hosted in.

Note that maxMessages and pollInterval only apply to MDB configuration.


Building

You can build the adapter yourself by cloning this repo

git clone https://github.com/se1by/SQS-Connect.git

and executing

mvn clean package

in the project root.

Versions

Version
1.0