Tag: spring integration

Spring Retry Junit:使用自定义重试策略测试重试模板

我正在尝试测试使用自定义重试策略的重试模板。 为了做到这一点,我使用这个例子: https://github.com/spring-projects/spring-retry/blob/master/src/test/java/org/springframework/retry/support/RetryTemplateTests.java#L57 基本上,我的目标是在我获得某些特定的http错误状态(例如http 500错误状态)时测试我的重试逻辑。 这是我的junit的xml上下文: CustomRetryPolicy就像: public class CustomRetryPolicy extends ExceptionClassifierRetryPolicy { private String maxAttempts; @PostConstruct public void init() { this.setExceptionClassifier(new Classifier() { @Override public RetryPolicy classify(Throwable classifiable) { Throwable exceptionCause = classifiable.getCause(); if (exceptionCause instanceof HttpStatusCodeException) { int statusCode = ((HttpStatusCodeException) classifiable.getCause()).getStatusCode().value(); return handleHttpErrorCode(statusCode); } return neverRetry(); } }); } public void setMaxAttempts(String […]

SpringXD和Spring Integration:每隔X分钟从kafka主题中读取一遍,然后发送到另一个主题

我正在尝试实现一个解决方案来创建一个由kafka源,桥接模块和kafka接收器组成的SpringXD流。 所以我有类似的东西: 我的问题是我想以某种方式避免使用轮询器。 基本上是因为当这些消息在队列中时我想避免将消息保留在内存中。 我宁愿每隔X分钟从kafka读取一次,只需从队列中取出Y消息,然后将这些消息发送到下一个主题。 看起来我无法摆脱队列,但后来我的问题是:还有其他选择吗? 我不喜欢把东西留在内存中,但我也不想使用这个选项: http : //docs.spring.io/spring-integration/reference/html/system-management-chapter.html#message -商店

如何在Spring集成中将XML JMS消息发送到FTP

我正在尝试使用active MQ在Spring Integration向FTP发送XML消息。 文本消息在Receiver Queue工作正常,我可以在控制台中打印消息,但是如何将此消息发送到需要存储在本地目录中的XML file中的FTP出站适配器?

Spring Integration – 可靠的TCP,适用于大批量应用

我正在使用Spring Integration for TCP服务器,它可以连接几千个客户端。 我需要服务器在负载过重的情况下限制客户端并且不丢失消息。 我的服务器配置: 由于连接工厂的默认任务执行程序是无限制的,因此我使用池化任务执行程序来防止内存不足错误。 一个简单的负载测试客户端: public class TCPClientTest { static Socket socket; static List sl = new ArrayList(); static DataOutputStream out; public static void main(String[] args) throws Exception { for (int i = 0; i < 10000; i++) { socket = new Socket("localhost", 60000); sl.add(socket); out = new DataOutputStream(socket.getOutputStream()); out.writeBytes("connection " + […]

订阅Spring Metrics频道

因此,根据Spring的文档,它将在REST端点和消息通道上发布指标。 REST端点工作正常,因为我得到了预期的结果。 但是,我想处理指标中的每个更改。 因此它表示默认情况下会将消息发布到名为“metricsChannel”的频道 我试图创建以下类来听这个频道,但它似乎没有激发。 其他所有内容都保留了Spring Boot应用程序的默认值。 package services.core; import org.springframework.stereotype.Service; import org.springframework.integration.annotation.ServiceActivator; @Service public class MetricService { @ServiceActivator(inputChannel = “metricsChannel”) public void handleMessage(org.springframework.messaging.Message message) { System.out.println(“Message [” + message.toString() + “] is received”); } }

Http Gateways和Json Transformers:剥离的标题

使用Spring Integration 4.0.3.RELEASE和Jackson2,我试图将Json Transformers与http网关结合使用。 我的路径看起来类似于Spring Integration文档中引用的amqp适配器,但是使用http gateways(1): …->对象到JSON-变压器 – > HTTP的出站网关—-> —-> HTTP的入站网关 – > JSON到对象的变压器 – > 客户: … 服务器: … 我得到的例外是(我认为相关的是粗体): 2014-08-22T23:58:21.640-0400 WARN [http-bio-8080-exec-2] osihiHttpRequestHandlingMessagingGateway网关发生故障sendAndReceive org.springframework.integration.transformer.MessageTransformationException:无法在org.springframework.integration上转换消息。 transform.AbstractTransformer.transform(AbstractTransformer.java:44)〜[spring-integration-core-4.0.3.RELEASE.jar:na] at org.springframework.integration.transformer.MessageTransformingHandler.handleRequestMessage(MessageTransformingHandler.java:68)〜 [spring-integration-core-4.0.3.RELEASE.jar:na] at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:170)~ [spring-integration-core-4.0.3.RELEASE。 jar:na] at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)〜[spring-integration-core-4.0.3.RELEASE.jar:na] at org.springframework.integration.handler。 MessageHandlerChain.ha ndleMessageInternal(MessageHandlerChain.java:131)〜[spring-integration-core-4.0.3.RELEASE.jar:na] at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)〜[spring-integration -core-4.0.3.RELEASE.jar:na] at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)~ [spring-integration-core-4.0.3.RELEASE.jar:na]在org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:101)〜[spring-integration-core-4.0.3.RELEASE.jar:na] org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch( UnicastingDispatcher.java:97)〜[spring-integration-core-4.0.3.RELEASE.jar:na] org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)〜[spring-integration-core -4.0.3.RELEASE.jar:na] at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:255)~ [spring-integration-core-4.0.3.RELEASE.jar:na] […]

使用Spring Boot和Spring集成与数据库支持的配置

对于spring boot +集成应用程序,我正在尝试从数据库加载配置,允许它通过@Value注释可以访问Spring的Environment和注入,并且可以通过外部化配置覆盖,如弹簧引导参考文档中所述。 外化配置部分 。 我遇到的问题是我的spring Integration XML包含无法解析的${input}属性占位符,因为在 Spring尝试加载XML配置之前 ,我无法加载数据库支持的配置。 应用程序的入口点: @SpringBootApplication public class TestApplication { public static void main(String[] args) { SpringApplication.run(TestApplication.class, args); } } 如何加载数据库配置: @Configuration public class DbPropertiesConfig { @Autowired private org.springframework.core.env.Environment env; @PostConstruct public void initializeDatabasePropertySourceUsage() { MutablePropertySources propertySources = ((ConfigurableEnvironment) env).getPropertySources(); try { // The below code will be replace […]

Spring集成出站网关希望像动态一样使用URL

spring集成,在outbound-gateway中想要像动态一样使用URL Requestvalues就像这样简单的POJO @Data public class Requestvalues { public String Url; public String reqMethod; } org.springframework.beans.factory.BeanCreationException:创建名为’org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler#0’的bean时出错:无法创建[org.springframework]类型的内部bean’(内部bean)#6ea2bc93’。使用key [url]设置bean属性’uriVariableExpressions’时的integration.config.ExpressionFactoryBean]; 嵌套exception是org.springframework.beans.factory.BeanCreationException:创建名为’(内部bean)#6ea2bc93’的bean时出错:通过构造函数的Bean实例化失败; 嵌套exception是org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.integration.config.ExpressionFactoryBean]:构造函数抛出exception; 嵌套exception是java.lang.IllegalArgumentException:expressionString不能为空或null

在Spring Integration中使用Transformer轮询HTTP服务(出站网关)和进程

这是我想要实现的目标。 每15分钟轮询一次HTTP API并处理从中检索的数据。 我们计划使用Spring Integration。 我是新手。 所以几乎没有理解,我已经创建了一个出站网关并添加了相同的轮询,但得到以下错误。 此外,有人可以告诉我如何使用变压器处理来自出站网关的数据? Error creating bean with name ‘org.springframework.integration.config.ConsumerEndpointFactoryBean#0’: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: A poller should not be specified for endpoint ‘org.springframework.integration.config.ConsumerEndpointFactoryBean#0’, since ‘in’ is a SubscribableChannel (not pollable). 我的int-config.xml文件是 有人能告诉我为什么会收到此错误? 先谢谢你们!

Spring Integration – 如何使用http outbound-gateway发送POST参数

我正在尝试使用Spring Integration和http outbound-gateway组合一个非常简单的HTTP POST示例。 我需要能够发送带有一些POST参数的HTTP POST消息,就像我使用curl : $ curl -d ‘fName=Fred&sName=Bloggs’ http://localhost 如果我将一个简单的String作为参数发送到接口方法,我可以使它工作(没有POST参数),但是我需要发送一个pojo,其中pojo的每个属性都成为POST参数。 我有以下SI配置: 我的RequestGateway界面如下所示: public interface RequestGateway { String echo(Pojo request); } 我的Pojo类看起来像这样: public class Pojo { private String fName; private String sName; public Pojo(String fName, String sName) { this.fName = fName; this.sName = sName; } …. getters and setters } 而我的全class学生就是这样的: public class […]