🎄 Happy Holidays! 🥳
Most of Solace is closed December 24–January 1 so our employees can spend time with their families. We will re-open Thursday, January 2, 2024. Please expect slower response times during this period and open a support ticket for anything needing immediate assistance.
Happy Holidays!
Please note: most of Solace is closed December 25–January 2, and will re-open Tuesday, January 3, 2023.
Replay from Message ID - How to use it!
Hey everyone,
The recent v9.9 release of the PubSub+ Event Broker and the API releases that came with it now support the ability to trigger replay from a specific message id. I just wanted to share some info on how to use it with some of the different APIs!
Note that the Message ID is in available in the header of each Solace Message and each Solace SMF API allows you to easily retrieve it.
Useful resources
Using Python for Replay from Message ID
rgmid = "rmid1:096b4-e39eaab3209-00000000-0000002d" reply_strategy = ReplayStrategy.replication_group_message_id_based(ReplicationGroupMessageId.of(rgmid)) persistent_receiver: PersistentMessageReceiver = messaging_service.create_persistent_message_receiver_builder()\ .with_message_auto_acknowledgement()\ .with_message_replay(reply_strategy)\ .build(durable_exclusive_queue) persistent_receiver.start()
Using CCSMP for Replay from Message ID
const string &replayMsgId = "rmid1:0117b-75462900ca8-00000000-00135082"; flowProps[propIndex++] = strdup(SOLCLIENT_FLOW_PROP_REPLAY_START_LOCATION); flowProps[propIndex++] = strdup(replayMsgId.c_str()); csmpRc = solClient_session_createFlow( (char **)flowProps, session_mp, &opaqueFlow_p, &flowFuncInfo, sizeof(flowFuncInfo));
Using JCSMP for Replay from Message ID:
String replayMsgId = "rmid1:0117b-75462900ca8-00000000-00135082"; ReplayStartLocation loc = JCSMPFactory.onlyInstance().createReplicationGroupMessageId(replayMsgId); consFlowProps.setReplayStartLocation(loc); consumer = _jSession.createFlow(myConsumer, consFlowProps, null, myConsumer);
Using NodeJS/JavaScript for Replay from Message ID
var replayMsgId = "rmid1:0117b-75462900ca8-00000000-00135082"; messageConsumerProperties.replayStartLocation = solace.SolclientFactory.createReplicationGroupMessageId(replayMsgId); consumer = this.m_session.createMessageConsumer(messageConsumerProperties);
Using .NET for Replay from Message ID
Note: One important thing about .NET is the ReplayStartLocation property in FlowProperties has been deprecated so it needs to use ReplayStartLocationEx (All the other replay start locations should use it as well in the future)
FlowProperties fp = new FlowProperties(); String replayMsgId = "rmid1:0117b-75462900ca8-00000000-00135082"; IReplicationGroupMessageId rpStart = ContextFactory.Instance.CreateReplicationGroupMessageId(replayMsgId); fp.ReplayStartLocationEx = rpStart; flowHandle = m_session.CreateFlow(fp, bindEndpoint, topicSubscription, this._HandleMessageEvent, this._HandleFlowEvent, epProps);
Using JavaRTO for Replay from Message ID:
Map<String, String> flowPropsMap = new HashMap<String, String>(_flowProperties); String replayMsgId = "rmid1:0117b-75462900ca8-00000000-00135082"; flowPropsMap.put(FlowHandle.PROPERTIES.REPLAY_START_LOCATION, replayMsgId ); EventsAdapter myConsumer = new EventsAdapter(this, queue, flowProps, null, null, transactedSession, wantMsgPriorityOrderChecking);
Hope this thread comes in handy for folks trying to use this feature in the future
Go ahead and give it a like if it does and we'll continue to try to share content like this for future features.
Comments
-
Hi ,
I was trying to find replayMsgId in message header using spring cloud stream , i printed all header which i received but not able to find any values as "rmid1:0117b-75462900ca8-00000000-00135082"Headers which i got as below:
- solace_senderTimestamp --1628606024803
- solace_expiration -- 0
- deliveryAttempt -- 1
- solace_destination -- test/msg/replay
- solace_timeToLive -- 0
- solace_receiveTimestamp --0
- skip-input-type-conversion -- false
- solace_discardIndication -- false
- solace_priority ---1
- solace_redelivered --false
- id --1cbf2434-fb03-d17f-9174-1e3a2f0d6edf // this id is not accepted for message replay.
- contentType --application/json
- solace_senderId --Try-Me-Pub/solclientjs/chrome-91.0.4472-Windows-0.0.0/2758948243/0003
- timestamp --1628606684861
Need your help here to know how to get ReplicationGroupMessageId in spring cloud Stream project.
0 -
Thanks for the heads up @manzarul. Just linking to the other post incase others come across this: https://solace.community/discussion/918/how-to-get-replicationgroupmessageid-for-message-replay-with-spring-cloud-stream#latest
0 -
You can also do replay by message id using python as follows:
rgmid = "rmid1:096b4-e39eaab3209-00000000-0000002d" reply_strategy = ReplayStrategy.replication_group_message_id_based(ReplicationGroupMessageId.of(rgmid)) persistent_receiver: PersistentMessageReceiver = messaging_service.create_persistent_message_receiver_builder()\ .with_message_auto_acknowledgement()\ .with_message_replay(reply_strategy)\ .build(durable_exclusive_queue) persistent_receiver.start()
2 -
I m sort of looking to (if required) replay from beginning on occasion, but if possible replay a subset of messages using the group message id. So i was wondering if the group message id has any sort of pattern that imitates replaying from beginning of the replay log, that if required, I can just change to a group message id that represents a message.
0