Workflow with messaging in MVC

382 views Asked by At

Scenario:

  1. Request to approve comes in as a message on a bus (rapidMQ)
  2. Subscriber reads message and kicks off workflow if required
  3. Workflow is state machine workflow which starts off as Unassigned
  4. Unassigned item is added to a work item queue
  5. User assigns item to himself
  6. Workflow continues -> moves to assigned
  7. User is prompted to approve
  8. User approves/declines
  9. Workflow continues -> Item is updated and transitions to Approved/Declined. Messages sent out so further processing can occur.

I want to use rapidMQ as my messaging bus, I will be using web api and wcf as well. I want everything to be controlled via the message bus, so user approval/declining/assigning will result in a message on the bus, which workflow must pick up and action.

Is it possible to use workflow foundation with an mvc front end and have it respond to a message bus? i.e. workflow must place messages on a bus and read message from a bus and transition accordingly?

Please can you point me in the right direction? I am open to using another workflow solution if that will suit my needs better.

3

There are 3 answers

0
Eric Rohlfs On

You first have to solve your workflow hosting situation. You might be able to host in mvc, but you won't be happy with it. Usually the host is a windows service exposing a WCF endpoint for an entry point into the workflow. After you work out hosting you can address messaging and bus.

0
Richard210363 On

I've driven workflows from message queues.
The basic concept is to have the workflow hosted as a service and any other applications or web sites as totally separate solutions. Then they all communicate via queues.

I build a Workflow Controller class to handle incoming messages and run/re-hydrate the workflows. I never get the workflows themselves to read queues because handling timings/waiting gets annoying when queues go down. Better to send the workflow to sleep when it is waiting for a message from a queue and let the Controller class deal with the queue.

When sending to queues I get the Workflow Activities to call into a queue class in the workflow solution. I inject the queue handling class into the workflow by passing it into the workflow in the input parameters when running the workflow.

0
Simon J. Liu On
  1. It's better to isolate the workflow engine from business logic. workflow engine expose API to outside and maintain the task node and state.

  2. When you have a workable workflow engine, you can make a proxy layer to translate the message to workflow engine API.

  3. When client got the message from MQ, forward it to proxy layer and translate the message to a workflow API call. The message is actually another form of API call in this case.