In the video below, we take a closer look at how to get a record from the database using JdbcTemplate with Spring Boot. Let’s get started!
Articles
In the video below, we take a closer look at how to insert a record in the database using JdbcTemplate with Spring Boot. Let’s get started!
In the video below, we take a closer look at Spring Boot JMSTemplate with Embedded ActiveMQ. Let’s get started!
In the video below, we take a closer look at Spring Auto-Wiring Beans with @Autowired annotation. Let’s get started!
This article describes the steps that need to be followed in order to invoke a stored procedure with complex Abstract Data Type as IN, OUT, and IN OUT parameter in Mule 4.
The lack of documentation to handle ADT payloads while invoking stored procedures and technical issues while retrieving the ADT response in mule run time 4.x.x discouraged developers using mulesoft for the purpose.
xxxxxxxxxx
val myFuture = Future {
// you have no future, you are DOOMED!
42
// JK.
}
The Scenario
xxxxxxxxxx
def gimmeMyPreciousValue(yourArg: Int): Future[String]
xxxxxxxxxx
object MyService {
def produceThePreciousValue(theArg: Int): String = "The meaning of your life is " + (theArg / 42)
def submitTask[A](actualArg: A)(function: A => Unit): Boolean = {
// send the function to be evaluated on some thread, at the discretion of the scheduling logic
true
}
}
-
A "production" function that is completely deterministic.
-
A submission function that has a pretty terrible API because the function argument will be evaluated on one of the service’s threads, and you can’t get the returned value back from another thread’s call stack.
xxxxxxxxxx
def gimmeMyPreciousValue(yourArg: Int): Future[String] = Future {
MyService.produceThePreciousValue(yourArg)
}
The Solution
xxxxxxxxxx
// create an empty promise
val myPromise = Promise[String]()
// extract its future
val myFuture = myPromise.future
// do your thing with the future, assuming it will be filled with a value at some point
val furtherProcessing = myFuture.map(_.toUpperCase())
xxxxxxxxxx
val asyncCall(promise: Promise[String]): Unit = {
promise.success("Your value here, your majesty")
}
How to Use it
def gimmeMyPreciousValue(yourArg: Int): Future[String] = {
// create promise now
val thePromise = Promise[String]()
// submit a task to be evaluated later, at the discretion of the service
// note: if the service is not on the same JVM, you can pass a tuple with the arg and the promise so the service has access to both
MyService.submit(yourArg) { x: Int =>
val preciousValue = MyService.producePreciousValue(x)
thePromise.success(preciousValue)
}
// return the future now, so it can be reused by whoever's consuming it
thePromise.future
}
failure
, trySuccess
/ tryFailure
and more. Despite Java not providing a zip operation, you don’t need either 30 additional lines to implement it, nor a third party library. Simply compose a zipline through the existing Stream API.
Abstract
Java, from its 8th version onward, provides an easy way to query sequences of elements through its Stream Interface, which provides several operations out of the box. This set of operations is quite versatile but, as can be expected, it does not cover all the operations a programmer may require. One such operation is zip, as we can observe in one of the most visited posts about Java Streams in Stackoverfow: Zipping streams using JDK8 with lambda (java.util.stream.Streams.zip). Even 7 years later, we are now on Java 14 release and there is no zip operation for Streams yet.
Apache Ignite as a distributed database and caching platform needs end-to-end monitoring to act on time. Historically, Apache Ignite provides a set of API and instrumentation to gather application-specific information and metrics by the external tools. In release 2.8.0, Apache Ignite improved the monitoring capabilities and introduced some nice features like "System views subsystem" and "Metrics subsystem."
In this short article, we are going to explore the Apache Ignite new monitoring opportunities and how to use different tools and technics to gather metrics for diagnosis. Anyway, the full release notes of version 2.8.0 can be found here.
Health checks are a fundamental part of our APIs. I guess they fall in that category of "non-functional-but-heavily-required" things. More or less like a good part of the infrastructure code.
They don’t add business value per se but have an enormous impact for those in IT, like DDD and design patterns. You can normally see them in conjunction with container orchestration or monitoring tools to ensure that the system is alive and kicking.