How do I have an Async function that writes out to a service bus queue?

Micah Zoltu

Using the Azure WebJobs SDK, I want to create an async function that will receive ServiceBus queue input and write to a ServiceBus queue output. Async methods cannot have out parameters which, for examples on BlobStorage, appears to be worked around by having Streams and TextWriters instead. However, when I try to do the same with a ServiceBus parameter I receive an exception.

public static async void Transform(
    [ServiceBusTrigger("%InputQueue%")] String input,
    [ServiceBus("%OutputQueue%")] TextWriter output,
    TextWriter log)

Error indexing method 'FilterCurrentCpesToNewCpes'

Can't bind ServiceBus to type 'System.IO.TextWriter'.

I receive a similar message for Stream.

pranav rastogi

Since Async functions cannot have out parameters, you can bind to ICollector<T> or IAsyncCollector<T> and perform Add() operation to send a message. ICollector is defined in the WebJobs SDK.

Following sample demonstrates this.

 public static async void Transform(
[ServiceBusTrigger("%InputQueue%")] string input,
[ServiceBus("%OutputQueue%")] IAsyncCollector<string> output,
TextWriter log)
    {            
        await output.AddAsync(input);
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

I have a few function overloads, each of which takes a different subclass; how do I check which function to use for a given object?

来自分类Dev

How do I use the Volley network request queue?

来自分类Dev

In F#, how do I tell if an object is an Async<_>, and how can I cast it to an Async<_>?

来自分类Dev

AKKA是否尝试在内存中执行与磁盘上的Azure Service Bus Queue相同的操作?

来自分类Dev

How do I change the boot menu when I have no display?

来自分类Dev

How do I pass async method as Action or Func

来自分类Dev

How do I find out the numeric ID of the current Postgres Transaction?

来自分类Dev

How do I proc out with tilde expansion AND $PATH searching in Haskell?

来自分类Dev

How do I get my aliases to have correct completion?

来自分类Dev

How do I gracefully handle this exception in a background thread in a Windows service?

来自分类Dev

How do I dependency inject PDO to a service in Symfony2?

来自分类Dev

How can I propagate an exception thrown from an asynchronous function to an awaiting async void function?

来自分类Dev

Azure Service Bus AutoDeleteOnIdle

来自分类Dev

Azure Function App Azure Service Bus触发器两次触发

来自分类Dev

Azure Service Bus订户死信

来自分类Dev

Azure Service Bus AMQP异常

来自分类Dev

在本地使用Azure Service Bus

来自分类Dev

Azure Service Bus与SignalR的集成

来自分类Dev

Azure Service Bus订户死信

来自分类Dev

Swift: How do I return a value within an asynchronous urlsession function?

来自分类Dev

How do I redirect the output of a system() function to a variable?

来自分类Dev

How do I use a Codeigniter method within my own function?

来自分类Dev

How do I turn a function variable into a div id name?

来自分类Dev

How do I use an extension function in another class? C#

来自分类Dev

How do I unit test a function that loops over objects?

来自分类Dev

How do I update the working tree when checking out a branch with libgit2?

来自分类Dev

How do I find out which process is using so much of my RAM?

来自分类Dev

I have javascript function that add numbers to array

来自分类常见问题

In jQuery, how do I get the value of a radio button when they all have the same name?

Related 相关文章

  1. 1

    I have a few function overloads, each of which takes a different subclass; how do I check which function to use for a given object?

  2. 2

    How do I use the Volley network request queue?

  3. 3

    In F#, how do I tell if an object is an Async<_>, and how can I cast it to an Async<_>?

  4. 4

    AKKA是否尝试在内存中执行与磁盘上的Azure Service Bus Queue相同的操作?

  5. 5

    How do I change the boot menu when I have no display?

  6. 6

    How do I pass async method as Action or Func

  7. 7

    How do I find out the numeric ID of the current Postgres Transaction?

  8. 8

    How do I proc out with tilde expansion AND $PATH searching in Haskell?

  9. 9

    How do I get my aliases to have correct completion?

  10. 10

    How do I gracefully handle this exception in a background thread in a Windows service?

  11. 11

    How do I dependency inject PDO to a service in Symfony2?

  12. 12

    How can I propagate an exception thrown from an asynchronous function to an awaiting async void function?

  13. 13

    Azure Service Bus AutoDeleteOnIdle

  14. 14

    Azure Function App Azure Service Bus触发器两次触发

  15. 15

    Azure Service Bus订户死信

  16. 16

    Azure Service Bus AMQP异常

  17. 17

    在本地使用Azure Service Bus

  18. 18

    Azure Service Bus与SignalR的集成

  19. 19

    Azure Service Bus订户死信

  20. 20

    Swift: How do I return a value within an asynchronous urlsession function?

  21. 21

    How do I redirect the output of a system() function to a variable?

  22. 22

    How do I use a Codeigniter method within my own function?

  23. 23

    How do I turn a function variable into a div id name?

  24. 24

    How do I use an extension function in another class? C#

  25. 25

    How do I unit test a function that loops over objects?

  26. 26

    How do I update the working tree when checking out a branch with libgit2?

  27. 27

    How do I find out which process is using so much of my RAM?

  28. 28

    I have javascript function that add numbers to array

  29. 29

    In jQuery, how do I get the value of a radio button when they all have the same name?

热门标签

归档