spring-integration 相关问题

有关Spring Integration项目的问题,请使用此标记。它不适用于将其他Spring项目与其他技术集成的一般问题。

从 XML 到 Java 的 Spring AMQP 应用程序配置

我正在努力将 RabbitMQ 应用程序配置从 XML 重写为 Java。可悲的是,一旦执行代码,就会出现非常普遍的错误: org.springframework.amqp.rabbit.listener.exception.

回答 1 投票 0

如何将身份验证标头添加到 SOAP 请求

我正在使用 Spring Integration 4.2.4.RELEASE,它似乎不想将我的授权标头添加到 SOAP 请求中。 这是相关的弹簧集成配置: 我正在使用 Spring Integration 4.2.4.RELEASE,它似乎不想将我的授权标头添加到 SOAP 请求中。 这里是相关的spring-integration配置: <ws:outbound-gateway uri="${soap.ws.url}" message-factory="messageFactory" message-sender="messageSender"/> <bean id="httpClientFactory" class="com.myorg.http.HttpClientFactoryBean"> <property name="credentials" ref="httpClientCredentials"/> </bean> <bean name="messageSender" class="org.springframework.ws.transport.http.HttpComponentsMessageSender"> <property name="credentials" ref="httpClientCredentials"/> <property name="httpClient" ref="httpClientFactory"/> </bean> <bean id="httpClientCredentials" class="org.apache.http.auth.UsernamePasswordCredentials"> <constructor-arg value="${username}"/> <constructor-arg value="${password}"/> </bean> <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"> <property name="soapVersion"> <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_11"/> </property> <property name="messageFactory" ref="myMessageFactory" /> </bean> <bean id="myMessageFactory" class="com.myorg.soap.CustomMessageFactory" /> 这是自定义消息工厂类 package com.myorg.soap; import com.sun.xml.messaging.saaj.soap.MessageFactoryImpl; import com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl; import javax.xml.soap.MimeHeaders; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPMessage; import java.io.IOException; import java.io.InputStream; /** * Custom Message Factory. */ public class CustomMessageFactory extends MessageFactoryImpl { /** * Class Constructor. * * @return Message1_1Impl * @throws SOAPException when there is a SOAP error. */ @Override public SOAPMessage createMessage() throws SOAPException { return new Message1_1Impl(); } /** * Create a new message. * * @param mimeHeaders headers to add to the message * @param in input stream to use in the message. * @return New SOAP 1.1 message. * @throws IOException when there is an IO error * @throws SOAPException when there is a SOAP error */ @Override public SOAPMessage createMessage(final MimeHeaders mimeHeaders, final InputStream in) throws IOException, SOAPException { MimeHeaders headers = mimeHeaders; if (headers == null) { headers = new MimeHeaders(); } headers.setHeader("Content-Type", "text/xml"); Message1_1Impl msg = new Message1_1Impl(headers, in); msg.setLazyAttachments(this.lazyAttachments); return msg; } } 这是自定义的 httpClientFactory 类 package com.myorg.http; import org.apache.http.auth.AuthScope; import org.apache.http.auth.Credentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.HttpClient; import org.apache.http.config.SocketConfig; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.HttpClientBuilder; import org.springframework.beans.factory.FactoryBean; /** * Provide an HttpClient factory bean, so we can configure the ODE web service client to use TLS1.1 and TLS1.2. */ public class HttpClientFactoryBean implements FactoryBean<HttpClient> { /** * Default socket timeout will be 15 seconds. */ private static final int DEFAULT_READ_TIMEOUT_MILLISECONDS = (15 * 1000); /** * Max connections defaults to 5. */ private static final int MAX_CONNECTIONS = 5; /** * Local storage for credentials. */ private Credentials credentials; @Override public HttpClient getObject() throws Exception { HttpClientBuilder builder = HttpClientBuilder.create(); SocketConfig socketConfig = SocketConfig.custom() .setSoTimeout(DEFAULT_READ_TIMEOUT_MILLISECONDS) .build(); builder.useSystemProperties() .setMaxConnTotal(MAX_CONNECTIONS) .setDefaultSocketConfig(socketConfig); if (credentials != null) { CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(AuthScope.ANY, credentials); builder.setDefaultCredentialsProvider(credentialsProvider); } return builder.build(); } @Override public Class<?> getObjectType() { return HttpClient.class; } @Override public boolean isSingleton() { return true; } public Credentials getCredentials() { return credentials; } public void setCredentials(final Credentials credentials) { this.credentials = credentials; } } 我看到的问题是授权标头似乎没有在请求中设置。我错过了什么? 我遵循 spring 消费 web 服务指南“https://spring.io/guides/gs/consuming-web-service/#initial”也有一个例子。但是没有如何添加基本授权。所以你可以这样使用 public class WebServiceMessageSenderWithAuth extends HttpUrlConnectionMessageSender { private String username; private String password; @Override protected void prepareConnection(HttpURLConnection connection) throws IOException { BASE64Encoder enc = new sun.misc.BASE64Encoder(); String userpassword = username+":"+password; String encodedAuthorization = enc.encode( userpassword.getBytes() ); connection.setRequestProperty("Authorization", "Basic " + encodedAuthorization); super.prepareConnection(connection); } } 和 public YourClient yourClient(Jaxb2Marshaller marshaller){ YourClient client = new YourClient(); WebServiceTemplate template = client.getWebServiceTemplate(); template.setMessageSender(new WebServiceMessageSenderWithAuth()); client.setDefaultUri("http://examplesap.com/xx/WebService/soap1.1x"); client.setMarshaller(marshaller); client.setUnmarshaller(marshaller); return client; } 然后打电话.. return (YourResponseModel) getWebServiceTemplate() .marshalSendAndReceive(url, request, new SoapActionCallback( "http://examplesap.com/xx/WebService/soap1.1x"));

回答 1 投票 0

在 SI 中将自定义标头添加到 MarshallingWebServiceOutboundGateway

晚上好, 我正在尝试将自定义标头添加到请求中,但到目前为止我还不太成功。我找到了使用 Http.outboundGateway(...) 的示例,但我使用的是 MarshallingWebServiceOutboundGateway....

回答 2 投票 0

如何为反应式 Spring Integration 流程编写过滤器?

我在我的集成流程中使用 RSocket 作为 InboundGateway,使用交互模型 REQUEST_CHANNEL。它发出我的业务对象的 Flux。 我可以使用 RS 来“装饰”这些对象……

回答 1 投票 0

使用 Spring 消费来自 pubsub 的消息批次

如何消费来自pubsub的多条消息?这似乎是一个简单的问题,应该有简单的解决方案,但目前我可以找到简单的方法来使用 spring-

回答 3 投票 0

Spring Integration:用网关回复消息

我有这个 Spring Integration 代码,它接收 SOAP 消息然后回复它。 这是配置: @豆 公共 MessageChannel wsGatewayInboundChannel() { 返回 MessageChannels.

回答 1 投票 0

在Spring Integration中处理输出通道后,如何让流量回到当前通道?

我在我的 spring 集成 xml 中定义了以下通道。 1. 我在我的 spring 集成 xml 中定义了以下通道。 <int:chain id="channel1" input-channel="inChannel" output-channel="outChannel"> 1. <int:service-activator method="logMessage" ref="commonHelper"/> 2. <int:service-activator method="getAbcMessage" ref="flowHelper"/> 3. <int:filter method="isApplicable" ref="flowHelper" discard-channel="nullChannel"/> 4. <int-file:outbound-gateway directory="file:${archive-dir}" filename-generator="filenameGeneratorWithId" requires-reply="true" /> 5. <int:service-activator method="fetchInfo" ref="flowHelper"/> 6. <int:service-activator method="batchMessage" ref="flowHelper"/> 7. <int:service-activator method="logMessage" ref="commonHelper"/> </int:chain> 我想运行第1、2、3、4、5行,然后将消息发送到outChannel进行处理,outChannel完成后,执行第6、7行。 这在 Spring Integration 中可能吗? 请注意,outChannel 存在于导入的 xml 文件中,该文件必须保持不变。 我已经考虑过 Splitter 和 Router,但我认为使用它们无法实现。如果我错了,请纠正我。

回答 0 投票 0

使用 Spring 集成 FTP 客户端在 Docker 中传输文件后挂起

我正在使用以下代码连接到 FTP 服务器: 公共无效发送数据(BepReport bpReport){ FtpSession ftpSession = defaultFtpSessionFactory.getSession(); StringBuilder 缓冲区 = ...

回答 1 投票 0

Spring Integration 如何返回带有异常的有效负载和建议?

我们正在使用 Spring Integration Split 和 Aggregate 来并行处理大型请求的子消息流。 对于错误流,希望流在所有子消息都处理异常时

回答 1 投票 0

有没有一种方法可以发送包含在 Spring Integration FTP 中收到的所有文件(作为 Zip)的邮件,而不是根据收到的消息单独发送文件

我有一个基于 Spring Integration FTP 的 Spring Boot 应用程序,我可以在其中下载/上传文件。 我需要发送通过邮件收到的文件(以 ZIP 格式),但问题是,我只能自己做...

回答 0 投票 0

为什么Spring Integration的TimeoutCountSequenceSizeReleaseStrategy在用户设置的时间过去后不释放消息?

在我的 SpringBoot 应用程序中,我编写了一个聚合器,如下所示。我希望在 2 分钟后立即发布消息。但是下面的代码似乎不起作用。 然而,当释放-

回答 1 投票 0

spring 集成流 dsl 性能缓慢 [关闭]

public IntegrationFlow processEvent() { 返回 IntegrationFlow.from(Consumer.class, gateway -> gateway.beanName("onMessage")) .transform(变形金刚.fromJson(

回答 0 投票 0

如何将消息对象发送到 API 接受多部分文件对象?

我希望能够将文件发送到下面的 api,而无需实际创建文件 @PostMapping(value = "/receiveFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) 公开

回答 1 投票 0

Http出站网关在工作,但没有进行调用--使用spring集成DSL java。

我是一个新手,在spring集成框架。下面是我的代码,其实我是想用SI DSL配置的HTTP出站网关进行一些HTTP调用。当我运行代码时,...

回答 1 投票 0

Sping整合邮件闲置接收的问题

我正在使用spring integration mail来接收来自几个可配置账户的邮件信息。我使用IMAP服务器和空闲配置,我写了以下代码。@Autowired private ...

回答 1 投票 1

有了TCP FailOverConnectionFactory,有没有办法做自定义的健康检查,并在故障时回落到故障转移?

我有一个Tcp FailOverConnectionFactory提供了两个AbstarctClientConnectionFactory。每个AbstarctClientConnectionFactory将连接到不同的服务器。而使用TcpOutboundGateway进行...

回答 1 投票 1

Spring集成+文件读取消息源_入站通道适配器+出站网关。

对于文件读取消息源的Inbound Adapter和带有注解的Transformer配置如下 @Bean @InboundChannelAdapter(autoStartup = "false", value = "incomingchannel", poller = @....

回答 1 投票 0

_abc.txt

入站通道适配器是通过一个轮询器来轮询存在于根目录及其子目录中的文件,例如:RootDir。

回答 1 投票 0

Spring Integration JMS--Spring代码在RuntimeException时提交了。

我想请教有经验的Spring集成开发者甚至代码作者,关于我的代码遇到的奇怪行为。问题是Spring代码在我的代码上执行COMMIT ...

回答 1 投票 0

Spring JDBC出站网关返回原始有效载荷。

使用JdbcOutboundGateway,如何让回复是原始payload?目前,响应的payload是{UPDATED=1}。无论是参考文档(Spring 5.2.x)还是源代码似乎都没有提供...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.