Uvod u Spring Integration
Aug 16, 2015
Uvod u Spring Integration
Agenda
• Enterprise Application Integration & Enterprise Integration Patterns
• Uvod u Spring Integration• Messaging• Osnovni patterni• Primjeri• Zaključak
Enterprise Application Integration
Aplikacije
TehnologijeProtokoli
Spring Integration
• Spring + EIP• Lightweight• Jednostavan (Spring-like)• Nije ESB• Mediation & Routing framework
Spring Integration
Message(ing)
Header
Payload
Message
Channel Endpoint
Enterprise Integration Patterns
transformer
In ChAdap
Out ChAdap
Channel Endpoints
TCP/UDP
RMI
JMS WSStream
Primjer – twitter to gtalk
#mentions
Primjer - twitter to gtalk
<bean id="twitterTemplate" class="org.springframework.social.twitter.api.impl.TwitterTemplate">
<constructor-arg value="${twitter.oauth.consumerKey}"/><constructor-arg value="${twitter.oauth.consumerSecret}"/><constructor-arg value="${twitter.oauth.accessToken}"/><constructor-arg value="${twitter.oauth.accessTokenSecret}"/>
</bean>
<twitter:inbound-channel-adapter twitter-template="twitterTemplate" channel="inboundTwitterChannel">
<int:poller fixed-rate="2000" max-messages-per-poll=“10"/></twitter:inbound-channel-adapter>
<twitter:search-inbound-channel-adapter query="#springintegration" twitter-template="twitterTemplate" channel=" inboundTwitterChannel">
<int:poller fixed-rate=“5000" max-messages-per-poll=" 10 "/></twitter:search-inbound-channel-adapter>
Primjer - twitter to gtalk<int:transformer input-channel="inboundTwitterChannel"
output-channel="outputChannel" expression="'[' + payload.getFromUser() + ']: '+ payload.getText() + ' '"/>
<int:bridge input-channel="outputChannel" output-channel="toUserChannel"> <int:poller max-messages-per-poll="1" fixed-rate="3000"/></int:bridge>
<int-xmpp:xmpp-connection id="googleTalkConnection" user="${xmpp.login}" password="${xmpp.password}" host="${xmpp.host}"
service-name="${xmpp.service}" port="${xmpp.port}"/>
<int-xmpp:header-enricher input-channel="toUserChannel" output-channel="imChannel">
<int-xmpp:chat-to value="${send.to.user}"/></int-xmpp:header-enricher>
<int:channel id="toUserChannel"/><int-xmpp:outbound-channel-adapter channel="imChannel" xmpp-connection="googleTalkConnection"/>
Primjer – database polling
<int-jdbc:inbound-channel-adapter query="select * from item where status=1" channel="inDbChannel" data-
source="pollingDataSource" update="update item set status=10 where id in (:id)"
task-executor="pool" > <int:poller fixed-rate="1000" > <int:transactional/> </int:poller></int-jdbc:inbound-channel-adapter>
Primjer – cafe
Spring Integration – zaključak
• Kada, Zašto, Što Još?
• Hvala
• Pitanja?
Kontakt
• Samir ČaušSoftware Developer
gsm +385 91 5720896mail [email protected] samircaustwitter twitter.com/samircaus
http://www.fiveminutes.eu