This class uses an async supplier to connect to cassandra.
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.ResultSetFuture;
Simplest example.
public static void main(String... args) throws Exception{
ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
Callable<String> asyncTask = () -> {
Thread.sleep(1000);
There is a new release of QBit. This has the bug fixes and features that the some of our clients requested, and some bridge tech. (included is JS and Java example of using new bridge tech).
New version just released.
compile 'io.advantageous.qbit:qbit-admin:0.9.3-M2'
package io.advantageous.qbit.queue; | |
import io.advantageous.qbit.QBit; | |
import io.advantageous.qbit.concurrent.PeriodicScheduler; | |
import io.advantageous.qbit.json.JsonMapper; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.Map; | |
import java.util.concurrent.TimeUnit; |
@RequestMapping("/returnEmployeeCallback2") | |
public void returnEmployeeWithCallback2(Callback<HttpTextResponse> employeeCallback) { | |
HttpTextResponse response = (HttpTextResponse) HttpResponseBuilder.httpResponseBuilder() | |
.setBody("" + new Employee(1, "Rick")) | |
.setContentType("crap/crap").setCode(777).build(); | |
employeeCallback.returnThis(response); |
@RequestMapping("/hr") | |
public class HRService { | |
final Map<Integer, Department> departmentMap = new HashMap<>(); | |
@RequestMapping("/department/") | |
public List<Department> getDepartments() { | |
return new ArrayList<>(departmentMap.values()); |
Here is an example of how to change the root address from /services to something else. And this is also an example of working with the Docker, Mesos, Heroku friendly version of QBit.
package qbit.todo;
import io.advantageous.qbit.admin.ManagedServiceBuilder;
./gradlew idea | |
FAILURE: Build failed with an exception. | |
* What went wrong: | |
A problem occurred configuring root project 'vert.x'. | |
> Could not resolve all dependencies for configuration ':classpath'. | |
> Could not download artifact 'junit:junit:4.8.2@jar' | |
> Artifact 'junit:junit:4.8.2@jar' not found. |
The benchmark uses JMH. JMH is what the OpenJDK uses for benchmarking. | |
```java | |
@GenerateMicroBenchmark | |
@OutputTimeUnit( TimeUnit.SECONDS) | |
public void actionLabel(BlackHole bh) throws Exception { | |
bh.consume(parse(STR_ACTION_LABEL_BYTES)); | |
} | |
``` |