/// <summary> /// Task for Receiving messages from Jetstream Ground. /// </summary> private string ReceiveTask(CancellationToken ct) { try { JetstreamServiceClient client = new JetstreamServiceClient(JetstreamUrl, UserAccessKey); GetEventsRequest request = new GetEventsRequest(); GetEventsResponse response = client.GetEvents(request); string currentBatchId = response.BatchId; List<JetstreamEvent> messages = response.Events.ToList(); // now add the Messages to the data store for the window thread if (ct.IsCancellationRequested) { return currentBatchId; } lock (_setLock) { foreach (JetstreamEvent t in messages) { if (ct.IsCancellationRequested) { break; } _set.Add(t); } } return currentBatchId; } catch (Exception ex) { EventLog.WriteEntry(EventLogSource, ex.Message + "\n" + ex.StackTrace, EventLogEntryType.Error); } return String.Empty; }
public void GetEventsTest() { // construct a Jetstream service client JetstreamServiceClient client = new JetstreamServiceClient(JetstreamConfiguration.Url, JetstreamConfiguration.ApplicationAccessKey); try { // create and configure the request object GetEventsRequest request = new GetEventsRequest(); request.Limit = 2; // call the Jetstream ReST endpoint client.GetEvents(request); } catch (Exception ex) { Assert.Fail(ex.ToString()); } }