In this post, I will show how to use BiConsumer functional interface with an example. BiConsumer functional interface is similar to Consumer functional interface. It takes an input, processes it and doesn’t return anything. The difference lies in the number of inputs taken by the BiConsumer functional interface. Consumer functional interface takes one input whereas…… Continue reading BiConsumer Example
TransportListener Example
In this post under Java Mail, I will explain with example the purpose and how to use TransportListener interface. Note: For this example and other examples in future we need to have1) Gmail account2) GMail SMTP server address3) Stop the antivirus software running on your local.4) Create an application password. The steps are mentioned in…… Continue reading TransportListener Example
Private Interface Methods
From Java 9 onwards, we can declare private methods in interface. In this post I will show with an example of how to do it. Private methods in interface are useful if you have logic shared by more than one default interface methods. We can put the shared logic in the private method. Below is…… Continue reading Private Interface Methods
BiFunction Example
In this post, I will show how to use BiFunction functional interface with an example. BiFunction functional interface is similar to Function functional interface. It takes an input and produces an output. The difference lies in the number of inputs taken by the BiFunction functional interface. Function functional interface takes one input and produced one…… Continue reading BiFunction Example
Chaining multiple ItemProcessorListener
In this post under Spring Batch, I will explain with example how to chain multiple ItemProcessorListeners. For our example we create two ItemProcessorListener as shown below CustomItemProcessListener1 package package34; import org.springframework.batch.core.ItemProcessListener; public class CustomItemProcessListener1 implements ItemProcessListener<Employee, Employee> { @Override public void afterProcess(Employee employee1, Employee employee2) { System.out.println(“CustomItemProcessListener1: Item processing completed”); } @Override public void beforeProcess(Employee…… Continue reading Chaining multiple ItemProcessorListener
Sending Email Using SMTP (Approach 2)
In this post under Java Mail. I will show with an example how to send email using Java Mail api and SMTP protocol. Note: For this example and other examples in future we need to have 1) Gmail account 2) GMail SMTP server address 3) Stop the antivirus software running on your local. 4) Create…… Continue reading Sending Email Using SMTP (Approach 2)
CompositeItemWriter Example
In this post under Spring Batch, I will explain with example the purpose of CompositeItemWriter and how to use it. In all the previous post’s examples under Spring Batch, I have used only one writer bean. The writer bean’s job was to write the items read to a file as shown below <bean id=”writer” class=”org.springframework.batch.item.file.FlatFileItemWriter”>…… Continue reading CompositeItemWriter Example
Sending Email Using SMTP (Approach 1)
In this post under Java Mail. I will show with an example how to send email using Java api and SMTP protocol. Note: For this example and other examples in future we need to have 1) Gmail account 2) GMail SMTP server address 3) Stop the antivirus software running on your local. 4) Create an…… Continue reading Sending Email Using SMTP (Approach 1)
JMSTimestamp Example
In this post under JMS, I will explain about JMSTimestamp with an example Note: I will be using JMS 2.0 api for this and future examples. JMSTimestamp is a header field which is only set by JMS Provider and contains a long value in milliseconds that represents the time when the message was handed over…… Continue reading JMSTimestamp Example
JMSMessageID example
In this post under JMS, I will explain about JMSMessageID with an example JMSMessageID is a header field which is only set by JMS Provider and contains a string value that uniquely identifies a message. JMSMessageID is set by the provider when the JMSProducer calls the send method. Before calling the JMSProducer’s send method, the…… Continue reading JMSMessageID example