小编Gov*_*mar的帖子

如何使用 Airflow DAG 调用 REST 端点

我是 Apache Airflow 的新手。我想使用 DAG 调用 REST 端点。REST 端点例如

@PostMapping(path = "/api/employees", consumes = "application/json")
Run Code Online (Sandbox Code Playgroud)

现在我想使用 Airflow DAG 调用这个休息端点,并安排它。我正在做的是使用 SimpleHttpOperator 调用 Rest 端点。

t1 = SimpleHttpOperator(
task_id='post_op',
endpoint='http://localhost:8084/api/employees',
data=json.dumps({"department": "Digital","id": 102,"name": "Rakesh","salary": 80000}),
headers={"Content-Type": "application/json"},
dag=dag,)
Run Code Online (Sandbox Code Playgroud)

当我触发 DAG 时,任务失败

[2019-12-30 09:09:06,330] {{taskinstance.py:862}} INFO - Executing <Task(SimpleHttpOperator): 
post_op> on 2019-12-30T08:57:00.674386+00:00
[2019-12-30 09:09:06,331] {{base_task_runner.py:133}} INFO - Running: ['airflow', 'run', 
'example_http_operator', 'post_op', '2019-12-30T08:57:00.674386+00:00', '--job_id', '6', '--pool', 
'default_pool', '--raw', '-sd', 'DAGS_FOLDER/ExampleHttpOperator.py', '--cfg_path', 
'/tmp/tmpf9t6kzxb']
[2019-12-30 09:09:07,446] {{base_task_runner.py:115}} INFO - Job 6: Subtask post_op [2019-12-30 
09:09:07,445] …
Run Code Online (Sandbox Code Playgroud)

rest docker airflow airflow-scheduler

7
推荐指数
1
解决办法
2万
查看次数

Spring Cloud API Gateway:Resilience4j:无法找到名为 CircuitBreaker 的 GatewayFilterFactory

我正在尝试使用 Spring Cloud Resilience4j 在我的云网关上实现断路器,但出现“无法找到名称为 CircuitBreaker 的 GatewayFilterFactory ”错误。

我正在使用的依赖项

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-circuitbreaker-resilience4j</artifactId>
        </dependency>
Run Code Online (Sandbox Code Playgroud)

春云版本:

<spring-cloud.version>2021.0.0</spring-cloud.version>
Run Code Online (Sandbox Code Playgroud)

主班

@SpringBootApplication
@EnableEurekaClient
public class CloudGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(CloudGatewayApplication.class, args);
    }

}
Run Code Online (Sandbox Code Playgroud)

application.yml配置

spring:
  application:
    name: CLOUD-GATEWAY
  cloud:
    gateway:
      routes:
        - id: USER-SERVICE
          uri: lb://USER-SERVICE
          predicates:
            - Path=/users/**
          filters:
            - name: CircuitBreaker
              args:
                name: userCircuitBreaker
                fallbackuri: forward:/userServiceFallBack
        - id: DEPARTMENT-SERVICE
          uri: lb://DEPARTMENT-SERVICE
          predicates:
            - Path=/departments/**
          filters:
            - …
Run Code Online (Sandbox Code Playgroud)

java circuit-breaker spring-boot spring-cloud-gateway resilience4j

0
推荐指数
1
解决办法
1534
查看次数