5
votes

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
        }
1
Why just don't follow with some Google links and don't read about both a bit?..Artem Bilan
If there was enough on Google I wouldn't have put up this question in the first place. Why don't you stop downvoting questions if you don't know the answer.underdog

1 Answers

2
votes

Spring Integration implements the patterns from http://www.enterpriseintegrationpatterns.com/books1.html while using AMQP/RabbitMQ as one of its many transports.

I understand that spring-amqp is more the AMQP client functionality. If you don't want to use spring. Then we have a plain java client: https://www.rabbitmq.com/java-client.html