ninja.seibert:sqsconnect-impl

A JCA adapter for Amazon SQS

License

License

Categories

Categories

Ninja User Interface Web Frameworks
GroupId

GroupId

ninja.seibert
ArtifactId

ArtifactId

sqsconnect-impl
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

A JCA adapter for Amazon SQS

Download sqsconnect-impl

How to add to project

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

Dependencies

compile (3)

Group / Artifact Type Version
ninja.seibert : sqsconnect-api jar 1.0
org.projectlombok : lombok jar 1.16.10
com.amazonaws : aws-java-sdk-sqs jar 1.11.192

provided (1)

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

Project Modules

There are no modules declared in this project.

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