2017-12-19 16 views
0

https://github.com/Azure/azure-webjobs-sdk/wiki/EventHub-supportWebJobでEventHubコンシューマーグループを指定する方法は?ここで説明するように、私はEventHubにWebJobのバインディングを使用しています

webjobが実行されているが、これは例外では同じハブ結果にAzure Service Bus Explorerを実行しようとしている:

Exception: A receiver with a higher epoch '14' already exists. A new receiver with epoch 0 cannot be created. 
Make sure you are creating receiver with increasing epoch value to ensure connectivity, or ensure all old epoch receivers are closed or disconnected. 

私が理解から、これは、同じコンシューマー・グループを使用する2つのリスナー(webjob &バス・エクスプローラー)によって発生します。

私の質問には、どのように私のwebjobで別のコンシューマーグループを指定できますか?このような

私の現在のコードを見て:

のProgram.cs:

var config = new JobHostConfiguration() 
{ 
    NameResolver = new NameResolver() 
}; 

string eventHubConnectionString = ConfigurationManager.ConnectionStrings["EventHub"].ConnectionString; 
string eventHubName = ConfigurationManager.AppSettings["EventHubName"]; 
string eventProcessorHostStorageConnectionString = ConfigurationManager.ConnectionStrings["EventProcessorHostStorage"].ConnectionString; ; 

var eventHubConfig = new EventHubConfiguration(); 
eventHubConfig.AddReceiver(eventHubName, eventHubConnectionString, eventProcessorHostStorageConnectionString); 
config.UseEventHub(eventHubConfig); 

var host = new JobHost(config); 

host.RunAndBlock(); 

Functions.cs:

public class Functions 
    { 
     public static void Trigger([EventHubTrigger("%EventHubName%")] string message, TextWriter log) 
     { 
      log.WriteLine(message); 
     } 
    } 

[編集 - ボーナス質問]

I消費者グループと 'エポック'の使用を完全に把握していない。 1つのコンシューマーグループは1つの受信機に制限されていますか

答えて

0

EventHubTriggerには、オプションのConsumerGroupプロパティ(source)があります。したがって、これに基づいてこのようなトリガーを変更する:

public class Functions 
    { 
     public static void Trigger([EventHubTrigger("%EventHubName%", ConsumerGroup = "MyConsumerGroup")] string message, TextWriter log) 
     { 
      log.WriteLine(message); 
     } 
    } 
+0

ハ、あまりにも簡単:-)ありがとう –

関連する問題