I've been reading up on Spring Integration and Enterprise Integration Patterns.
I'm stuck on the Messaging Bridge pattern: http://enterpriseintegrationpatterns.com/MessagingBridge.html http://static.springsource.org/spring-integration/docs/2.0.0.M3/spring-integration-reference/html/bridge.html
What's the difference between a messaging bridge and a message translator in terms of message processing? Don't they both make it possible for two entities requiring disparate formats to work together?
From a pure EIP perspective, the translator is used to transform a message within a system whereas a bridge might include transformation between different systems.
In Spring Integration the <bridge/>
implementation is simply used as a no-op component between channels.
For example, you might have a common sub-flow that starts with a channel - let's say just some small number of components culminating in an outbound adapter (e.g. FTP). You might want to re-use that sub-flow in multiple applications - you could package it up in a jar and document that it starts with, say toFTPChannel
. Now, other applications that might want to use this "component" can simply <bridge/>
their output channels to toFTPChannel
.
The bridge does nothing more than allow you to connect two channels to one another.
Another use case is in Unit/Intgration testing - for example you might bridge the final channel of an application to a QueueChannel
so the test can consume the output message and verify it's contents.