--
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/0b886e56-e6af-4d3d-9849-d360d6626a91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The first question that I would ask is whether the originating client needs to stop and wait for a response, or whether it can have a callback (maybe using a WebHook) to get the response asynchronously. What are all of the components involved?
Hi,This is a pretty general question... I think there are a lot of ways you could do this. Is there something specific you are having trouble with, or do you not know where to even start?The first question that I would ask is whether the originating client needs to stop and wait for a response, or whether it can have a callback (maybe using a WebHook) to get the response asynchronously. What are all of the components involved?For the correlation ID I would generate a UUID early in the process and attach that to all of the messages that flow through the system.Best,Tim
On Sun, Dec 17, 2017 at 10:54 PM, Can çobanoğlu <cancob...@gmail.com> wrote:
Hi all,I have a case that a user makes a request via REST endpoint from one of my lagom services and this request will be sent to an external Flink Server to be processed via a kafka topic, after that if this operation is done or failed an information about this should be returned to the caller service. In this case a kind of "correlation info" has to be caried that my service (waits for callback) can poll the information that is sent. so, the user that made a request can get the response.How can i achieve this ? Could you propose me a solution ?Thanks.
--
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framewo...@googlegroups.com.
To post to this group, send email to lagom-f...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/0b886e56-e6af-4d3d-9849-d360d6626a91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/708ceb45-658e-49ae-b3dc-5f2e552632a1%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/708ceb45-658e-49ae-b3dc-5f2e552632a1%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/63e20786-ae31-4f9d-a81a-a9763045a543%40googlegroups.com.
@Override
public ServiceCall<String, String> doRequestAndWaitResponse(String someId) {
// create a message with a correlation Id (UUID) and send it to kafka
// and wait for a response with this id using pubSub
return (String req) -> {
// someId is my so called correlation ID
PubSubRef<String> topic = pubSubRegistry.refFor(TopicId.of(String.class, someId));
}
// omitted - publish message to kafka
return CompletableFuture.runAsync(() -> {
topic.subscriber().map(i -> {
if (i == someId)
return someId;
return "return what ?";
});
}).thenApply(str -> "New response " + str);
};
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/63e20786-ae31-4f9d-a81a-a9763045a543%40googlegroups.com.
@Override
public ServiceCall<String, NotUsed> publish(String someId) {
return req -> {
PubSubRef<String> topic = pubSubRegistry.refFor(TopicId.of(String.class, someId));
topic.publish("Laaaaan !");
return CompletableFuture.completedFuture(NotUsed.getInstance());
};
}
@Override
public ServiceCall<String, String> doRequestAndWaitResponse(String someId) {
// create a message with a correlation Id (UUID) and send it to kafka
// and wait for a response with this id using pubSub
return (String req) -> {
// someId is my so called correlation ID
PubSubRef<String> topic = pubSubRegistry.refFor(TopicId.of(String.class, someId));
// omitted - publish message to kafka
return CompletableFuture.supplyAsync(() -> {
System.out.println("s=============================================" + someId);
CompletableFuture<String> future = new CompletableFuture<>();
topic.subscriber().runForeach(i -> {
System.out.println("s=============================================" + i);
future.complete(i);
}, materializer);
return future;
}).thenApply(f -> {
try {
return f.get(10l, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
}
return "asd";
});
};
}
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/3bade376-13c4-4344-8bda-2e28d022ac00%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/3bade376-13c4-4344-8bda-2e28d022ac00%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/d146362a-dcd1-4382-80e5-17cf6694fe43%40googlegroups.com.
Hi all,I have a case that a user makes a request via REST endpoint from one of my lagom services and this request will be sent to an external Flink Server to be processed via a kafka topic, after that if this operation is done or failed an information about this should be returned to the caller service. In this case a kind of "correlation info" has to be caried that my service (waits for callback) can poll the information that is sent. so, the user that made a request can get the response.
REST call make.