Posts

Sealed Classes and Interfaces in Java

Sealed Classes & Interfaces   Sealed classes and interfaces restrict which other classes or interfaces may extend or implement them. Purpose Of Creating Sealed Classes or Interfaces:-   As We know  purposes of inheritance is code reuse: When you want to create a new class and there is an existing class that have some of the code that you want to reuse then you can derive your new class from the existing class. In doing this, you can reuse the fields and methods of the existing class.  In the above scenario, any new class(Child class) can extends Existing Class(Parent class)  and can use its fields and methods.  If we want to restrict any Class or Interface in such a way that only some permitted classes and interfaces can use their fields and methods, To achieve this Concept of Sealed Classes and Interfaces came in Java 17. How to Achieve Sealed Classes and Interfaces:- To seal a class, add the  sealed  modifier to its declaration. Then, after ...

RabbitMQ Installation on Windows

Image
Before installing RabbitMQ , We have to install Erlang. What is Erlang ? Erlang  is a general-purpose programming language and runtime environment.  Erlang  has built-in support for concurrency, distribution and fault tolerance .  Erlang  is  used  in several large telecommunication systems from Ericsson . The RabbitMQ is built on  Erlang  runtime environment so before we install RabbitMQ, first we need to download and install  Erlang  in our machines . Erlang Installation Following is the link to download and install Erlang on your windows machine. http://www.erlang.org/downloads RabbitMQ Installation After completion of Erlang installation, now we will install RabbitMQ on windows for that download a RabbitMQ setup file from following link for windows. https://www.rabbitmq.com/download.html After opening the above URL, we will get a RabbitMQ setup files information like as shown below. Here w...

RabbitMQ implementation in SpringBoot

Introduction of  RabbitMQ . Installation of RabbitMQ. RabbitMQ Exchanges. RabbitMQ Queues. RabbitMQ Bindings. RabbitMQ Users. RabbitMQ VirtualHost. RabbitMQ Connections RabbitMQ Channels RabbitMQ Publish Messages RabbitMQ Consume Messages.

Introduction of RabbitMQ

Image
What is RabbitMQ ? RabbitMQ  is an  AMQP  messaging broker and it is the most popular open source and cross-platform message broker. RabbitMQ is  a way to exchange data between different/same platform applications such as a message sent from one SpringBoot Application to to other SpringBoot application  or Dot   Net  application can be read by a  SpringBoot  Application. The RabbitMQ is built on  Erlang  general-purpose programming language and it is also used by WhatsApp for messaging. What is AMQP? The Advanced Message Queuing Protocol ( AMQP ) is an open standard application layer protocol for message-oriented and the features of AMQP are message orientation, queuing, routing (including point-to-point and publish-and-subscribe), reliability and security. AMQP was designed with the following main characteristics as goals: Security Reliability Interoperability Standard Open RabbitMQ is lightw...

Multi Threading

Image
What is Thread Group ? Based on functionality we can group thread into a single unit ,which is nothing but Thread Group i.e. Thread Group contains group of thread. In addition to Thread ,Thread Group can also contain sub-thread group. The main advantage of maintaining thread in the form thread group is ,we can perform common operation very easily. Code: What is yield() method ? Theoretically, to ‘yield’ means to let go, to give up, to surrender.  The  yield()  method of thread class causes the currently executing thread object to temporarily pause and allow other threads to execute.  Note that  it’s only a hint , though, and not guaranteed to have any effect at all. This method is persent in java.lang.Thread class in java. Syntax   :- public static native void yield()  Some platform wouldn't support for yield() method. The purpose of yield() method causes to pass current executing thread to give the chance for the remaining waiting thread of same...

product management crud test

application.properties server.port=8051 spring.datasource.url=jdbc:h2:file:~/test spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password= spring.jpa.database-platform=org.hibernate.dialect.H2Dialect # Enabling H2 Console spring.h2.console.enabled=true # Custom H2 Console URL spring.h2.console.path=/h2-console # create database schema from SQL files spring.jpa.hibernate.ddl-auto=create #Turn Statistics on and log SQL stmts spring.jpa.show-sql=true spring.jpa.properties.hibernate.format_sql=true spring.jpa.properties.hibernate.generate_statistics=false #logging.level.org.hibernate.type=trace #logging.level.org.hibernate.stat=debug logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} - %msg%n H2databaseApplication .java import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; import co...

Serialization in java

Image
What is Serialization in Java ? The process of of writing state of an object to a file called Serialization. But strictly speaking, It is the process of converting object from java supported from into file file supported form or network supported form or network supported form. By using FileOutputstream or ObjectOutputStream we can achieve serialization. Deserialization :- The process of reading state of an object from from the file is called deserialization . But strictly speaking it is process of converting an object from either file supported form or network supported into java supported form. We can serialize  to be only serializable  object. An Object is said to be serializable if and only if the corresponding class implements Serializable interface. Serializable interface is present in the java.io package. It doesn't contain any method. Its a marker interface. If we try to serialize, non-serialized object  then it will throw NotSerialzableException . Tra...