This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void it_should_return_dispense_product_and_thank_you() { | |
//Given | |
Integer id = 1; | |
Product product = Product.builder().id(1).name("name").price(5.0).stock(10).build(); | |
ProductRequest productRequest = ProductRequest.builder().id(1).build(); | |
//when | |
when(coinAmount.getBalance()).thenReturn(10.0); | |
when(productRepository.findById(id)).thenReturn(Optional.ofNullable(product)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lombok.RequiredArgsConstructor; | |
import org.apache.commons.lang3.StringUtils; | |
import org.springframework.amqp.core.Binding; | |
import org.springframework.amqp.core.BindingBuilder; | |
import org.springframework.amqp.core.Queue; | |
import org.springframework.amqp.core.QueueBuilder; | |
import org.springframework.amqp.core.TopicExchange; | |
import org.springframework.amqp.rabbit.core.RabbitAdmin; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(MockitoJUnitRunner.class) | |
public class RabbitMqConfigurationTest { | |
@InjectMocks | |
private RabbitMqConfiguration queueConfiguration; | |
@Test | |
public void it_should_get_queue() { | |
//Given && //When | |
final Queue queue = queueConfiguration.queue(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.amqp.rabbit.core.RabbitTemplate; | |
public class EnqueueService { | |
private final RabbitTemplate rabbitTemplate; | |
public void enqueue(YourObject request) { | |
rabbitTemplate.convertAndSend(RabbitMqExchangeConfiguration.EXCHANGE, "", request); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(MockitoJUnitRunner.class) | |
public class EnqueueServiceTest { | |
@InjectMocks | |
private EnqueueService enqueueService; | |
@Mock | |
private RabbitTemplate rabbitTemplate; | |
@Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.amqp.rabbit.annotation.RabbitListener; | |
public class QueueListener { | |
@RabbitListener(queues = QueueConfiguration.QUEUE, | |
concurrency = "1", | |
errorHandler = "defaultRabbitListenerErrorHandler") | |
public void listener(YourObjectDto dto) { | |
//your code | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
application: | |
name: queue-api | |
rabbitmq: | |
host: localhost | |
port: 5672 | |
username: guest | |
password: guest | |
listener: | |
simple: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import timedelta, datetime | |
sys.path.append("/opt/bitnami/airflow/dags/git-d/") | |
from airflow.models import DAG | |
from Util.XSparkSubmit import spark_submit | |
from Util.SlackUtil import task_fail_slack_alert, task_success_slack_message | |
args = { | |
'owner': 'Airflow', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-amqp</artifactId> | |
<version>2.6.6</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@RequiredArgsConstructor | |
public class RabbitMqExchangeConfiguration { | |
public static final String EXCHANGE = "queue"; | |
private final RabbitAdmin rabbitAdmin; | |
@Bean | |
public TopicExchange rabbitMqExchange() { |