Add Activities to Routing Slip from Activity?

304 views
Skip to first unread message

Landon Campbell

unread,
Jun 27, 2017, 10:14:18 PM6/27/17
to masstransit-discuss
I'm an MT noob, and I was wondering if it's possible to alter the itinerary of an executing routing slip? Specifically, is it possible to dynamically add an activity to the itinerary based on the outcome of an activity? Any information would be greatly appreciated.

Chris Patterson

unread,
Jun 27, 2017, 10:44:46 PM6/27/17
to masstrans...@googlegroups.com
Yes, that's fully supported.


You can build the itinerary inside that method (in this case it just empties it).


On Tue, Jun 27, 2017 at 9:14 PM, Landon Campbell <campbel...@hotmail.com> wrote:
I'm an MT noob, and I was wondering if it's possible to alter the itinerary of an executing routing slip? Specifically, is it possible to dynamically add an activity to the itinerary based on the outcome of an activity? Any information would be greatly appreciated.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstransit-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/masstransit-discuss/8adf7a1b-334d-42a2-aca5-4ac3b24858e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Landon Campbell

unread,
Jun 27, 2017, 10:53:58 PM6/27/17
to masstransit-discuss
Thanks for the quick reply, but would you mind elaborating a little bit? What would it look like to add an activity? And if I add one, does it put it next in the itinerary, or at the end of it, etc.? I tried using the ReviseItinerary method, but it wasn't working for me, so I must've been doing something wrong. I did this:

var builder = new RoutingSlipBuilder(NewId.NextGuid());
Uri scanAddress = new Uri("rabbitmq://127.0.0.1/msg/execute_scan");
System.Action<ItineraryBuilder> a = (RoutingSlipBuilder) => builder.AddActivity("scan", scanAddress);
return context.ReviseItinerary(a);

Is it more straight-forward than that? Thanks!


On Tuesday, June 27, 2017 at 9:44:46 PM UTC-5, Chris Patterson wrote:
Yes, that's fully supported.


You can build the itinerary inside that method (in this case it just empties it).

On Tue, Jun 27, 2017 at 9:14 PM, Landon Campbell <campbel...@hotmail.com> wrote:
I'm an MT noob, and I was wondering if it's possible to alter the itinerary of an executing routing slip? Specifically, is it possible to dynamically add an activity to the itinerary based on the outcome of an activity? Any information would be greatly appreciated.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
To post to this group, send email to masstrans...@googlegroups.com.
Message has been deleted

Landon Campbell

unread,
Jun 27, 2017, 11:23:48 PM6/27/17
to masstransit-discuss
I simplified further, to this, but the routing slip stops and doesn't proceed to the added activity or the next activity originally defined in the builder.


var builder = new RoutingSlipBuilder(NewId.NextGuid());
Uri scanAddress = new Uri("rabbitmq://127.0.0.1/msg/execute_scan");
return context.ReviseItinerary(=> builder.AddActivity("scan", scanAddress));


 The message disappears from the Rabbit queue, so I assume it's being marked "completed" without executing any of the remaining activities, or perhaps it's being terminated. There are no exceptions showing in code or in Rabbit. Thoughts?

Landon Campbell

unread,
Jun 28, 2017, 12:15:09 AM6/28/17
to masstransit-discuss
Sorry for the barrage of replies, just want to make sure I'm providing all the pertinent information. I added some event handlers, and noticed the following message for the slip that I'm trying to add an activity to. The message type is:

"messageType": [

"urn:message:MassTransit.Courier.Contracts:RoutingSlipRevised"
],

And then there's this:

    "itinerary": [],

"discardedItinerary": [
{
"name": "resultsAnalysis",
"address": "rabbitmq://127.0.0.1/msg/execute_resultsAnalysis",
"arguments": {}
}
]

I am receiving the "RoutingSlipCompleted" message, but obviously when I try to revise the itinerary, it clears it instead of adding the new activity. So, I don't guess "AddActivity" is what I want to be using...

Chris Patterson

unread,
Jun 28, 2017, 10:01:43 AM6/28/17
to masstrans...@googlegroups.com
Don't create a routing slip builder in your activity. The lambda argument you receive in the ReviseItinerary call is what you should be using to build the new itinerary. There are methods on that argument to add the original itinerary activities as well. 

How is this not obvious? Why would you ever think to create a separate object instance with no coupling to the delegate argument? Just surprised it isn't more clear. 

__
Chris Patterson

From: masstrans...@googlegroups.com <masstrans...@googlegroups.com> on behalf of Landon Campbell <campbel...@hotmail.com>
Sent: Tuesday, June 27, 2017 11:15:09 PM
To: masstransit-discuss
Subject: Re: [masstransit-discuss] Add Activities to Routing Slip from Activity?
 
--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-dis...@googlegroups.com.

To post to this group, send email to masstrans...@googlegroups.com.

Landon Campbell

unread,
Jun 28, 2017, 11:07:41 AM6/28/17
to masstransit-discuss
Great, thanks for your measured, civil reply.


On Wednesday, June 28, 2017 at 9:01:43 AM UTC-5, Chris Patterson wrote:
Don't create a routing slip builder in your activity. The lambda argument you receive in the ReviseItinerary call is what you should be using to build the new itinerary. There are methods on that argument to add the original itinerary activities as well. 

How is this not obvious? Why would you ever think to create a separate object instance with no coupling to the delegate argument? Just surprised it isn't more clear. 

__
Chris Patterson

From: masstrans...@googlegroups.com <masstrans...@googlegroups.com> on behalf of Landon Campbell <campbel...@hotmail.com>
Sent: Tuesday, June 27, 2017 11:15:09 PM
To: masstransit-discuss
Subject: Re: [masstransit-discuss] Add Activities to Routing Slip from Activity?
 
Sorry for the barrage of replies, just want to make sure I'm providing all the pertinent information. I added some event handlers, and noticed the following message for the slip that I'm trying to add an activity to. The message type is:

"messageType": [

"urn:message:MassTransit.Courier.Contracts:RoutingSlipRevised"
],

And then there's this:

    "itinerary": [],

"discardedItinerary": [
{
"name": "resultsAnalysis",
"address": "rabbitmq://127.0.0.1/msg/execute_resultsAnalysis",
"arguments": {}
}
]

I am receiving the "RoutingSlipCompleted" message, but obviously when I try to revise the itinerary, it clears it instead of adding the new activity. So, I don't guess "AddActivity" is what I want to be using...

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.

Chris Patterson

unread,
Jun 28, 2017, 3:39:46 PM6/28/17
to masstrans...@googlegroups.com
I hope you didn't take it otherwise, I was asking serious questions.

To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsubscribe...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "masstransit-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to masstransit-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages