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);
}
}
}
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);
}
}
}
C,C++,JAVA,SPRING,R,PYTHON,SQL Developer, Javascript MOTIVATION and programming & coding channel.π»π»
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β¦
9. After that Start all the services and it will work fine as required, sending emails whenever order event is triggered and request is send from the request producer to request consumer.
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β¦
C,C++,JAVA,SPRING,R,PYTHON,SQL Developer, Javascript MOTIVATION and programming & coding channel.π»π»
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β¦
GitHub
GitHub - ksubhamkrishna/Microservices_Project_With_Api_Gateway_RestTemplate_Swagger_Kafka_Prometheus_Loki_Grafana_kubernetes: β¦
Microservices_Project_With_Api_Gateway_Using Spring_Cloud_Gateway_MVC_RestTemplate_Swagger_Kafka_Prometheus_Loki_Grafana_kubernetes - ksubhamkrishna/Microservices_Project_With_Api_Gateway_RestTempl...
βΆοΈ 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
/**
* 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
* 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
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.
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.
βΆοΈ Common JavaScript Events:
Event Attribute Description
1. onclick : Triggered when an element is clicked.
2. onmouseover : Fired when the mouse pointer moves over an element.
3. onmouseout : Occurs when the mouse pointer leaves an element.
4. onkeydown : Fired when a key is pressed down.
5. onkeyup : Fired when a key is released.
6. onchange : Triggered when the value of an input element changes.
7. onload : Occurs when a page has finished loading.
8. onsubmit : Fired when a form is submitted.
9. onfocus : Occurs when an element gets focus.
10. onblur : Fired when an element loses focus.
Event Attribute Description
1. onclick : Triggered when an element is clicked.
2. onmouseover : Fired when the mouse pointer moves over an element.
3. onmouseout : Occurs when the mouse pointer leaves an element.
4. onkeydown : Fired when a key is pressed down.
5. onkeyup : Fired when a key is released.
6. onchange : Triggered when the value of an input element changes.
7. onload : Occurs when a page has finished loading.
8. onsubmit : Fired when a form is submitted.
9. onfocus : Occurs when an element gets focus.
10. onblur : Fired when an element loses focus.
Hi Kumar Subham Krishna, Code To Cure Hackathon is here!
A 90-minute virtual challenge from Cepheid, a global molecular diagnostics leader.
Your Java and Angular skills will be tested on problems inspired by real diagnostic systems.
Top performers gain *career opportunities* at their Danaher IDC, Bengaluru.
*Register Now*: https://eej.at/AY5b2M9i
Team MyCareernet
Talent Engagement Partner, Cepheid
A 90-minute virtual challenge from Cepheid, a global molecular diagnostics leader.
Your Java and Angular skills will be tested on problems inspired by real diagnostic systems.
Top performers gain *career opportunities* at their Danaher IDC, Bengaluru.
*Register Now*: https://eej.at/AY5b2M9i
Team MyCareernet
Talent Engagement Partner, Cepheid