Elefantenstark for JAVA

A postgres advisory lock based worker queue.

Лицензия

Лицензия

Категории

Категории

Ant Компиляция и сборка Сеть
Группа

Группа

net.andreaskluth
Идентификатор

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

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

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

0.1-RELEASE
Дата

Дата

Тип

Тип

jar
Описание

Описание

Elefantenstark for JAVA
A postgres advisory lock based worker queue.
Ссылка на сайт

Ссылка на сайт

https://github.com/AndreasKl/elefantenstark
Система контроля версий

Система контроля версий

http://github.com/AndreasKl/elefantenstark/tree/master

Скачать elefantenstark

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

<!-- https://jarcasting.com/artifacts/net.andreaskluth/elefantenstark/ -->
<dependency>
    <groupId>net.andreaskluth</groupId>
    <artifactId>elefantenstark</artifactId>
    <version>0.1-RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/net.andreaskluth/elefantenstark/
implementation 'net.andreaskluth:elefantenstark:0.1-RELEASE'
// https://jarcasting.com/artifacts/net.andreaskluth/elefantenstark/
implementation ("net.andreaskluth:elefantenstark:0.1-RELEASE")
'net.andreaskluth:elefantenstark:jar:0.1-RELEASE'
<dependency org="net.andreaskluth" name="elefantenstark" rev="0.1-RELEASE">
  <artifact name="elefantenstark" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.andreaskluth', module='elefantenstark', version='0.1-RELEASE')
)
libraryDependencies += "net.andreaskluth" % "elefantenstark" % "0.1-RELEASE"
[net.andreaskluth/elefantenstark "0.1-RELEASE"]

Зависимости

test (5)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter-engine jar 5.3.1
org.junit.jupiter : junit-jupiter-params jar 5.3.1
org.postgresql : postgresql jar 42.2.4
com.opentable.components : otj-pg-embedded jar 0.12.0
org.slf4j : slf4j-simple jar 1.7.25

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

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

elefantenstark

Build Status Maven Central codecov

Elefantenstark is a PostgreSQL powered worker queue for Java 8. It uses Postgres advisory locks to lock work while being worked on.

The lock can be tweaked to solve requirements regarding the ordering of how work has to be processed. E.g. all work items sharing the same key must be processed one after another.

Initializing the database tables

The Initializer creates the default queue table and indexes.

withPostgres(
    connection -> {
      new Initializer().build(connection);
      validateTableIsAvailable(connection);
    });

Producing work

Producer is thread safe and can be used to produce a WorkItem to the queue.

withPostgresAndSchema(
    connection -> {
      WorkItem workItem = WorkItem.groupedOnKey("_test_key_", "_test_value_", 0);
      new Producer().produce(connection, workItem);

      WorkItem queuedWorkItem = queryForWorkItem(connection);

      assertEquals(workItem, queuedWorkItem);
    });

Consuming work

A Consumer can be sessionScoped (tied to the current connection) or transactionScoped (creates a transaction). The session scoped can modify state that is not rolled back when the consuming function fails, however can cause unreleased locks when the application is killed. These are cleaned up when the OS decides to close the network connection.

withPostgresAndSchema(
    connection -> {
      Producer producer = new Producer();
      Consumer consumer = Consumer.sessionScoped();
      producer.produce(connection, WorkItem.groupedOnKey("a", "b", 23));

      Optional<String> next = consumer.next(
          connection,
          workItemContext -> {
            capturedWork.set(workItemContext);
            return "OK+";
          });
    });

Builds

Snapshot builds are available on Sonatype Snapshots, release builds are available on maven central.

<dependencies>
  <dependency>
    <groupId>net.andreaskluth</groupId>
    <artifactId>elefantenstark</artifactId>
    <version>0.1-RELEASE</version>
  </dependency>
</dependencies>

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

Версия
0.1-RELEASE