Topic Endpoint Replay
Best Answers
-
Hi amishra,
Take a look at our Java Replay tutorial here: https://solace.com/samples/solace-samples-java/feature_message-replay/
It replays to a queue, but replaying to a topic is very similar.You should be able to just pull out the queue specific stuff and replace with a TopicEndpoint that's subscribed to a topic.
So remove this...
Queue queue = JCSMPFactory.onlyInstance().createQueue(queueName); consumerFlowProps.setEndpoint(queue);
Replace with this as an example
TopicEndpoint topicEndpoint = JCSMPFactory.onlyInstance().createDurableTopicEndpointEx(topicName); Topic topicSub = JCSMPFactory.onlyInstance().createTopic("ATTENDEE/tweets/stream"); consumerFlowProps.setEndpoint(topicEndpoint); consumerFlowProps.setNewSubscription(topicSub);
Hope that helps!
6 -
As a side note, we usually recommend that clients use queue endpoints instead of topic endpoints as they are more flexible.
Topic endpoints allow you to specify an inbound message selector, but if you aren't using that feature then going with a queue endpoint will allow for your endpoint to have multiple topic subscriptions, choose exclusive vs. non-exclusive to provide, etc. You can read more the endpoints in the docs here: https://docs.solace.com/PubSub-Basics/Endpoints.htm5
Answers
-
Hi amishra,
Take a look at our Java Replay tutorial here: https://solace.com/samples/solace-samples-java/feature_message-replay/
It replays to a queue, but replaying to a topic is very similar.You should be able to just pull out the queue specific stuff and replace with a TopicEndpoint that's subscribed to a topic.
So remove this...
Queue queue = JCSMPFactory.onlyInstance().createQueue(queueName); consumerFlowProps.setEndpoint(queue);
Replace with this as an example
TopicEndpoint topicEndpoint = JCSMPFactory.onlyInstance().createDurableTopicEndpointEx(topicName); Topic topicSub = JCSMPFactory.onlyInstance().createTopic("ATTENDEE/tweets/stream"); consumerFlowProps.setEndpoint(topicEndpoint); consumerFlowProps.setNewSubscription(topicSub);
Hope that helps!
6 -
As a side note, we usually recommend that clients use queue endpoints instead of topic endpoints as they are more flexible.
Topic endpoints allow you to specify an inbound message selector, but if you aren't using that feature then going with a queue endpoint will allow for your endpoint to have multiple topic subscriptions, choose exclusive vs. non-exclusive to provide, etc. You can read more the endpoints in the docs here: https://docs.solace.com/PubSub-Basics/Endpoints.htm5