I would like to access Service Bus Queues and Topics from Workflows with some specific activities.

I couldn't find anything fitting this scenario (this MSDN article and this article by Roman Kiss) are the nearest one.

I would like to design a custom activity which uses the QueueClient to receive asynchronously the brokered messages, using the BeginReceive method implemented with the async/await pattern (please see my question about it).

First of all, I would like to ask if it there are any reasons why I should prefer the suggested approach (adapted WCF) instead of my desired one (using the QueueClient).

Then, I would appreciate help designing it in a persistence-friendly way.

Update:

This is what I tried so far:

public class AsyncReceiveBrokeredMessage : AsyncCodeActivity<BrokeredMessage>
{
    [RequiredArgument]
    public InArgument<string> ConnectionString { get; set; }

    [RequiredArgument]
    public InArgument<string> Path { get; set; }

    protected sealed override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
    {
        var connectionString = this.ConnectionString.Get(context);
        var path = this.Path.Get(context);
        var queueClient = QueueClient.CreateFromConnectionString(connectionString, path);
        var cts = new CancellationTokenSource();
        context.UserState = new ReceiveState
                                {
                                    CancellationTokenSource = cts,
                                    QueueClient = queueClient
              
Edit
Report