Skip to content

Basic Elastic Search Java API CRUD operation example

This guide assumes you have already setup the Elastic Search API with your Java application. The following examples use a ‘Part’ entity: public class Part { private String elasticSearchId; @SerializedName(“PartId”) @Expose public String partId; @SerializedName(“PartNumber”) @Expose public String partNumber; @SerializedName(“PartDescription”) […] Indexing a Part document:…

Continue reading Basic Elastic Search Java API CRUD operation example

Spring Boot multi-thread scheduling

Spring Boot provides impressive scheduling functionality out-of-the-box. To install it all you need to do is include the Spring Boot Starter dependency in your Maven project: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> Configuration By default Spring Boot will use just a single thread for all scheduled tasks…

Continue reading Spring Boot multi-thread scheduling

Create OkHttp3 Response for testing

Use a variation of the following code to create a Response to test with: private Response createResponse() { HttpUrl mHttpUrl = new HttpUrl.Builder() .scheme(“https”) .host(“example.com”) .build(); Request mRequest = new Request.Builder() .url(mHttpUrl) .build(); Response.Builder builder = new Response.Builder() .request(mRequest) .protocol(Protocol.HTTP_1_1) .message(“message”) .code(302); return builder.build(); }…

Continue reading Create OkHttp3 Response for testing

How to programmatically add and remove elements from Ehcache

Pre-requisites This guide assumes that you have already configured Ehcache, and is specifically concerned with programmatic addition and removal of elements. Adding an element to a cache @Autowired private CacheManager cacheManager; […] public Ehcache getCache(String name) { return cacheManager.getCache(name); } In the above example we…

Continue reading How to programmatically add and remove elements from Ehcache