Publishing to a topic from an Action fails silently


I’m having some difficulties debugging the publishing of messages to a topic.
I have an action which is defined like this

service PublishService {
  option (akkaserverless.service) = {
  rpc Publish(EntityData) returns (Data) {
    option (akkaserverless.method).eventing = {
      out: {
        topic: "data_topic"

There is a value-entity which triggers this PublishService like this:

//in the constructor
publishService = valueEntityContext.serviceCallFactory().lookup(...);

//in a method of the value-entity:
return effects()

This results in the PublishService to be called. That one succesfully converts the EntityData into a Data and returning it like this:

return effects().reply(dataToPublish);
(where dataToPublish is of the correct type, defined in the protobuf definition)

I would expect that this returned dataToPublish would be published to the topic configured in the protobuf description.
Except, what happens is: nothing: not even an error. Logstatements I added just befor the return statement are printed, and then nothing anymore, until I trigger the same thing again though the API. The proxy-service is silent too: no errors, also not during deployment.
Is publishing from an action to a topic in this way not supported? It is not explicitely mentioned in the docs, but I would expect it to work transparently (Publishing and Subscribing with Actions :: Akka Serverless Documentation)

I use, in another place in the same application a very similar approach to publish to another topic, and that works fine. The only difference with it is that the definition looks like this.

service ToTopicService {
    option (akkaserverless.service) = {
        type : SERVICE_TYPE_ACTION
    rpc Publish(SomeModel) returns (SomeData){
        option (akkaserverless.method).eventing = {
            in: {
                event_sourced_entity: "entity"
            out: {
                topic: "other_topic"

(So, using the as input, but since my PublishService is correctly being called, I don’t think this difference is relevant)

For local development I use the google-pubsub emulator.
By using a local python subscriber (Testing apps locally with the emulator  |  Cloud Pub/Sub Documentation) I can see that messages are published to the second (“other_topic”), but not to first (“data_topic”)

How can I debug this further? Is there a way to enable extra logging? Should I download the sources of akka-serverless and start digging in those?
Any suggestions are appreciated.
(I haven’t tried deploying this in the cloud yet, this is all local development)

A few months back, when trying out a previous version of akka-serverless using the SDK of that moment (which has changed quite a bit), I ran into a very similar thing: Manually publishing to pub/sub
No solution for it then either. I hope to have better luck now :sweat_smile:

Thanks for letting us know about this. I’d also expect this to work but, unless I’m missing something, it seems like it’s an oversight on our part — where side effects and forwards are bypassing the eventing destination support. You can try calling the PublishService action directly with gRPC or HTTP, which should publish to the topic as expected.

We’ll follow up by looking at this properly. For now, a workaround would be to trigger the publish using a gRPC call as if it was an external service. Examples in the docs for this here:

Or subscribing to the value entity changes would be another way to have this work for now.

Thanks a lot for the idea!
It’s actually from a value-entity that I want to trigger the action that should publish to the topic. I found this way to create the grpc-client within an entity

this.publishService = new GrpcClients(context.materializer().system().systemImpl()).getGrpcClient(PublishService.class,

If I call this publishService, it just seems to hang. The CompletqbleFuture that is returned never completes.
The connection seems to be established though: if I set something else than localhost:8080, I see that the connection fails, and then there are some retries.
What else could be missing?

You’ll need to call through the proxy, which will be running locally at localhost:9000. When deployed, it will need to be the deployed service name (and default port 80).

Async inter-service calls are only directly supported, with convenience utilities for getting clients and returning async replies, in Actions. It would be possible as another variation on this workaround, to side effect to the action as expected, and then have the action call itself to trigger the publishing — a bit odd, but that has all support built in. And then only the action is updated once triggering event destination for side effect calls is fixed.

But it may be better overall to trigger publishing from value entity state changes instead of using a side effect. This has better guarantees. So like publishing from an event sourced entity to a topic, but subscribe to the value entity changes instead:

Thanks a lot! That did the trick! I’ll experiment a bit with your alternative suggestion too, to see which one looks better :slight_smile:
Thank you