Skip to content

Instantly share code, notes, and snippets.

View RichardHightower's full-sized avatar

Richard Hightower RichardHightower

View GitHub Profile
@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);
@RichardHightower
RichardHightower / My Response
Created April 26, 2014 18:03
Explanation why dead code optimization is not done by Boon JSON Test
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));
}
```
./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.
@RichardHightower
RichardHightower / foo.md
Last active August 29, 2015 14:24
example changing the uri to MRS

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;
@RichardHightower
RichardHightower / foo.java
Created August 21, 2015 01:57
resource-url-example
@RequestMapping("/hr")
public class HRService {
final Map<Integer, Department> departmentMap = new HashMap<>();
@RequestMapping("/department/")
public List<Department> getDepartments() {
return new ArrayList<>(departmentMap.values());
@RichardHightower
RichardHightower / JsonQueue.java
Created October 15, 2015 04:41
JsonQueue that does encoding/decoding of a QBit Queue on the fly
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;
@RichardHightower
RichardHightower / Composite Example
Created November 1, 2013 22:13
Composite Example for Mr. B
import com.examples.model.test.Email;
import com.examples.model.test.UserEmail;
...
import java.util.List;
import java.util.Objects;
import static org.boon.criteria.CriteriaFactory.eqNested;
@RichardHightower
RichardHightower / boon-java-import-maven
Last active December 27, 2015 14:49
using boon from maven
<dependencies>
<dependency>
<groupId>org.boon</groupId>
<artifactId>boon</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
@RichardHightower
RichardHightower / new-qbit-release.md
Created April 1, 2016 17:15
new release of qbit, integration with Node, Kafka, Vertx event bus

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'
@RichardHightower
RichardHightower / qbit_reakt_cassandra.md
Created April 9, 2016 01:21
Example of using QBit circuit breaker logic with Cassandra using Reakt

This class uses an async supplier to connect to cassandra.

Example of circuit breaker for Cassandra.

import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.ResultSetFuture;