Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

Consuming Event Hub messages with the IEventProcessor interface

$
0
0

Hi - 

It seems that I am doing something wrong when I try to consume messages off of an Event Hub using the EventProcessorHost with an implemented IEventProcessor Interface.

If I manually create a receiver, I can pull messages of my hub. Example (just creating a receiver on partition "1"):

let consumer = ehClientrec.GetDefaultConsumerGroup().CreateReceiverAsync("1").Result
    let msg = consumer.ReceiveAsync()
    msg.Wait()
    Console.WriteLine(Encoding.UTF8.GetString(msg.Result.GetBytes()))

This successfully prints a message to my console. 

But if I try to use the event processor host, first I (very simply) implement the IEventProcessor interface:

type msgProc() =
    interface IEventProcessor with
        member this.CloseAsync(context,reason) =
            let r = reason.ToString()
            Console.WriteLine("Closed Partition {0} for reason: {1}",context.Lease.PartitionId,r)
            Unchecked.defaultof<Task>
        member this.OpenAsync(context) =
            Console.WriteLine("Opened Partition {0}",context.Lease.PartitionId)
            Unchecked.defaultof<Task>
        member this.ProcessEventsAsync(context,msgs) =
            Console.WriteLine("Received message.")
            Unchecked.defaultof<Task>

Then I create the host and register it, and run the program. 

I never hit the ProcessEventsAsync method.

Instead, I see console output that shows the Partitions cyclically opening and closing:

"Opened Partition 1""Opened Partition 2""Opened Partition 4""Opened Partition 3""Opened Partition 0""Opened Partition 5""Opened Partition 7""Opened Partition 6""Closed Partition 3 for reason: Shutdown""Closed Partition 6 for reason: Shutdown""Closed Partition 7 for reason: Shutdown""Closed Partition 2 for reason: Shutdown""Closed Partition 0 for reason: Shutdown""Closed Partition 1 for reason: Shutdown""Closed Partition 4 for reason: Shutdown""Closed Partition 5 for reason: Shutdown"

(This repeats forever, with the opening and closing partitions appearing in a slightly different order each time).

I can't find any documentation on what conditions typically cause a shutdown or what would cause this behavior. Any ideas?

I'm basically positive my EventProcessorHost is configured properly.

Thanks.


Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>