Database polling using spring integration - spring-integration

I am new to the Spring integration. Previously I developed an application using Weblogic Integration where I poll a database table for any new rows. If there is one, I obtain that data, modify it and send it to a different database. I have seen several examples on Spring integration where it integrates web pages, emails etc. I want to set up a poll for a table and get the message to the gateway from where I can handle it. Any help or advice is appreciated.

This example is the basic Db poller..
<int-jdbc:inbound-channel-adapter query="select * from item where status=2"
channel="target" data-source="dataSource"
update="update item set status=10 where id in (:id)" />
For channel 'target', you can put your service-activator to handle message.. You may also need a row-mapper..
Tell me more about your problem if you need more advice.,

See the inbound-channel-adapter in the reference documentation and/or the jdbc sample.
The sample doesn't show the use of the adapter, but it might help you with a general understanding of Spring Integration. Another useful resource is the test cases... integration tests and polling* parser tests.

Related

spring integration 4.1.x channel vs message template send operation

In Spring integration app, you can send message to channel in different ways. Two of them are, you can use channel.send(msg) and MessageTemplate.convertAndSend(channel,msg).
Can anyone tell me the difference and which is recommended? What is the drwaback of others?
There is another more high-level way to send message - #MessagingGateway, where your source client is fully free from Messaging API.
On the other hand it is up to use what to use on the matter.
The MessageChannel.send() API is very low and don't provide so much control over the message.
The MessagingTemplate can be configured as a bean with some common options like MessageConverter, which is really used by the aforementioned convertAndSend(). But in the end it is, of course, just MessageChannel.send().
There is no any recommendations, but MessagingTemplate has been introduced for convenience.

spring integration multiple stored procedure enricher pattern

I am new to spring integration. I have very specific requirement.
I have two Database to fetch.
Created two SP.
I have to get the data calling their respective stored procedure and create a JAXB object to make webservice call.
I am able to call one SP but not able to call 2nd SP. I think I can use enricher pattern but dont know how to configure.
Please help.
Well, trying to answer to your so broad question I only may suggest:
Configure <int-jdbc:stored-proc-outbound-gateway> to call first SP
Configure <int:enricher> with a request-channel for sub-flow to call the second SP similar way like a previous one
with this <int:enricher> you will be able to store additional info in some your Customer model property (which is payload) or headers
And so on until WS call.
Everything rest you can find in the Spring Integration Reference Manual and samples project.
UPDATE
I still need help.
Since it looks like you still don't understand Spring Integration principles properly, I'd suggest you to have one <service-activator> and call both stored procedures in custom code using Spring JDBC directly.
Eventually with an experience you will be able to refactor it really to separate components with the <enricher> on board.
OTOH your scenario recalls me Scatter-Gather pattern.

How to download attachments from SF(salesforce) webservice using Spring Integration (WebService Inbound Adapter)

I have a situation where I have to pull the attachments from sfdc webservice and put it into some other ftp location. I need a suggestion, if anybody faced this situation please share approach.
please help to develop this interface
thanks in advance
Samba
You question isn't clear, so that would be better to share more info on the matter and maybe some code, config.
Anyway, Spring Integration WS module is fully based on the Spring WS projects and deals exactly with the WebServiceMessage abstraction.
Which you can cast to the MimeMessage in case of MTOM enabled on request/response.
And that one getAttachments() method.
In case of Inbound Gateway you can use extractPayload = false option and receive a full WebServiceMessage as a payload in downstream flow.
When you send request to the external service and receive response with an attachments, you should take a look into custom DefaultSoapHeaderMapper extension, where you can populate your attachments into headers in the extractUserDefinedHeaders overridden method.

pass query to execute to a jdbc component

How can I have a jdbc channel adapter of gateway to execute a query that is passed through input message or its properties. Not sure if there a way to use query this way. So instead of below
<int-jdbc:outbound..
query="select * from ...."
...
I would like to have something like
<int-jdbc:outbound...
query="payload.sqlQuery"
..>
Thank you for your help.
We have a flow where the adapter need to run various queries as specified by request so i can not put the query there.
No, it isn't possible by adapters. They aren't designed for such a low-level protocol linking. It breaks a bit messaging principles.
If you really need so generic behavior of the Integration endpoint, consider to use JdbcTemplate directly from some POJO and refer it to the <service-activator>.

Implementing Spring Integration

I have to implement Spring integration, the requirement is that When I get a request I need to split it and call two seperate web services to process the request and then get the response back from both the services and combine it into one and return the response. I am not sure how to just wanted to know if someone had a clue.
And also if this is possible can I make the calls simultaneously
Looks like you don't have enough theoretical knowledges.
You need:
Splitter
Aggregator
Router
Executor Channel
So, please, read these docs:
http://martinfowler.com/books/eip.html
http://www.manning.com/fisher
http://docs.spring.io/spring-integration/docs/2.2.6.RELEASE/reference/html

Resources