hi,
In the below code, my outmsg from the result, in one case, i need to flat
it to multiple output messages, i am stuck as where/how can i do it, really
appreciate if someone can help.
Thanks
Shannon
Source<Pair<TopicPartition, Source<CommittableMessage<SpecificRecord,
SpecificRecord>, NotUsed>>, Control> s
= Consumer.committablePartitionedSource(consumerSettings,
Subscriptions.topics("akkatest"));
s.mapAsyncUnordered(3, new
Function<Pair<TopicPartition,Source<CommittableMessage<SpecificRecord,SpecificRecord>,NotUsed>>,
CompletionStage<Done>>() {
public CompletionStage<Done> apply(
Pair<TopicPartition,
Source<ConsumerMessage.CommittableMessage<SpecificRecord, SpecificRecord>,
NotUsed>> param)
throws Exception {
logger.debug("----------------part -----------------" +
param.first().partition());
Source<Message<SpecificRecord, SpecificRecord, Committable>, NotUsed> f
=
param.second().map(new
Function<ConsumerMessage.CommittableMessage<SpecificRecord,SpecificRecord>,
ProducerMessage.Message<SpecificRecord, SpecificRecord,
ConsumerMessage.Committable>>() {
public ProducerMessage.Message<SpecificRecord, SpecificRecord,
ConsumerMessage.Committable> apply(
CommittableMessage<SpecificRecord, SpecificRecord> msg)
throws Exception {
//logger.debug(Thread.currentThread().getName() +
"msg---------------------------------------------------" + msg);
logger.debug(Thread.currentThread().getName() + "
msg---------------------------------------------------" +
msg.record().value().getClass());
final Timeout timeout = new Timeout(5, TimeUnit.SECONDS);
Future<Object> future = Patterns.ask(tpperactor, msg, timeout);
logger.debug(Thread.currentThread().getName() + "
asking---------------------------------------------------" +
msg.record().value().getClass());
List<CommittableMessage<SpecificRecord, SpecificRecord>> outlist = new
ArrayList<>();
CommittableMessage<SpecificRecord, SpecificRecord> outmsg =
(CommittableMessage<SpecificRecord, SpecificRecord>) Await.result(future,
timeout.duration());
logger.debug(Thread.currentThread().getName() + "
back---------------------------------------------------" +
outmsg.record().value().getClass());
ProducerMessage.Message<SpecificRecord, SpecificRecord,
ConsumerMessage.Committable> result =
new ProducerMessage.Message<SpecificRecord, SpecificRecord,
ConsumerMessage.Committable>(
new ProducerRecord<SpecificRecord, SpecificRecord>("akkatest2",
outmsg.record().key(), outmsg.record().value()),
outmsg.committableOffset());
return result;
}
});
return f.runWith(Producer.commitableSink(producerSettings),
materializer);
}
}).runForeach(new Procedure<Done>() {
@Override
public void apply(Done param) throws Exception {
}
}, materializer);
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.