Skip to content

Instantly share code, notes, and snippets.

View robsonkades's full-sized avatar
🎯
Focusing

Robson Kades robsonkades

🎯
Focusing
View GitHub Profile
record StatusTransition(InvoiceStatus current) {
public void validate(InvoiceStatus next, String invoiceId) {
if (!current.canTransitionTo(next)) {
throw DomainException.with(Message.INVOICE_TRANSITION_NOT_ALLOWED, invoiceId, current, next);
}
}
}
import org.springframework.stereotype.Component;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.Serial;
import java.io.StringReader;
import java.util.ArrayDeque;
import org.springframework.web.client.RestClient;
public record WebServiceClient(RestClient restClient, CloseableResources closeableResources) {
}
import org.springframework.http.ResponseEntity;
import java.util.concurrent.CompletableFuture;
public interface WebService {
@RestController
@RequestMapping
public class MessageController {
private final AzureServiceBusTemplate serviceBusTemplate;
public MessageController(AzureServiceBusTemplate azureServiceBusTemplate) {
this.serviceBusTemplate = azureServiceBusTemplate;
}
@PostMapping
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.EventListener;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import io.micrometer.core.aop.TimedAspect;
import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import java.time.Duration;
spring:
application:
name: agendador-distribuido
datasource:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver #org.postgresql.Driver
password: ${SQL_PASSWORD:Sqlserver!@#} #postgres
url: ${SQL_JDBC:jdbc:sqlserver://localhost:1433;encrypt=false;databaseName=master;encrypt=true;trustServerCertificate=true;sendStringParametersAsUnicode=false;ApplicationName=App} #jdbc:postgresql://localhost:5432/postgres
username: sa #postgres
hikari:
connection-timeout: 250 # É uma configuração em milliseconds. O ideal é manter baixo para que estoure timeout logo e não prenda as threads.
spring.quartz.auto-startup=true
spring.quartz.job-store-type=jdbc
spring.quartz.jdbc.initialize-schema=never
spring.quartz.startup-delay=30s
spring.quartz.wait-for-jobs-to-complete-on-shutdown=true
spring.threads.virtual.enabled=true
logging.level.org.quartz=DEBUG
spring.quartz.scheduler-name=quartzScheduler
spring.quartz.properties.org.quartz.scheduler.instanceId=AUTO
spring.quartz.properties.org.quartz.jobStore.useProperties=true
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.XMLConstants;
import javax.xml.crypto.AlgorithmMethod;
import javax.xml.crypto.KeySelector;
import javax.xml.crypto.KeySelectorException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.XMLConstants;
import javax.xml.crypto.AlgorithmMethod;
import javax.xml.crypto.KeySelector;
import javax.xml.crypto.KeySelectorException;