On Github mnimer / ESB-Presentation
Presented by: Mike Nimer@mnimer http://mnimer.github.io/ESB-Presentation
The common object that everything understands and passes around.
Java
Message message1 = MessageBuilder.withPayload("test") .setHeader("foo", "bar") .build();
Java
Message message2 = MessageBuilder.fromMessage(message1).build();
The message pipe in and out of other components (services, adapters, etc).
"A Point-to-Point Channel ensures that only one receiver consumes any given message"
XML
<int:channel id="exampleChannel"/>
"One input channel that splits into multiple output channels, one for each subscriber."
XML
<int:publish-subscribe-channel id="exampleChannel"/>
"When a messaging system determines that it cannot or should not deliver a message, it may elect to move the message to a Dead Letter Channel."
XML
<int:service outputChannel="nullChannel"/>
XML
<int:channel id="exampleChannel"> <interceptors> <wire-tap channel="logger"/> </interceptors> <int:channel>
Queue
<int:channel id="exampleChannel"> <queue capacity="25"/>/> </int:channel>
Thread Pool
<int:channel id="exampleChannel"> <task:executor id="executorWithPoolSizeRange" pool-size="5" queue-capacity="100"/> </int:channel>
Routers control the different process flows.
XML
<header-value-router input-channel="inChannel" header-name="library"> <mapping value="drewNoakes" channel="drewParser" /> <mapping value="apacheCommons" channel="apacheParser" /> </header-value-router>
XML
<bean id="payloadTypeRouter" class="org.springframework.integration.router.PayloadTypeRouter"> <property name="payloadTypeChannelMap"> <map> <entry key="com.data.User" value-ref="userChannel"/> <entry key="com.data.Product" value-ref="productChannel"/> </map> </property> </bean>
Takes in a Message and returns the name (String) of the channel to route the message to.
XML
<router input-channel="inChannel" default-output-channel="jsonChannel"method="route" > <beans:bean class="com.foo.FileRouter"/> </router>
Java
public String route(Message message){...}
Takes in a single Message and returns a list of message.
XML
<splitter input-channel="inChannel" output-channel="outChannel"method="split"> <beans:bean class="com.foo.FileSplitter"/> </spliter>
Java
public List<Post> split(Message message){...}
Uses the auto-generated header values for: correlation id, sequence number and sequence size
XML
<aggregator input-channel="inChannel" output-channel="outChannel" method="validate" > <beans:bean class="org.foo.FileAggregator"/> </aggregator>
Java
public Message verifyFiles(List<Message> message){...}
Transforms message from one format to another.
XML
<transformer id="testTransformer" input-channel="inChannel" output-channel="outChannel"method="transform"> <beans:bean class="org.foo.CustomTransformer"/> </transformer>
Java
public Message transform(Message message){...}
Used to connect the message bus to an external system and to perform any required mapping between the external system and the ESB messages.
XML
<http:outbound-gateway id="example" request-channel="requests" reply-channel="replies" url="http://localhost/test" http-method="POST" extract-request-payload="false" expected-response-type="java.lang.String" charset="UTF-8" request-factory="requestFactory" request-timeout="200"/>
XML
<int-mail:inbound-channel-adapter id="imapAdapter" store-uri="imaps://[username]:[password]@imap.gmail.com/INBOX" java-mail-properties="javaMailProperties" channel="recieveChannel" should-delete-messages="true" should-mark-messages-as-read="true" auto-startup="true"> <int:poller max-messages-per-poll="1" fixed-rate="5000"/> </int-mail:inbound-channel-adapter>
XML
<inbound-channel-adapter channel="outChannel" method="process" > <beans:bean class="org.bar.Foo"/> <poller fixed-rate="5000"/> </inbound-channel-adapter>
XML
<outbound-channel-adapter channel="inChannel" method="send"> <beans:bean class="org.bar.Foo"/> </outbound-channel-adapter>
Generic endpoint to connect a service to the messaging system. (The output channel is optional)
Java
public Message execute(Message message){...}
Java
public void execute(Message message){...}
Simple interface to allow code outside of the ESB to interact with the ESB, with zero dependenct on the Spring Integration API
XML
<si:gateway id="imageMetadataGateway"service-interface="apiserver...ImageMetadataGateway" default-reply-channel="imageMetadataChannelReplyChannel" default-reply-timeout="60"> <int:method name="getMetadataSync" request-channel="imageMetadataChannelRequestChannel"> <int:header name="library" value="drewNoakes"/> </int:method> <int:method name="getMetadataAsync" request-channel="imageMetadataChannelRequestChannel"> <int:header name="library" value="drewNoakes"/> </int:method> </si:gateway>
JAVA
public interface ImageMetadataGateway { Map getMetadataSync(ImageDocumentJob args); Future<Map> getMetadataAsync(ImageDocumentJob args); }