org.apache.camel.component.cassandra.CassandraProducer Maven / Gradle / Ivy
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.camel.component.cassandra;
import java.util.Collection;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.support.DefaultProducer;
import static org.apache.camel.utils.cassandra.CassandraUtils.isEmpty;
/**
* Cassandra 2 CQL3 producer.
*
* - In Message
* - Bound parameters: Collection of Objects, Array of Objects, Simple Object
*
-
*
- Out Message
* - List of all Rows
*
-
*
*/
public class CassandraProducer extends DefaultProducer {
private PreparedStatement preparedStatement;
public CassandraProducer(CassandraEndpoint endpoint) {
super(endpoint);
}
@Override
protected void doStart() throws Exception {
super.doStart();
if (isPrepareStatements() && getEndpoint().getCql() != null) {
this.preparedStatement = getEndpoint().prepareStatement();
}
}
@Override
protected void doStop() throws Exception {
this.preparedStatement = null;
super.doStop();
}
@Override
public CassandraEndpoint getEndpoint() {
return (CassandraEndpoint) super.getEndpoint();
}
public boolean isPrepareStatements() {
return getEndpoint().isPrepareStatements();
}
private Object[] getCqlParams(Message message) {
Object cqlParamsObj = message.getBody();
Object[] cqlParams;
final Class
© 2015 - 2025 Weber Informatics LLC | Privacy Policy