ninja.seibert:sqsconnect-api

A JCA adapter for Amazon SQS

Лицензия

Лицензия

Категории

Категории

Ninja Взаимодействие с пользователем Веб-фреймворки
Группа

Группа

ninja.seibert
Идентификатор

Идентификатор

sqsconnect-api
Последняя версия

Последняя версия

1.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

A JCA adapter for Amazon SQS

Скачать sqsconnect-api

Как подключить последнюю версию

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

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
com.amazonaws : aws-java-sdk-sqs jar 1.11.192

provided (1)

Идентификатор библиотеки Тип Версия
javax : javaee-api jar 6.0

Модули Проекта

Данный проект не имеет модулей.

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.

Версии библиотеки

Версия
1.0