spring-integration , How to handle timeout exception when using jms outbound gateway?

How to handle timeout exception when using jms outbound gateway?


Tag: spring-integration

I have a jms outbound gateway like this:

<jms:outbound-gateway request-destination = "requestQueue"

In my spring integration flow I send requests to 'sendToJmsChannel' and handle replies from 'receiveFromJmsChannel'

The question is, how can I handle the case when the receive-timeout is elapsed and no reply was returned to the reply-destination?


The JmsOutboundGateway thorws:

throw new MessageTimeoutException(message,
                        "failed to receive JMS response within timeout of: " + this.receiveTimeout + "ms");

In case of that timeout (5 sec by default).

You can configure <retry-advice> within <request-handler-advice-chain> for the <jms:outbound-gateway> to resend the same message to the request-destination on that MessageTimeoutException. Or just handle it from the caller with regular try...catch, or in the ErrorHandler on the error-channel, if your flow starts from the <poller> or message-driven-ednpoint.

Otherwise it isn't clear what is your goal. The Exception in the Spring Integration doesn't provide more complexity as it is in the typical Java application.


Publisher should wait till broker is available

I have a simple publisher, which sends messages to a queue. <int:channel id="publishChannel"/> <int-jms:outbound-channel-adapter channel="publishChannel" destination="testQueue" session-transacted="true"/> @Publisher(channel = "publishChannel") public String sendMessage (String text) { return text; } If the broker crashes, the publisher throws an MessageHandlingException. Is it possible to block the publisher, till the broker is available...

Spring Integration - @Filter discardChannel and/or throwExceptionOnRejection being ignored?

I have a java DSL based spring integration (spring-integration-java-dsl:1.0.1.RELEASE) flow which puts messages through a Filter to filter out certain messages. The Filter component works okay in terms of filtering out unwanted messages. Now, I would like to set either a discardChannel="discard.ch" but, when I set the discard channel, the...

Spring Integration Java DSL - @ServiceActivator method with @Header parameter annotations

I have a Spring Integration 4 bean method with the following signature: @Component public class AService { @ServiceActivator public Message<?> serviceMethod( Message<?> message, @Header(ServiceHeader.A_STATE) AState state, @Header(ServiceHeader.A_ID) String id) { ... } ... } At the moment, I call this service method from within a Spring Integration Java DSL (spring-integration-java-dsl:1.0.1.RELEASE)...

Syntax error on tokens, delete these tokens - kafka spring integration demo application

I am trying to use the demo application for spring kafka integration and getting an "syntax error on token, delete these token" error in eclipse. looks to be simple one, but i dont know how to fix. errors at return args -> @Bean @DependsOn("kafkaOutboundChannelAdapter") CommandLineRunner kickOff(@Qualifier("inputToKafka") MessageChannel in) { return...

How to convert Spring Integration XML to Java DSL for errorChannel

I have the below xml configuration in my application and I would like to convert it to the Java DSL. So in this reference I'm explicitly defining the name for the error channel. Mostly for example reason. With this reference what I'm expecting to happen is when a downstream process...

spring-integration-dsl-groovy-http return null when i use httpGet method

I use spring integration 4.1.4 and spring integration dsl groovy 1.1.0 I included spring integration core, http in dependency. When i am executing spring integration dsl groovy http sample, it throwing null value in console. I am not sure what i missed. Here is my code looks like IntegrationBuilder builder...

Sending mail with a custom MIME Message using Camel

I want to send a multipart MIME message (custom headers, plain text and HTML) using Camel. I can see in the source code that if I send a javax.mail.internet.MimeMessage in the body of a Camel message to the mail component, it send it without creating a new one. But in...

having spring integration tcpserver to manage clients and send them messages

I have already created a simple tcp server with spring integration which keeps a connection alive and responses to each request during the connection. In that requestMethod, I'm also able to read the MessageHeder to get the connectionId. Now I want to send messages from the server to the client....

how should a message look like to be a response

I have read and followed the example in http://docs.spring.io/spring-integration/reference/html/ip.html#ip-correlation I have a spring-integration server <int-ip:tcp-connection-factory id="socketserver" type="server" port="30124" using-nio="true" mapper="mapper" deserializer="jsonSerializer" serializer="jsonSerializer" single-use="false"/> with this mapper from above link: <bean id="mapper" class="org.springframework.integration.ip.tcp.connection.MessageConvertingTcpMessageMapper"> <constructor-arg...

Send Mail using Spring MVC

I have a custom MailDto object in which I set the to,cc, bCc field and send it using RestTemplate to Spring MVC controller as below @RequestMapping(value = "/SendMail" ) public ResponseEntity<String> SendMail( @RequestBody MailMessageDto mailDto) throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException From the controller I invoke the Gateway (Spring integration). The...

spring-integration perform ftp from various source

Is it possible to download files from various source directory of multiple servers via spring-integration channel adapters. To be more clear, I have situation Server A Dirs A,B,C,D I need to download it in P,Q,R,S dirs on client and after successful download remove source dirs. Is that possible via JAVA...

How to send basicAck to inbound adapter after publisher confirm from outbound adapter

We have an inbound channel adapter that receives notifications of an event. The complexity of the consumer's criteria restrict our ability to use a simple routing key to distribute the messages, so the application uses a splitter to send that message to interested subscriber's queues via a direct exchange. We...

How to catch socket exceptions on TcpInboundGateway?

I'm using TcpInboundGateway from spring-integration for a socket client. In TcpInboundGateway.doOnMessage() the stream is send via the socket connection. If an exception occurs eg because the socket is closed, there is just a spring error log "Failed to send reply". BUT I'd like to handle those socket errors explicit. How...

can a jms inbound gateway reply include all messages of a message sequence

I have a jms-inbound-gateway that reads requests from a WebsphereMQ broker and passes them though my integration system which returns a message sequence as reply. The message sequence is obtained by applying the splitter on a collection. It generates 63 messages as shown in the log. The problem is that...

Getting Class cast exception after upgrading Spring Integration version

I have a Spring Integration Application which polls for data from AS400 DB picks it and then after some modification transmit it to MQ. It was running fine until I decided to upgrade Spring Integration version. I am getting below error after upgrading from version - spring-integration-core-2.2.3.RELEASE to spring-integration-core-3.0.1.RELEASE. Caused...

Serialization error using a jdbc-message-channel

I'm using a channel backed by a jdbc-message-store but I'm having a serialization error when storing the message. The message payload is a simple String. Here's my config and stacktrace: <bean id="auditMessageStoreQueryProviderBean" class="org.springframework.integration.jdbc.store.channel.MySqlChannelMessageStoreQueryProvider" /> <bean id="auditMessageStore" class="org.springframework.integration.jdbc.store.JdbcChannelMessageStore"> <property name="dataSource" ref="auditMessageStoreDataSource" /> <property...

Spring Integration: poll files based on creation date / time

Using Spring Integration, I need to pick up input messages from a directory. This is a CIFS / Samba shared folder that I only have read-only access to, so I need to find a way to pick up only new files while not needing to delete them. Default AcceptOnceFileListFilter behavior...

Which Spring Integration Channel should be used for MQTT

I am trying a demo app where we send commands over a UI which then goes through spring integration to deliver a command to a device and gives a command status back to UI, this is my first time using Spring Integration and am a bit unsure of the various...

Spring-integration scripting with Python

I'm trying to use Python with spring-integration and jython-standalone-2.7.0: Here is my application context: <int:inbound-channel-adapter id="in" channel="exampleChannel" > <int:poller fixed-rate="1000" /> <int-script:script lang="python" location="script/message.py" /> </int:inbound-channel-adapter> <int:channel id="exampleChannel" /> <int-ip:udp-outbound-channel-adapter id="udpOut" channel="exampleChannel" host="" port="11111" /> Here is my script in Python: print "Python"...

Is there any workaround for using channel name with dash character using spring integration 4 without xml?

I upgraded my spring integration 3.x to 4.x. And I removed all xml configuration and replace to java annotation in pojo files. But the problem is.. I want to use the channel name with '-' character. It is very good to recognize and distinguish each words in name. Besides, if...

Spring Integration with RESTEasy

In our existing integration, we are planning to replace Queue ( the entry point to our integration processing) with RESTEasy services. We are processing the HTTP requests as below: 1) Asynchronous HTTP Request Processing for GET 2) Asynchronous Job Service for POST I understand that spring integration provides and for...

Spring Integration, change udp-outbound-channel port

I'm using spring integration to send line of files in UDP. Here is what I'm doing: <int-file:inbound-channel-adapter prevent-duplicates="false" id="filesIn" directory="file:input" channel="inputFiles"> <int:poller default="true" fixed-rate="1000" /> </int-file:inbound-channel-adapter> <int:splitter input-channel="inputFiles" output-channel="output"> <bean class="fr.spring.demo.FileSplitter"> <property name="commentPrefix" value="#" /> </bean> </int:splitter> <int:transformer...

Spring Integration input file adapter - Where/when should file contents enter message payload?

I'd started a Spring Integration project using a file-based inbound-channel-adapter and so far it's working well. But I realized that I don't seem to have implemented the concept correctly and would like to seek some advice here on how to correct it. In the Spring XML declaration, the adapter is...

Failure to remove a file using an outbound-gateway

Im trying to use an sftp outbound gateway to delete a specific log file on a remote sftp. <int-sftp:outbound-gateway id="removeSourceGateway" session-factory="sftpCachingSessionFactory" reply-channel="outputChannel" request-channel="afterSuccessBackupChannel" requires-reply="false" command="ls" expression="'/export/logs/'" remote-directory="${sftp.remote.dir}"> </int-sftp:outbound-gateway> If I execute a LS or PUT command in the configuration above, then I get the expected content - see below for...

What is the correct way to make use of correlated messages for TcpOutboundGateway connection to a legacy server

My understanding is that TcpOutboundGateway is correlating a tcp request and response, but I am not sure how to use this. The snippet below sends a message via a TcpOutboundGateway to communicate with a legacy system. message = new GenericMessage("ccs?cmd=5&itm="+(16600+t)+"&rf=2"); Test.sendChannel.send(message); // sendChannel is a DirectChannel. //Blocks here until reply...

Spring integration-graph: It is posible to show components within profiles or imports?

I'm used to work with a spring-context.xml with a "beans" root tag, where I write the whole app configuration. That way, I can see integration-graph from STS 3.6.4. Now I want to divide some components of my app for testing purposes. First, I tried to separe the different components and...

Spring integration - need immediate response from webservice gateway with asynchronous processing in backend

We have a requirement where the external client are calling one of our spring integration inbound webservice gateway and we need to acknowledge them right away with a generic OK status. Meanwhile, the payload will be submitted to a channel for asynchronous processing and we don't need the response(email will...

Is the Spring Integration project inactive?

I'm looking into Spring Integration but the last bibliography I see on the subject is from 2012. It seems as if the project is dead. Is this the case?

Continuing with Spring integration flow after SoapFault

Our application integration flow is defined as splitter -> ws gateway -> aggregator The splitter splits request into a list of account numbers; so that for each account number a web service call is initiated and the responses from multiple web service calls are aggregated in the aggregator.The channel between...

Which bean can I use as a alternative one of http-outbound-gateway?

I am changing spring-integration 3.x to 4.x. And I should change every xml configuration to the java file. But, I can't find the bean that can be replaced in place of the followings. <int-http:outbound-gateway url="http://www.google.com/ig/api?weather={city}" http-method="GET" expected-response-type="java.lang.String" request-factory="requestFactory" request-channel="requestChannel" reply-channel="replyChannel"> <int-http:uri-variable name="city" expression="payload"/> </int-http:outbound-gateway> <bean...

jdbc backed channel on a cluster mode

I want to use the jdbc backed message channel. Reading the doc says that it is supported but after that I found a thread in the forum that explicitly says don't. Could you please clarify me if it's supported? In this case, could you guide me to do so? thanks...

Maximum simultaneous connection when using ftp adapter

What can I tweak to solve this maximum connection problem? Any ways to specify a limit? This is from a Spring Integration application. <int-ftp:outbound-channel-adapter id="matasLiveProdSdkOutbound" channel="ftpOutboundChannel" session-factory="ftpsSessionFactory" charset="UTF-8" auto-create-directory="true" use-temporary-file-name="false" remote-file-separator="/" remote-directory-expression="${egnyte.remote.dir}" mode="IGNORE"> </int-ftp:outbound-channel-adapter> This is the error I get: Caused by:...

spring integration java dsl: how to expand a uri-variable in a Simp destination header

I use a mix of spring-mvc websocket support and spring-integration java dsl. I have an integration flow responsible to send messages to websocket-stomp subscribers using AbstractBrokerMessageHandler. The destination is /topic/notifications/{tenantId} where tenantId is a member of the payload I want to send to subscribers. In spring-integration xml dsl uri-variable subElement....

Spring Integration and returning schema validation errors

We are using Spring Integration to process a JSON payload passed into a RESTful endpoint. As part of this flow we are using a filter to validate the JSON: .filter(schemaValidationFilter, s -> s .discardFlow(f -> f .handle(message -> { throw new SchemaValidationException(message); })) ) This works great. However, if the...

Spring Integration: SMTP server

I am using Spring Integration 4.1.2. In the program flow, at the end of a process I need to send an email. I am using the following: <int:payload-type-router input-channel="response.in"> <int:mapping type="java.lang.String" channel="response.out"/> <int:mapping type="org.springframework.mail.SimpleMailMessage" channel="mail.out"/> </int:payload-type-router> <mail:outbound-channel-adapter channel="mail.out" mail-sender="mailSender"/> This is working fine. I want to also handle the situation...

Spring integration Splitter task execution

I'm working on a Spring Integration application. I have an inbound channel adapter that read a directory Then a splitter that split the File into lines Finally an udp outbound channel adapter that sends the lines <int-file:inbound-channel-adapter prevent-duplicates="false" id="filesIn" directory="file:input" channel="inputFiles" /> <int:splitter input-channel="inputFiles" output-channel="udpChannel_11111" expression="T(org.apache.commons.io.FileUtils).lineIterator(payload)" /> <!-- Define UDP...

Spring Integration Async Gateway Response Handling

I need some hint how to solve a problem with Spring Integration. I have a Gateway interface. public interface OrderGateway { Future<Response> process(Request value); } I send a request message via the gateway. The ValidationService should check if the data is correct. If yes it should forward the message to...

Return last value query in MongoDB in Spring XD Source module

I would like to be able to create a query/query-expression that I can use in SprinXD MongoDB Source module to return only the last document that has been inserted. It seems that max-messages-per-poll doesn't do the trick (paginated data with the help of mongo inbound adapter in spring integration) I...

Delete File after successful persist to MongoDB in Spring Integration

I have a Spring Integration flow that reads a csv file from a directory, splits the lines, then processes each line and extracts 2 objects from each line. These two objects are then send to two seperate int-mongodb:outbound-channel-adapter. I want to delete the incoming file after all of the lines...

spring-integration: Error handling on inbound adapters

Basics: Using spring 4.1.1 with integration, boot and 1.0.0 of the DSL. Multiple inbound SFTP adapters on different schedules fetching files from different vendors. Each integration flow attaches headers to the message after the files are downloaded to identify the vendor source. Use a MessagePublishingErrorHandler to handle exceptions. Standard message...

Error while sending message to turn on Spring Integration inbound adapter using ControlBus

This is my first attempt using ControlBus to turn inbound channel adapters on/off. To make it simple, I'm sending my control message by writing an empty file into a directory watched by a inbound file adapter (this one is perpetually turned on), which I then route to a service activator...

Spring Integration - how to pass parameters into service activator

I want to send an email once an SFTP upload is completed ... I have an SFTP uploader: <sftp:outbound-channel-adapter id="sftpOutboundAdapter" channel="inputFiles" charset="UTF-8" remote-directory="${directory.remote}" session-factory="sftpSessionFactory"> <sftp:request-handler-advice-chain> <bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice"> <property name="onSuccessExpression" value="payload.delete()"/> <property name="successChannel"...

spring integration vs spring batch [on hold]

We have application where we are receiving file every day and it needs to be parsed and persist in db. File has 5000 record. Should we use spring batch or spring integration? And why? we do need to skip bad record and audit them....

Limit the output of jsch in Spring integration

I am trying to limit the output of the com.jcraft.jsch package in my Spring Boot applicatoin. My application uses Spring Intgration and has a log4j.properties files defining the following log levels # Root logger option log4j.rootLogger=DEBUG log4j.category.com.jcraft.jsch=ERROR log4j.category.org.springframework.integration.file=ERROR And still, I get a whole lot of INFO levelled messages from...

Spring Integration 4 - How to set a Gateway's replyTimeout value dynamically?

My Gateway looks like this ... @MessagingGateway public interface MyGateway { @Gateway(requestChannel = "startChannel", replyTimeout = 1000L) ListenableFuture<Boolean> myFlow(); } I use an application.yml file to define some properties which I use throughout my application. One of those is a timeout value. I would like to make MyGateway's replyTimeout parameter...

JAXB marshalling exception; nested exception is javax.xml.bind.MarshalException

I am reading data from the file and validating the number and calling webservice.I am getting following error while calling webservice. [org.springframework.integration.ws.MarshallingWebServiceOutboundGateway] org.springframework.integration.ws.MarshallingWebServiceOutboundGateway#0 received message: GenericMessage [payload=1000213569, headers={timestamp=1432121523488, id=fbdb4e0d-d124-1620-8b41-c8dfea69069c, correlationId=e68bb811-7e9e-b86b-0b28-c24a2e3c02c0, sequenceSize=0, sequenceNumber=2}] 14:32:03.488 DEBUG...

How to concatenate a string with SpEL in SpringXD Stream Definition

I'm trying to create a stream definition that uses two payload fields joined together to create a concatenated string. stream create --name blah --definition "http | gemfire-json-server --keyExpression=payload.getField('deviceId') + payload.getField('timestamp')" --deploy` The concatenation piece in the keyExpression is incorrect, what should it be to get it to work inline?...

Spurious error “Cannot correlate response - no pending reply” using TcpOutboundGateway and CachingClientConnectionFactory

I am getting spurious correlation errors using TcpOutboundGateway with CachingClientConnectionFactory in a multithreaded context. The log message is: 2015-05-26 14:50:38.406 ERROR 3320 --- [pool-2-thread-2] o.s.i.ip.tcp.TcpOutboundGateway : Cannot correlate response - no pending reply I do not get the error when sending from a single thread, and I have tested and...

Spring integration FileTailingMessageProducer: Remember current line when restarting

We are using the Spring integration FileTailingMessageProducer (Apache Commons) for remotely tailing files and sending messages to rabbitmq. Obviously when the java process that contains the file tailer is restarted, the information which lines have already been processed is lost. We would like to be able to restart the process...

Spring Integration - including payload in errors

I'm trying to include the inputMessage payload in errors, but it seems it's never being passed on and enriching doesn't seem to work either. I have a directory polling service: <file:inbound-channel-adapter id="incomingFiles" auto-startup="true" auto-create-directory="false" channel="myFiles" filename-pattern="${directory.local.pattern}" directory="file:${directory.local}"> <int:poller id="poller" fixed-delay="${directory.local.poll}"/> </file:inbound-channel-adapter> These files are then being uploaded via SFTP:...