Pub/Sub Using vFabric, Spring Integration, and Gemfire
Join the DZone community and get the full member experience.Join For Free
in the next few blogs, i will be discussing how each pieces tie in together. in this blog i will be demonstrating how spring integration and vfabric gemfire participate in a typical publisher/ subscriber eip pattern, where in data is picked from source system and delivered to 1 or many target systems.
for people who are in hurry, here is the code and the steps to execute .
details: publisher, subscriber using vfabric spring integration, gemfire
this demo is the continuation of my earlier blog on claimcheck pattern . i will implement an end to end flow as below
for demo purpose, on the publisher side, the message that comes in from claimcheck output is directly bridged to the jms outbound channel adapter . but in an enterprise application, in reality there can be a spring integration flow which can do an entire workflow/ transformation/ mapping, before it puts the message onto the topic.
again for demo purpose, on the subscriber side, i just directly took the payload output from claimcheck and passed to a console based service activator. but in an enterprise application, it can be sending this to a target system.
on the publisher side, the jdbc listener is configured in the spring integration as below,
<int-jdbc:inbound-channel-adapter query="select * from notification where status=2" channel="jdbc.inbound" data-source="datasource" update="update notification set status=10 where id in (:id)"> <int:poller fixed-rate="1000" /> </int-jdbc:inbound-channel-adapter>
and you bridge this to the claimcheck channel as below,
<!-- for convenience sake we are bridging the jdbc to directly claimcheck in reality we will be going thru a si flow <int:bridge input-channel="jdbc.inbound" output-channel="common.claimcheck.in.inputchannel" /> <!-- bridge the claimcheck output directly to jms --> <int:bridge input-channel="common.claimcheck.in.outputchannel" output-channel="jms-channel.out" />
on the subscriber side, the payload is pushed to the vfabric gemfire and a guid is created on the vfabric gemfire side and it is pushed to the topic. the subscriber component picks up the payload and prints to the console. this blog explains this more in detail.
vfabric infrastructure provides a good support for developing integration components by the way of sts ide , vfabric tc server , vfabric gemfire . i have clearly demonstrated how you can build a publisher/subscriber components which can integrate a source system to target system.
i hope this blog helped you.
Published at DZone with permission of Krishna Prasad, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.