Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Wokflows Invocation

prema
New Member

Hi, Is it possible to invoke workflows from pubsub?

0 4 247
4 REPLIES 4

Not directly but you can use Eventarc in the middle to achieve that. I show how here: https://github.com/GoogleCloudPlatform/eventarc-samples/tree/main/eventarc-workflows-integration/eve...

AFAIK, Eventarc trigger for workflows only allows user to configure a given topic without any further filtering. I have a use case where many micro-services publish to a topic, while I am only interested in msgs from a particular service. I do have an existing subscription that pulls only msgs from my target service. Is there any recommendation on how to leverage this existing subscription for workflow triggering? Of course, I can just have that service publish to another new topic, but I am trying to avoid that.

I'm not sure if I understand your question fully but let me try to answer. When you create an Eventarc Pub/Sub trigger for Workflows, the trigger uses a Pub/Sub topic under the covers to deliver messages to Workflows. You want to be able to filter messages in this Pub/Sub topic, so that the Workflow only receives a subset of those messages? If so, that's not possible today. However, one possible solution is to do the filtering in Workflows. So, Workflows receives all the messages and it checks the Pub/Sub message to do its own filtering. This is not ideal but it could work. 

@prema  - Can you share a bit more information about your use case ? Do you have a custom application publishing messages into a Pub/Sub topic ? As @atamel  suggested, you can use Eventarc in the middle to achieve what you want. In future, you will be able to publish your events directly into Eventarc. We are planning to do a private preview in the near future. If you are interested, please ping me directly with your email address.