ACTIVEMQ- publisher subscriber hello world example

前端 未结 4 830
北恋
北恋 2020-12-13 15:02

There are two programs: subscriber and publisher... Subscriber is able to put the message onto the topic and the message is sent successfully. When I check the activemq serv

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 15:16

    The main problem (besides the app closing down to quickly) is that you are sending to a Topic. Topics don't retain messages so if you run your application that produces and then run the consumer, the consumer won't receive anything because it was not subscribed to the topic at the time the message was sent. If you fix the shutdown issue and then run the consumer in one terminal and then run the producer you should then see the message received by your consumer. If you want message retention then you need to use a Queue which will hold onto the message until someone consumes it.

提交回复
热议问题