A Kotlin client, based on pure JDBC, for Postgres Message Queue (PGMQ).
This library currently supports following PGMQ API:
create
drop_queue
list_queues
send_batch
read
pop
archive
delete
purge_queue
First of all - you need to set up PgmqConnectionFactory
and PgmqSerializationProvider
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
This library provides 2 implementations - GsonPgmqSerializationProvider and JacksonPgmqSerializationProvider
If you use some other serialization library - feel free to implement PgmqSerializationProvider interface, it's simple! :)
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
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 are always welcomed!