newbie_86
newbie_86

Reputation: 4610

Workflow with messaging in MVC

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.

Upvotes: 4

Views: 393

Answers (3)

Simon J. Liu
Simon J. Liu

Reputation: 827

  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.

Upvotes: 0

Richard210363
Richard210363

Reputation: 8406

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.

Upvotes: 1

Eric Rohlfs
Eric Rohlfs

Reputation: 1830

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.

Upvotes: 1

Related Questions