Tag: spring integration

在Spring集成中,如何捕获不同的exception?

在Spring集成中,我有一个简单的tcp客户端管道:一个网关,一个tcp出站网关,一个服务激活器和一个错误通道。 在tcp-connection-factory中有一个简单的拦截器。 错误通道非常简单,我用这个filter实现了tcp-connection-event-inbound-channel-adapter: org.springframework.integration.ip.tcp.connection.TcpConnectionExceptionEvent。 所以我的error handling程序非常简单,看起来像这样: public class TcpErrorHandler { public void onException(){ System.out.println(“Exception!!! “); } } 它工作,因为当我有一个Socket关闭exception(服务器端我关闭连接),应用程序写“exception!!!” 到了控制台,但另一方面,当我有连接超时exception时,它不起作用。 我的问题是:如何为我获得所有最相关的例外: 运行时套接字关闭exception 连接超时exception 其他例外 有没有捕捉机制? 这是来自我的bean配置的snipet: 这是我的error handling程序: public class TcpErrorHandler { @Autowired private ApplicationContext appContext; public void onException(TcpConnectionExceptionEvent event){ MainService mainService = appContext.getBean(MainService.class); mainService.setSuccess(3); System.out.println(“Exception!!! “); System.out.println(event.getCause().getMessage()); } } 拦截器在这里: public class CustomInterceptor extends TcpConnectionInterceptorSupport{ […]

Spring SFTP入站chanel适配器删除本地文件

我已配置spring SFTP将文件从远程路径汇集到本地,处理一些作业,然后删除本地和远程文件。 下面的配置工作正常,除了本地文件删除,我没有找到任何删除本地文件的配置,比如delete-remote-files=”true” 这里,当文件从远程传输到本地时,调用服务激活器。 如何在服务激活器完成作业时配置删除本地文件? 编辑:远程和本地的有效负载删除都通过以下更改解决:

spring integration – 逐行读取远程文件

我正在尝试使用spring集成逐行读取远程文件。 使用此处的spring文档,我已经设置了我的项目来轮询文件,并在找到文件时通过sftp进行传输。 我被困在如何一次一行地读取文件内容。 这是我的入站通道适配器设置,目前可用于提取文件。 编辑:为了澄清,我想从远程文件一次检索一行,然后处理该行的内容,然后检索下一行。 类似于为本地文件创建java.io.inputstream并逐行读取它。 任何帮助深表感谢。 谢谢!

没有Transformer的Spring TCP客户端

我按照这个例子在Spring中设置TCP客户端。 下面是tcpClientServerDemo-context.xml所在的tcpClientServerDemo-context.xml文件。 有人可以帮我拆除变压器并按原样发送数据而不做任何修改吗? 如果我尝试删除行reply-channel=’clientBytes2StringChannel’或甚至将其reply-channel=’clientBytes2StringChannel’ null,我在构建项目时会遇到exception。 编辑: 现在我可以使用自定义序列化器/解串器发送消息。 但不幸的是,我无法收到回复。 这是我的序列化器/反序列化器: public class CustomSerializerDeserializer implements Serializer, Deserializer { protected final Log logger = LogFactory.getLog(this.getClass()); public void serialize(String input, OutputStream outputStream) throws IOException { logger.info(“inside serialize”); outputStream.write(buildSampleMsg(input)); outputStream.flush(); } public String deserialize(InputStream inputStream) throws IOException { logger.info(“inside deserialize”); final int bufferSize = 1024; final char[] buffer = new […]

Spring MqttPahoMessageDrivenChannelAdapter丢失连接:连接丢失; 重试

我们使用Spring message-driven-channel-adapter来订阅MQTT主题。 但是我们经常遇到错误。 我已经使用JavaScript客户端( mqttws31.js )测试了连接,它工作正常。 意味着连接没有问题。 错误: – org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter connectionLost SEVERE: Lost connection:Connection lost; retrying… MQTT消息: – [payload=6483D03E4C75BA943148F18D73,1.00,1E, headers={mqtt_retained=false, mqtt_qos=0, id=5fa41168-34c6-1e3d-a775-e3146842990a, mqtt_topic=TEST/GATEWAY2, mqtt_duplicate=false, timestamp=1499067757559}] 配置 : – pom.xml: org.eclipse.paho org.eclipse.paho.client.mqttv3 1.1.1 org.springframework.integration spring-integration-mqtt 4.2.2.RELEASE 在调试org.eclipse.paho.client.mqttv3-1.1.1-sources.jar : – CommsReceiver.Java public void run() { final String methodName = “run”; MqttToken token = null; while (running && […]

Spring int-xml:带路径函数的xpath-expression错误

我使用XMLSpy编写以下XPath来确定最长的字符串长度,它在XMLSpy中工作: string-length(//exception:ElementMessageAbcException/@exceptionMsg[not(string-length(.) < //exception:ElementMessageAbcException/@exceptionMsg/string-length(.))] ) 但是当我在Spring集成中将相同的字符串放入xpath-expression时,它会出错: org.springframework.beans.factory.BeanCreationException:创建名为’xpathMaxLengthExceptionMsg’的bean时出错:bean的实例化失败; 嵌套exception是org.springframework.beans.factory.BeanDefinitionStoreException:工厂方法[public static org.springframework.xml.xpath.XPathExpression org.springframework.xml.xpath.XPathExpressionFactory.createXPathExpression(java.lang.String,java.util.Map)抛出java.lang.IllegalStateException,org.springframework.xml.xpath.XPathParseException]抛出exception; 嵌套exception是org.springframework.xml.xpath.XPathParseException:无法编译[//exception:MarkitMessageAciException / @ exceptionMsg [not(string-length()<//异常:MarkitMessageAciException / @ exceptionMsg / string-length())]到XPathExpression:null; 嵌套异常是javax.xml.xpath.XPathExpressionException引起:javax.xml.transform.TransformerException:未知nodetype:string-length 示例XML:

java.lang.ClassNotFoundException:org.springframework.http.converter.json.MappingJackson2HttpMessageConverter

我在我的项目中使用spring-integration。 当我在jetty容器中部署我的应用程序时,我收到以下exception: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘integrationRequestMappingHandlerMapping’: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘inboundhttpJobRequestGateway’: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.integration.http.inbound.HttpRequestHandlingMessagingGateway]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/http/converter/json/MappingJackson2HttpMessageConverter at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) […]

在Spring Integration中处理exception时遇到问题

我是Spring集成的新手,对于如何将错误消息发送到指定的错误队列感到困惑。 我希望错误消息是原始消息上的标头,并最终在一个单独的队列中。 我读到这可以通过标头扩充器来完成,我尝试实现但没有出现在错误队列中。 另外,我是否需要一个单独的exception处理类,以便将错误消息发送到错误队列,或者我可以在转换方法中抛出exception? 这是我的xml配置: 错误类: public class ErrorHandler { public String errorHandle(MessageHandlingException exception) { return exception.getMessage(); QualityScorer类(由变换器调用): public class QualityScorer { private Hashtable table; private final static String csvFile = “C:\\Users\\john\\Test.csv”; public QualityScorer() throws Exception { table = new Hashtable(); initializeTable(); } private void initializeTable() throws Exception { BufferedReader br = null; String line […]

Spring Cloud数据流类型转换在处理器组件中不起作用?

我有一个处理器,它将byte[]有效负载转换为MyClass有效负载: @Slf4j @EnableBinding(Processor.class) public class MyDecoder { @ServiceActivator(inputChannel = Processor.INPUT, outputChannel = Processor.OUTPUT) public MyClass decode(final byte[] payload) { MyClass decoded = doStuff(payload); if (decoded != null) { log.info(“Successfully decoded!”); } return decoded; } } 我尝试创建以下DSL: some-source | my-decoder | some-sink some-source | my-decoder | some-sink some-source | my-decoder | some-sink和some-sink报告错误,因为它在classLoader中没有MyClass类。 这是预期的行为。 我尝试在my-decoder上应用类型转换,例如: some-source | […]

spring integration sftp mainframe:写文件失败; 嵌套exception为3:权限被拒绝

我正在尝试使用spring integration sftp:outbound-gateway将文件sft到大型机:这是配置: 哪里 remote.upload.filename.credit.fmpl=/!DTS4.UP.G3TRF.S60304 remote.upload.directory=/ 我得到例外: Caused by: org.springframework.integration.MessagingException: Failed to write to ‘//!DTS4.UP.G3TRF.S60304’ while uploading the file at org.springframework.integration.file.remote.RemoteFileTemplate.sendFileToRemoteDirectory(RemoteFileTemplate.java:392) at org.springframework.integration.file.remote.RemoteFileTemplate.access$500(RemoteFileTemplate.java:56) at org.springframework.integration.file.remote.RemoteFileTemplate$1.doInSession(RemoteFileTemplate.java:213) … 46 more Caused by: org.springframework.core.NestedIOException: failed to write file; nested exception is 3: Permission denied at org.springframework.integration.sftp.session.SftpSession.write(SftpSession.java:158) at org.springframework.integration.file.remote.RemoteFileTemplate.sendFileToRemoteDirectory(RemoteFileTemplate.java:385) … 48 more Caused by: 3: Permission denied at com.jcraft.jsch.ChannelSftp.throwStatusError(ChannelSftp.java:2629) […]