Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
java.nio.channels.AcceptPendingException

Ehab Qadah ehabqadah

💭
java.nio.channels.AcceptPendingException
View GitHub Profile
View Dockerfile
# Build layer
FROM maven:3.6.3-adoptopenjdk-11 as build
LABEL maintainer="ehabqadah@gmail.com"
ARG GIT_COMMIT
ARG ENVIRONMENT
LABEL service=demo \
stage=build \
View jdbc.properties
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.jdbc.time_zone=UTC
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/${MYSQL_DB:local_db}?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
spring.datasource.username=${MYSQL_USER:local_user}
spring.datasource.password=${MYSQL_PASSWORD:P@ssowrd1}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.show_sql=${SHOW_SQL:false}
spring.jpa.properties.hibernate.jdbc.batch_size=${JDBC_BACTH_SIZE:10}
View management.properties
management.health.probes.enabled=true
management.endpoint.health.show-details=always
management.endpoint.health.group.readiness.include=*
management.endpoint.health.group.readiness.show-details=always
management.endpoint.health.group.liveness.include=ping
management.endpoint.health.group.liveness.show-details=always
View probes.yaml
......
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 50
periodSeconds: 10
timeoutSeconds: 2
readinessProbe:
httpGet:
View OrderIncomingDto.java
/**
* Incoming DTO to create a new record of {@link com.qadah.demo.data.model.Order}
*
* @author Ehab Qadah
*/
public class OrderIncomingDto {
@JsonProperty(required = true)
@NotEmpty
@NotBlank
View GeneralExceptionHandler.java
/**
* * Handle all exceptions and java bean validation errors
* for all endpoints income data that use the @Valid annotation
*
* @author Ehab Qadah
*/
@ControllerAdvice
public class GeneralExceptionHandler extends ResponseEntityExceptionHandler {
public static final String ACCESS_DENIED = "Access denied!";
View BaseIdentifierGenerator.java
/**
* A custom Id generator based on combination of long time hex string and UUID
*
* @author Ehab Qadah
*/
public class BaseIdentifierGenerator extends UUIDGenerator {
private static final int NUMBER_OF_CHARS_IN_ID_PART = -5;
@Override
View BaseEntity.java
/**
* <p> Root entity for object persistence via JPA.</p>
*
* @author Ehab Qadah
*/
@MappedSuperclass
public abstract class BaseEntity {
@Id
@GeneratedValue(generator = "custom-generator",
View OrderController.java
/**
* @author Ehab Qadah
*/
@RestController
@RequestMapping(path = {"/api/v1/orders"}, produces = APPLICATION_JSON_VALUE)
public class OrderController {
private static final Logger logger =
LoggerFactory.getLogger(OrderController.class);
@ehabqadah
ehabqadah / SlackApiClient.java
Last active May 5, 2020
Spring boot java slack API client to send messages and reply to it (thread) with retries
View SlackApiClient.java
package com.qadah.slack;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpEntity;