Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dinstone/beanstalkc
Beanstalkc is a thread-safe client library of the beanstalkd.
https://github.com/dinstone/beanstalkc
Last synced: about 1 month ago
JSON representation
Beanstalkc is a thread-safe client library of the beanstalkd.
- Host: GitHub
- URL: https://github.com/dinstone/beanstalkc
- Owner: dinstone
- Created: 2013-03-23T14:02:24.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2023-08-17T07:35:09.000Z (over 1 year ago)
- Last Synced: 2023-08-17T08:55:46.761Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 257 KB
- Stars: 40
- Watchers: 1
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license/ApacheV2.txt
Awesome Lists containing this project
README
# What
Beanstalkc is a thread-safe client library of the [beanstalkd](https://beanstalkd.github.io), which support connection pool.
# How
## Add Maven Dependency:
```xml
com.dinstone.beanstalkc
beanstalkc-netty
2.4.0```
or
```xml
com.dinstone.beanstalkc
beanstalkc-mina
2.4.0```
## Example:
```java
public static void main(String[] args) {
// set beanstalkd service host and port and other connetion config,
// then create job producer or consumer by this config.
Configuration config = new Configuration();
config.setServiceHost("192.168.1.120");
config.setServicePort(11300);
config.setConnectTimeout(2000);
config.setReadTimeout(3000);
BeanstalkClientFactory factory = new BeanstalkClientFactory(config);
// create an producer instance
JobProducer producer = factory.createJobProducer("pctube");
// publish delay job to beanstalkd
producer.putJob(1, 1, 5000, "dddd".getBytes());// create an consumer instance
JobConsumer consumer = factory.createJobConsumer("pctube");// peek delay job from beanstalkd
Job job = consumer.reserveJob(1);
// do someting
System.out.println("id = " + job.getId() + " ; data = " + new String(job.getData()));
// job execute success, then delete it
consumer.deleteJob(job.getId());
// finnally close client and release resources
producer.close();
consumer.close();
}
```