Open jeremy1265 opened 4 years ago
I use this code after send and create listener consumer:
` String amqpMessageResponse;
StreamSubscription
streamSubscriptionMessage = consumerForListen.listen(
(AmqpMessage amqpMessage) {
print('consumerForListen -> onMessage, amqpMessage: ' + amqpMessage.payloadAsString);
},
);
print('start listen');
waitingForMessage = true;
int counter = 0;
int waitingMillisec = 0;
do {
print('listen counter: ' + counter.toString());
streamSubscriptionMessage.onData((amqpMessage) {
try {
print('streamSubscriptionMessage -> onData, amqpMessage: ' + amqpMessage.payloadAsString);
} catch (e) {}
if (amqpMessage.payloadAsString == 'Test') {
amqpMessageResponse = amqpMessage.payloadAsString;
waitingForMessage = false;
}
});
if (waitingForMessage) {
await Future.delayed(const Duration(milliseconds: 500));
waitingMillisec += 500;
if (waitingMillisec > timeout.inMilliseconds) {
waitingForMessage = false;
}
}
counter++;
} while (waitingForMessage);`
try{
await streamSubscriptionMessage.cancel();
}
catch(e){
}
Hi,
Any example of handling the client timeout?? and also can we set the timeout length manually??
Thanks.