I am working on a MicroBlog spring mvc hibernate application. I need to implement a publish subscribe functionality like twitter.
I am using RabbitMQ for messaging with Spring AMQP abstraction.
Everywhere I see on web the pubsub examples are given involving
Spring Integration
Spring AMQP & RabbitMQ
I researched a little more on Spring-Integration & found that a publish subscribe can be implemented with it even without using RabbitMQ.
Now my question is
Why do I need to use Spring Integration with [Spring AMQP & RabbitMQ] to implement a pubsub functionality. Why can't I just use Spring AMQP with Rabbit to do that?
Does Spring integration provide any additional features?
My Spring AMQP & RabbitMQ configuration
<rabbit:connection-factory id="connectionFactory" virtual-host="/" host="localhost"
username="guest" password="guest"/>
<rabbit:admin connection-factory="connectionFactory" />
<rabbit:queue name="UserPostpublishQueue" />
<fanout-exchange name="broadcastUserPosts" xmlns="http://www.springframework.org/schema/rabbit">
<bindings>
<binding queue="UserPostpublishQueue"/>
</bindings>
</fanout-exchange>
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" exchange="broadcastUserPosts"
queue="UserPostpublishQueue"/>
</beans>
Test code in my controller
@Autowire
private AmqpTemplate amqpTemplate;
try{
amqpTemplate.convertAndSend(post);
Post receivedPost = (Post)amqpTemplate.receiveAndConvert();
System.out.println("received Post "+receivedPost);
}catch(AmqpException e){
//deal with exception
}