C,C++,JAVA,SPRING,R,PYTHON,SQL Developer, Javascript MOTIVATION and programming & coding channel.πŸ’»πŸ’»
232 subscribers
73 photos
8 videos
264 files
212 links
Download Telegram
5. After that go to start.spring.io website download project with following dependencies and settings and plugins :

<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-mail</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.kafka</groupId>
      <artifactId>spring-kafka</artifactId>
    </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
<dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
C,C++,JAVA,SPRING,R,PYTHON,SQL Developer, Javascript MOTIVATION and programming & coding channel.πŸ’»πŸ’»
5. After that go to start.spring.io website download project with following dependencies and settings and plugins : <dependency>       <groupId>org.springframework.boot</groupId>       <artifactId>spring-boot-starter-mail</artifactId>     </dependency>    β€¦
<build>
<plugins>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<executions>
<execution>
<id>schemas</id>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/main/resources/avro</sourceDirectory>
<outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>

</plugins>
</build>
C,C++,JAVA,SPRING,R,PYTHON,SQL Developer, Javascript MOTIVATION and programming & coding channel.πŸ’»πŸ’»
5. After that go to start.spring.io website download project with following dependencies and settings and plugins : <dependency>       <groupId>org.springframework.boot</groupId>       <artifactId>spring-boot-starter-mail</artifactId>     </dependency>    β€¦
6. After downloading the Kafka consumer module(here we named it as notification-service),After that add these properties to your project's module's application.properties file(consumer's application.properties file) :

spring.application.name=notification-service
server.port=8084

#Mail Properties
spring.mail.host=sandbox.smtp.mailtrap.io
spring.mail.port=2525
spring.mail.username=a2adfdfdca22a5
spring.mail.password=f470820b1b0fad

#Kafka Consumer properties
spring.kafka.bootstrap-service=localhost:9092
spring.kafka.consumer.group-id=notificationService
spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
spring.kafka.consumer.value-deserializer=org.springframework.kafka.support.serializer.JsonDeserializer
spring.kafka.consumer.properties.spring.json.trusted.packages=com.techie.microservices.order.event
C,C++,JAVA,SPRING,R,PYTHON,SQL Developer, Javascript MOTIVATION and programming & coding channel.πŸ’»πŸ’»
6. After downloading the Kafka consumer module(here we named it as notification-service),After that add these properties to your project's module's application.properties file(consumer's application.properties file) : spring.application.name=notification…
7. Go to project open in intellij/eclipse/SpringToolSuite and there make a package as order.event, there place this code with required variables as per your requirements and it should either match with schema defined in file defined as order-placed.avsc in avro folder in application.properties folder of module or with class defined with the same folder structure as in consumer's module as follows :

package com.techie.microservices.order.event;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class OrderPlacedEvent {

private String orderNumber;
private String email;

}

or

Schema-registry file defined as order-placed.avsc in avro folder in application.properties folder of module:

{
"type": "record",
"name": "OrderPlacedEvent",
"namespace": "com.techie.microservices.order.event",
"fields": [
{ "name": "orderNumber", "type": "string" },
{ "name": "email", "type": "string" },
{ "name": "firstName", "type": "string" },
{ "name": "lastName", "type": "string" }
]
}
C,C++,JAVA,SPRING,R,PYTHON,SQL Developer, Javascript MOTIVATION and programming & coding channel.πŸ’»πŸ’»
7. Go to project open in intellij/eclipse/SpringToolSuite and there make a package as order.event, there place this code with required variables as per your requirements and it should either match with schema defined in file defined as order-placed.avsc in…
8. After that make a package named as service(you can keep it anything but most preferably you should write the name as service as it is providing service of sending mail) and then make a class in it(here it's NotificationService) and write the following code to enable consumer to consume the request and act accordingly here sending mail) like this :

package com.techie.microservices.notification.service;

import com.techie.microservices.order.event.OrderPlacedEvent;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.mail.MailException;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.mail.javamail.MimeMessagePreparator;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
@Slf4j
public class NotificationService {

private final JavaMailSender javaMailSender;

@KafkaListener(topics = "order-placed")
public void listen(OrderPlacedEvent orderPlacedEvent){

log.info("Got Message from order-placed topic {}",orderPlacedEvent);
// Send email to the customer
MimeMessagePreparator messagePreparator = mimeMessage -> {
MimeMessageHelper messageHelper = new MimeMessageHelper(mimeMessage);
messageHelper.setFrom("springshop@gmail.com");
messageHelper.setTo(orderPlacedEvent.getEmail());
messageHelper.setSubject(String.format("Your Order with OrderNumber %s is placed successfully",orderPlacedEvent.getOrderNumber()));
messageHelper.setText(String.format("""
Hi

Any msg in the body(here i'm providing message as Your order with order number %s is now placed successfully)

Best Regards
Spring Shop
""",
Any Dynamic msg you want to print in as %s variable Name(here it's orderPlacedEvent.getOrderNumber()));
};
try{
javaMailSender.send(messagePreparator);
log.info("Order Notification email sent!!");

}catch(MailException e){
log.error("Exception occurred when sending mailed");
throw new RuntimeException("Exception occured when sending mail to springshop@email.com",e);
}

}


}
▢️ Logical Operator Part-2: Truthy And Falsy Value in Javascript:-

/**
* Logical Operator with truthy and falsy values
* 1. OR
* 2. AND &&
*
* Truthy
* Falsy Values - "",0,null,undefined
*/

console.log(Boolean("Prakash"));

console.log(Boolean(""));

console.log(Boolean(null));

console.log(Boolean(undefined));

console.log(Boolean(0));

const firstName = "Prakash";
const nickName = "Anna";

console.log(firstName||nickName); // Output : Prakash

const emptyFirstName = "";
const FilledNickName = "Anna";

console.log(emptyFirstName|| FilledNickName); // Output : Anna

const FilledFirstName = "Prakash";
const EmptyNickName = "";

console.log(FilledFirstName|| EmptyNickName); //Output : Prakash

const emptyString = "";
const nullValue = null;

console.log(emptyString||nullValue);

const nullValue2 = null;
const emptyString2= "";

console.log( Name - ${nullValue2||emptyString2} );

console.log( Name - ${nullValue2emptyString2null} );

console.log( Name - ${nullValue2emptyString2null||"HiddenGeek"} ); //Short Circuiting

let a12 = 12;
let undefinedb;

console.log(a12+undefinedb);

let a = 12;
let b;

console.log(a+(b||0));

let a1 = 12;
let b1=3;

console.log(a1+(b1||0));

let a2 = 12;
let b2=null;

console.log(a2+(b2||0));

let a3 = 12;
let b3="";

console.log(a3+(b3||0));

const firstNameForAnd = "Prakash";
const firstNickNameForAnd = "Anna";

console.log(Name - ${firstNameForAnd && firstNickNameForAnd});

const firstNameForAnd1 = "Prakash";
const firstNickNameForAnd1 = null;

console.log(Name - ${firstNameForAnd1 && firstNickNameForAnd1});

const firstNameForAnd2 = "Prakash";
const firstNickNameForAnd2 = null;

console.log(Name - ${firstNameForAnd2 && firstNickNameForAnd2});

const firstNameForAnd3 = "Prakash";
const firstNickNameForAnd3 = "Anna";

console.log(Name - ${firstNameForAnd3 && firstNickNameForAnd3 && "HiddenGeek"});

Output : -

[Running] node "c:\Users\subham.krishna\Desktop\JavaScript\logical-operator-2.js"
true
false
false
false
false
Prakash
Anna
Prakash
null
Name -
Name - null
Name - HiddenGeek
NaN
12
15
12
12
Name - Anna
Name - null
Name - null
Name - HiddenGeek
C,C++,JAVA,SPRING,R,PYTHON,SQL Developer, Javascript MOTIVATION and programming & coding channel.πŸ’»πŸ’»
▢️ Logical Operator Part-2: Truthy And Falsy Value in Javascript:- /** * Logical Operator with truthy and falsy values * 1. OR * 2. AND && * * Truthy * Falsy Values - "",0,null,undefined */ console.log(Boolean("Prakash")); console.log(Boolean(""));…
/**
* Nullish Coalescing in javascript?? : When the variable is null or undefined then it gives the alternative value assigned by the symbol ??
*/

let firstName;
console.log(firstName ?? "HiddenGeeks"); // Output : HiddenGeeks

let firstNullName = null;
console.log(firstNullName ?? "Nullish Coalescing Value"); // Output : Nullish Coalescing Value

let firstEmptyName = "";
console.log(firstEmptyName ?? "Nullish Coalescing Value"); // Output : (Empty String)

const a =0;
console.log(a??1); // Output : 0
▢️ Stuck issue ------------/ways to make your pc/laptop faster:-

Press start button and search Commant Prompt and run as administrator =>sfc /scannow after that 100% type : DISM /Online /Cleanup-Image /RestoreHealth Press start button and search Commant Prompt and run as administrator >> DISM /Online /Cleanup-Image /ScanHealth Press start button and search Commant Prompt and run as administrator >> chkdsk Go to search >> %temp% => delete all temp files win + R =>prefetch => delete everything Go to search >>Type disk cleanup => clean Go to search >>Type services >> Windows Update >> disable win + R =>sysdm.cpl =>> advanced => settings => click adjust for best performance
C,C++,JAVA,SPRING,R,PYTHON,SQL Developer, Javascript MOTIVATION and programming & coding channel.πŸ’»πŸ’»
#How to add kafka in our project as a container through docker: 1.a) Add this property in docker-compose.yml file located in your root folder of your project or particular module : zookeeper: image: confluentinc/cp-zookeeper:7.5.0 hostname: zookeeper…
▢️ How to push front end part of project to docker hub using dockerfile ?

1st: a) Create a DockerFile named as DockerFile in parent directory of frontend part of project,and write the following code there :

FROM node:22 AS build

WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

FROM nginx:alpine
COPY --from=build /app/dist/frontend/browser /usr/share/nginx/html

b) Also put this code after creating the .dockerignore file in the root directory of frontend part and write the following files which you wat to ignore there(in our case) following:

.angular(front_end_framework_automatically_created_folder,in my case it is .angular)
dist
node_modules



2nd : After that open terminal from any IDE and go to the path where frontend part's root folder is present,after that type the following command there :

docker build -t NameOfTheProject(in my case it is angular-frontend).

3rd: In the root folder only write the following command to tag the project as follows :

docker tag NameOfProject docker_hub_account_username/NameWithWhatNameYouWantToPushProject


4th : After tagging the project just write the following command in order to push the project into docker hub :

docker push DockerhubAccountUsername/frontend:latest

These following steps will push the frontend part of project into docker hub successfully.