Try PubSub+

Replay from Message ID - How to use it!

marcmarc Member, Administrator, Moderator, Employee Posts: 514 admin
edited May 28 in PubSub+ Event Broker #1

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 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, bindEndp

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.

Tagged:

Comments

  • manzarulmanzarul Member Posts: 16

    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:

    1. solace_senderTimestamp --1628606024803
    2. solace_expiration -- 0
    3. deliveryAttempt -- 1
    4. solace_destination -- test/msg/replay
    5. solace_timeToLive -- 0
    6. solace_receiveTimestamp --0
    7. skip-input-type-conversion -- false
    8. solace_discardIndication -- false
    9. solace_priority ---1
    10. solace_redelivered --false
    11. id --1cbf2434-fb03-d17f-9174-1e3a2f0d6edf // this id is not accepted for message replay.
    12. contentType --application/json
    13. solace_senderId --Try-Me-Pub/solclientjs/chrome-91.0.4472-Windows-0.0.0/2758948243/0003
    14. timestamp --1628606684861

    Need your help here to know how to get ReplicationGroupMessageId in spring cloud Stream project.

  • marcmarc Member, Administrator, Moderator, Employee Posts: 514 admin
Sign In or Register to comment.