Skip to content
Java Beanstalkd Client
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

##a Java beanstalkd client This is a work in progress. Client library for beanstalkd.


####Non pooled connection Example of a producer:

// Create a factory with given configuration
BeanstalkFactory factory = BeanstalkFactory.factory().host("localhost")
// fetch the producer
Producer producer = factory.get().producer();
// place job
producer.put(1l, 0, 5000, "this is some data".getBytes());
// print tube stats

To see more on the Producer

Example of a worker/consumer:

// We can use the default factory, poiting to localhost:11300
BeanstalkFactory factory = BeanstalkFactory.defaultFactory();

Worker worker = factory.get().worker();
BeanstalkJob job = worker.reserve(60).get();

System.out.println("Got job: " + job);


To see more on the Consumer

####Pooled connection Example of a producer:

// Like in non-pooled client we need to configure first or connection
BeanstalkFactory factory = BeanstalkFactory.factory().host("localhost")

// Optionally we could configure non-default pool parameters
GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();

BeanstalkPool pool = new BeanstalkPool(poolConfig, factory);
// If we use default pool configuration we could do:
// BeanstalkPool pool = new BeanstalkPool(factory);
try (Producer producer = pool.getResource().producer()) {
	producer.put(1l, 0, 5000, "this is some data".getBytes());;

Using try-with-resource we ensure the client is returned to the pool.

And for the Worker:

try (Worker worker = pool.getResource().worker()) {
			BeanstalkJob job = worker.reserve(60).get();"Got job: " + job);

Another fast way of creating a pool in a single line but the tube itself can be:

BeanstalkPool pool = BeanstalkFactory.factory()


License is MIT

You can’t perform that action at this time.