Asynchronous 用于编排服务的驼峰路由
我有一个基于Spring引导的微服务(PolicyService),它使用Spring Security OAuth2作为资源组件进行保护 因此,通过使用Authorization Server组件验证请求中接收到的令牌,可以检查用户是否经过身份验证 此外,在服务内部,我检查当前用户的角色,并检查请求对象的ACE(用于更新、删除和读取操作),以 确定当前用户是否具有执行目标操作所需的权限。我使用Spring安全方法级别的注释进行角色检查,并使用自定义ACL服务进行域对象级别的权限检查 一旦我确定用户已通过身份验证,并且还具有所请求操作和/或对象所需的授权, 将在数据库中创建策略 另外,我从策略服务调用ACL服务中的另一个操作,为创建的对象和用户添加ACE(访问控制条目) 如果在任何时候出现故障,我会抛出一个异常作为“拒绝访问” 现在,我想使用基于ApacheCamel的组合服务来编排此服务 我想知道是否最好分开使用ACL服务检查授权的步骤 以及在创建策略后添加ACL条目,作为Apache camel中的单独步骤 到目前为止,它们都由策略服务使用 此外,我现在需要对正在创建的策略进行验证,这目前非常耗时,因此我希望通过向队列发送事件来使用消息传递,该队列将由一个服务监控,该服务将验证和更新数据库,并根据验证结果相应地发送邮件 我想知道是否最好将这些不同的功能提取为驼峰路线中的单个步骤,如下所示,或者在策略服务中使用它们 如果我将角色检查提取到复合服务中,这意味着我需要将Spring安全性添加到基于Spring引导的ApacheCamel复合服务中,以保护该服务 我目前使用Spring安全方法级别注释和自定义ACL服务执行ACL权限检查(不是针对创建,而是针对其他操作)。我相信我现在可能需要在驼峰服务中以不同的方式重新编写逻辑 另外,使用异步、消息传递或使用事件源引发自定义事件来调用策略验证服务的更好方法是什么 另外,Apache Camel中是否支持使用事件源和异步服务调用来引发自定义事件 我目前在Camel中有一条如下设计的路线Asynchronous 用于编排服务的驼峰路由,asynchronous,spring-boot,apache-camel,messaging,rx-java,Asynchronous,Spring Boot,Apache Camel,Messaging,Rx Java,我有一个基于Spring引导的微服务(PolicyService),它使用Spring Security OAuth2作为资源组件进行保护 因此,通过使用Authorization Server组件验证请求中接收到的令牌,可以检查用户是否经过身份验证 此外,在服务内部,我检查当前用户的角色,并检查请求对象的ACE(用于更新、删除和读取操作),以 确定当前用户是否具有执行目标操作所需的权限。我使用Spring安全方法级别的注释进行角色检查,并使用自定义ACL服务进行域对象级别的权限检查 一旦我确定
<route id="createPolicy">
<from uri="direct:createPolicy"/>
<!-- Check if User has the Role(s) required for this operation , handled internally by Policy Service using Spring Security-->
<bean ref="aclClientBean" method="checkRoleForCreatePolicy(${body})"/>
<!-- Create a Policy using Policy Service -->
<bean ref="policyClientBean" method="createPolicy(${body})"/>
<!-- Add ACE for Policy Instance and Current User using ACL Service , handled internally by Policy Service using ACL Service-->
<bean ref="aclClientBean" method="addACLForPolicy(${body})"/>
<!--Validating the Policy Details-->
<!-- Option 1:Send a message to a configured Policy Validation Queue which is monitored by Policy Validation Service -->
<!-- Option 2:Send a event that Policy is created, whoever interested on Policy Creation Event will subscribe to the event
and act accordingly when notified -->
<!-- Option 3:Asynchronously invoke the Policy Validation Service and validate the passed details -->
<bean ref="policyValidationClientBean" method="validatePolicyDetails(${body})"/>
<onException>
<exception>com.company.application.exception.AuthException</exception>
<handled>
<constant>true</constant>
</handled>
<to uri="direct:authException"/>
</onException>
<onException>
<exception>com.company.application.exception.APPException</exception>
<handled>
<constant>true</constant>
</handled>
<to uri="direct:appException"/>
</onException>
</route>
<route id="authException">
<from uri="direct:authException"/>
<log message="Access Denied."/>
<bean ref="policyOrchestratorClientBean" method="handleFailure('Access Denied.')"/>
</route>
<route id="appException">
<from uri="direct:appException"/>
<log message="Exception invoking Service"/>
<bean ref="policyOrchestratorClientBean" method="handleFailure('Exception invoking Service')"/>
</route>
com.company.application.exception.AuthException
真的
com.company.application.exception.APPException
真的