Skip to content

A Kotlin client, based on pure JDBC, for Postgres Message Queue (PGMQ).

License

Notifications You must be signed in to change notification settings

vdsirotkin/pgmq-kotlin-jvm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codecov Maven Central Version Dynamic XML Badge

pgmq-kotlin-jvm

A Kotlin client, based on pure JDBC, for Postgres Message Queue (PGMQ).

Compatibility

This library currently supports following PGMQ API:

  • create
  • drop_queue
  • list_queues
  • send_batch
  • read
  • pop
  • archive
  • delete
  • purge_queue

Usage

First of all - you need to set up PgmqConnectionFactory and PgmqSerializationProvider

PgmqConnectionFactory

You are free to implement it either way you wish :)

Example implementation for Spring, which acquires current connection inside of @Transactional method (may be useful if you need PGMQ to be transational):

@Bean
fun pgmqConnectionFactory(dataSource: DataSource) = PgmqConnectionFactory {
    DataSourceUtils.getConnection(dataSource)
} 

Please refer to Spring's DataSourceUtils docs for explanations

PgmqSerializationProvider

This library provides 2 implementations - GsonPgmqSerializationProvider and JacksonPgmqSerializationProvider

If you use some other serialization library - feel free to implement PgmqSerializationProvider interface, it's simple! :)

PgmqConfiguration

Next step should be defining PgmqConfiguration. You can also implement it either way you want.

Here's an example for Spring's Configuration Properties:

@ConfigurationProperties(prefix = "pgmq")
data class PgmqConfigurationProps(
    override val defaultVisibilityTimeout: java.time.Duration = 30.seconds.toJavaDuration()
) : PgmqConfiguration

Building client

If you have set up connection factory and serializer - you're free to build the client!

Here's complete example of Spring setup for PgmqClient - SpringPgmqApplication.kt.

Contributions

Contributions are always welcomed!

About

A Kotlin client, based on pure JDBC, for Postgres Message Queue (PGMQ).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages