com.osinka.camel.beanstalk.BeanstalkComponent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of camel-beanstalk Show documentation
Show all versions of camel-beanstalk Show documentation
Apache Camel component for Beanstalk
/**
* Copyright (C) 2010 Osinka
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.osinka.camel.beanstalk;
import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.impl.DefaultComponent;
/**
* Beanstalk Camel component.
*
* URI is beanstalk://[host[:port]][/tube]?query
*
* Parameters:
* command
- one of "put", "release", "bury", "touch", "delete", "kick".
* "put" is the default for Producers.
* jobPriority
* jobDelay
* jobTimeToRun
* consumer.onFailure
*
*
* @author Alexander Azarov
* @see BeanstalkEndpoint
* @see ConnectionSettingsFactory
*/
public class BeanstalkComponent extends DefaultComponent {
public static final String DEFAULT_TUBE = "default";
public final static String COMMAND_BURY = "bury";
public final static String COMMAND_RELEASE = "release";
public final static String COMMAND_PUT = "put";
public final static String COMMAND_TOUCH = "touch";
public final static String COMMAND_DELETE = "delete";
public final static String COMMAND_KICK = "kick";
public final static long DEFAULT_PRIORITY = 1000; // 0 is highest
public final static int DEFAULT_DELAY = 0;
public final static int DEFAULT_TIME_TO_RUN = 60; // if 0 the daemon sets 1.
static ConnectionSettingsFactory connFactory = ConnectionSettingsFactory.DEFAULT;
public BeanstalkComponent() {
}
public BeanstalkComponent(final CamelContext context) {
super(context);
}
@Override
protected Endpoint createEndpoint(final String uri, final String remaining, final Map parameters) throws Exception {
return new BeanstalkEndpoint(uri, this, connFactory.parseUri(remaining));
}
/**
* Custom ConnectionSettingsFactory.
*
* Specify which {@link ConnectionSettingsFactory} to use to make connections to Beanstalkd. Especially
* useful for unit testing without beanstalkd daemon (you can mock {@link ConnectionSettings})
*
* @param connFactory
* @see ConnectionSettingsFactory
*/
public static void setConnectionSettingsFactory(ConnectionSettingsFactory connFactory) {
BeanstalkComponent.connFactory = connFactory;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy