Description : There are more simpler and cleaner ways to avoid asserts and handling null checks. Guava’s Preconditions are used for checking method arguments, states, etc. When a condition is false the Precondition will throw the expected exception. The class Preconditions may throw IllegalArgumentException, NullPointerException, IllegalStateException and IndexOutOfBoundsException. Here are some examples that I took that can be shortened to ...
Read More »An Overview of Guava
What’s Guava : 1) Extensive suite of common libraries that is used in many Java projects. 2) These utilities relate to: collections, concurrency, primitives, reflection, comparison, I/O, hashing, networking, strings, math, in-memory caching, in-memory publish/subscribe… and various basic data types. 3) JDK required is Java 6+. Before jumping to Guava, we will have brief about Functional Interfaces. These Functional Interfaces ...
Read More »Using WireTap method in Camel Routers
Description : By using the wireTap method in the Java DSL, you can send a copy of the exchange to a secondary destination without affecting the behavior of the rest of the route. With Out WireTap Method: // add our route to the CamelContext context.addRoutes(new RouteBuilder() { @Override public void configure() { // load file orders from src/data into the ...
Read More »Using Recipient Lists In Camel Routers
Description : 1) If we are not priorities the customers all orders coming from small and top-tier customers are going directly into production. 2) We can define customer types like small and top-tier. Only For top-tier customers orders processed parallel by the both accounting and production departments. For small customer, first orders will go to accounting first. Here In accounting ...
Read More »Using Multicasting In Camel Routers
Description 1) When the list of destinations is known ahead of time and is static, you can add an element to the route that will consume messages from a source endpoint and then send the message out to a list of destinations. (accounting dept & production dept). 2) Using this multicasting technique, we can improve the speed of operations by ...
Read More »How to Use message filters in Camel Routers
Need of Message filters 1) Suppose QA department has expressed the need to be able to send test orders into the live web front end of the order system. 2) In this case we required some message filter, that stop the QA messages so that they are not to be processed. 3) Incoming messages only pass through the filter if ...
Read More »Java Anti Patterns
Description : There are many anti patterns in java, one of them is calculations and conversions to the weights. Use Case : Before instructing to Che (Container Handling Equipment, like STRADDLE, RMG, RTG, Quay-Crane), We need to check, whether this Che is lift capacity is greater than the container or containers(In case of twins) weight. CheCapacityCheck.java import javax.measure.quantity.Mass; import javax.measure.unit.Unit; ...
Read More »Content-Based Router Using Camel
1) Content-Based Router (CBR) is a message router that routes a message to a destination based on its content. 2) The content could be a message header, the payload data type, part of the payload itself—pretty much anything in the message exchange. 3) The CBR routes messages based on their content. In this case, the filename extension (as a message ...
Read More »Creating Camel routes with Spring
Description : 1) The core framework allows to you “wire” beans together to form applications. This wiring is done through an XML configuration file. 2) we need are a few Java beans (classes),Spring XML configuration file, and an ApplicationContext. The ApplicationContext is similar to the CamelContext. 3) This example, we have two routing points, One is from activemq -> Java ...
Read More »JMS Introduction
JMS Basics : 1) JMS (Java Message Service) is a Java API that allows you to create, send, receive, and read messages. 2) It also mandates that messaging is asynchronous and has specific elements of reliability, like guaranteed and once-and-only-once delivery. JMS is the de facto messaging solution in the Java community. 3) In JMS, message consumers and producers talk ...
Read More »