Spring integration 重载用于审核目的的MessageHistory对象
我需要审核通过spring集成流的每个消息,非常基本的消息 应用程序从int-redis:queue入站通道适配器读取数据,并在int-http:outbound网关中写入数据 输出网关有一个应答通道,以便接收http方法的响应,此时正是我想要注册反审核信息的时候,包括初始消息和http响应 如果http方法失败,消息将转到errorHandler,我可以获得带有时间戳和有效负载的历史对象,这对于审计来说是完美的 但是如果http方法起作用(代码200201…),我会收到一条包含ResponseEntity对象和状态代码的消息,但我没有从redis获得初始负载 那么,有没有办法对这两条消息(在发送http出站之前和http响应之后)进行corelate,以便获得用于审计的完整信息 提前谢谢 这里是集成流程:Spring integration 重载用于审核目的的MessageHistory对象,spring-integration,Spring Integration,我需要审核通过spring集成流的每个消息,非常基本的消息 应用程序从int-redis:queue入站通道适配器读取数据,并在int-http:outbound网关中写入数据 输出网关有一个应答通道,以便接收http方法的响应,此时正是我想要注册反审核信息的时候,包括初始消息和http响应 如果http方法失败,消息将转到errorHandler,我可以获得带有时间戳和有效负载的历史对象,这对于审计来说是完美的 但是如果http方法起作用(代码200201…),我会收到一条包含Response
<int:message-history/>
<int:channel id="responseChannel"/>
<int:channel id="responseError"/>
<int:logging-channel-adapter channel="responseChannel" level="INFO"
expression="@messageHandlerSpel.handle( #this )" id="logger"/>
<int:logging-channel-adapter channel="responseError"
level="ERROR" expression="@errorHandlerSpel.handle( #this )"
id="LogingERROR"/>
<int-redis:queue-inbound-channel-adapter id="inputRedis" connection-factory="redisCF"
channel="redisInput" queue="redis-input" serializer="" error-channel="responseError"/>
<int:channel id="redisInput" />
<int-http:outbound-gateway id="HttpOutbound" request-channel="redisInput"
url="http://{server}:{port}/{index}/{type}/{id}"
http-method="PUT" extract-request-payload="true" charset="UTF-8"
reply-channel="responseChannel" request-factory="requestFactory"/>
和处理程序类:
@Component
public class MessageHandlerSpel {
public String handle(Message<byte[]> message) {
MessageHeaders msgH = message.getHeaders();
MessageHistory msgHistory =
message.getHeaders().get(MessageHistory.HEADER_NAME, MessageHistory.class);
... // Do whatever
return "";
}
@组件
公共类MessageHandlerSpel{
公共字符串句柄(消息){
MessageHeaders msgH=message.getHeaders();
MessageHistory msgHistory=
message.getHeaders().get(MessageHistory.HEADER_NAME,MessageHistory.class);
…做什么都行
返回“”;
}
一个技巧是在执行HTTP请求之前将请求有效负载
存储在自定义头中
在接收到响应后,请求头将与该响应有效负载
合并。因此,在下游,您将同时拥有两个:头中的请求和有效负载
中的回复
MessageHistory
保持不变,没有理由在那里进行黑客攻击
另一种方法是基于
来关联请求和应答,但这种方法适用于更复杂或分布式的场景
通过以下方式将简单的复制/粘贴到标题:
<header-enricher>
<header name="requestPayload" expressio="payload"/>
</header-enricher>
应该足够了。一个技巧是在执行HTTP请求之前,将请求
负载
存储在自定义头中
在接收到响应后,请求头将与该响应有效负载
合并。因此,在下游,您将同时拥有两个:头中的请求和有效负载
中的回复
MessageHistory
保持不变,没有理由在那里进行黑客攻击
另一种方法是基于
来关联请求和应答,但这种方法适用于更复杂或分布式的场景
通过以下方式将简单的复制/粘贴到标题:
<header-enricher>
<header name="requestPayload" expressio="payload"/>
</header-enricher>
应该足够了。Perfecta和清洁溶液,谢谢Artem!Perfecta和清洁溶液,谢谢Artem!