SMF sample for Batch/Transacted Send and Receive
Hi,
I have a use case in which I have to send batch of 256 messages in a single local transaction. Also, on the consumer side I should receive all 256 messages in a batch and local transaction.
Is there a Java (JCSMP) sample to do that?
Please help.
Thanks,
Raghu
Comments
-
The example at: https://solace.com/samples/solace-samples-java/feature_transactions/ shows the use of transactions. In the example it shows a producer and consumer in the transaction which is a different use case than what you are asking about. However, the setup would be the same but you would do 256 of the
onReceive()
and then calltxSession.commit();
to close off that window.0 -
Don't 256
onReceive()
methods create 256 different asynchronous threads? If write 256onReceive()
methods, do we need to put 'txSession.commit()` on all methods?
Also, writing 256 onReceive methods with same signature does not compile. Does it mean, we have to create 256 FlowReceivers on the transacted session? and have commit in one of the Flow receivers?
Please clarify.0 -
I wasn't suggesting doing 256 onRecieve() functions. I was suggesting that on your onRecieve () you keep a counter and reset it every 256 messages. When you reset it back to 0, commit the txn.
0 -
@amackenzie thanks a lot for clarifying. Suggested approach is working like a charm
0 -
@amackenzie Message send and receive is working fine with the approach. However, the callback function in JCSMPStreamingPublishEventHandler is not working as expected. None of the logging statements were printed in the callback method when doing batch
transactedSession.commit()
:@Override public void responseReceived(String messageID) {...}
Am I missing something?
0 -
can you paste your publisher code?
0