agave-common/common-core/src/main/java/org/iplantc/service/common/messaging/BeanstalkClient.java
/* 
	 * Pulls multiple messages off a tube. Beanstalk locks the client when you try to read
	 * a message and none are available, so don't use this if you are not sure there are
	 * <pre>count</pre> messages available.
	 */
Pulls multiple messages off a tube. Beanstalk locks the client when you try to read
a message and none are available, so don't use this if you are not sure there are
count messages available.
Pulls multiple messages off a tube . Beanstalk locks the client when you try to read a message and none are available so don ' t use this if you are not sure there are count messages available .
@Override
	public List<Message> pop(String exchange, String queue, int count) throws MessagingException
	{
		List<Message> messages = new ArrayList<Message>();
		try
		{
			for (int i=0;i<Math.min(count, getActiveJobCount(exchange, queue));i++) 
			{
				client.watch(queue);
				client.useTube(queue);
				Job beanstalkJob = client.reserve(null);
				if (beanstalkJob == null) {
					break;
				}
				client.ignore(queue);
				messages.add(new Message(beanstalkJob.getJobId(), new String(beanstalkJob.getData())));
			}
			return messages;
		}
		catch (Exception e)
		{
			throw new MessagingException("Failed to retrieve messages from the " + queue + " tube", e);
		}
	}
@ Override public List < Message > pop ( String exchange , String queue , int count ) throws MessagingException { List < Message > messages = new ArrayList < Message > ( ) ; try { for ( int i = 0 ; i < Math . min ( count , getActiveJobCount ( exchange , queue ) ) ; i ++ ) { client . watch ( queue ) ; client . useTube ( queue ) ; Job beanstalkJob = client . reserve ( null ) ; if ( beanstalkJob == null ) { break ; } client . ignore ( queue ) ; messages . add ( new Message ( beanstalkJob . getJobId ( ) , new String ( beanstalkJob . getData ( ) ) ) ) ; } return messages ; } catch ( Exception e ) { throw new MessagingException ( "Failed to retrieve messages from the " + queue + " tube" , e ) ; } }
Pulls multiple messages off a tube.
Pulls multiple messages off a tube .