我们使用提供的JAVA SDK将示例json事件推送到了Azure事件中心。 然后我们创建了流分析作业,该作业从事件中心获取输入并将数据推送到Blob存储。但是我们已经观察到(从监视中)事件被推送到事件中心,但是我的流分析作业既未接收到事件也未引发任何异常(查看的活动日志)。我尝试了Internet上所有可用的故障排除解决方案,但仍然无法正常工作。
概述页面上的图形上没有显示输入事件
注意:我使用天蓝色的Twitter情绪分析尝试了上述流程 (https://docs.microsoft.com/en-us/azure/stream-analytics/stream-analytics-introduction)并有效。
我们还为流分析工作启用了诊断日志,但是我们还没有发现任何东西。
事件肯定会被推送到事件中心,我们通过编写自己的事件中心使用者来对其进行测试。
已发布示例JSON事件:
{
"timestamp":"2018-06-20T17:25:37.863Z",
"name":"Alex",
"city":"Aukland",
"message":"Sample Logger"
}
事件中心发布者代码:
ConnectionStringBuilder connStr = new ConnectionStringBuilder()
.setNamespaceName("test-eventhub")
.setEventHubName("testEventhub")
.setSasKeyName("testEventhub-access")
.setSasKey("Endpoint=sb://test-eventhub.servicebus.windows.net/;"
+ "SharedAccessKeyName=testEventhub-access;SharedAccessKey=xyz=");
final Gson gson = new GsonBuilder().create();
// The Executor handles all asynchronous tasks and this is passed to the EventHubClient instance.
// The enables the user to segregate their thread pool based on the work load.
// This pool can then be shared across multiple EventHubClient instances.
// The following sample uses a single thread executor, as there is only one EventHubClient instance,
// handling different flavors of ingestion to Event Hubs here.
final ExecutorService executorService = Executors.newSingleThreadExecutor();
// Each EventHubClient instance spins up a new TCP/SSL connection, which is expensive.
// It is always a best practice to reuse these instances. The following sample shows this.
final EventHubClient ehClient = EventHubClient.createSync(connStr.toString(), executorService);
try {
for (int i = 0; i < 10000; i++) {
String payload = "{\"timestamp\":\"2018-06-20T17:25:37.863Z\",\"name\":\"Alex\",\"city\":\"Aukland\",\"message\":\"Sample Logger\"}";
System.out.println(payload);
//PayloadEvent payload = new PayloadEvent(i);
byte[] payloadBytes = gson.toJson(payload).getBytes(Charset.defaultCharset());
EventData sendEvent = EventData.create(payloadBytes);
// Send - not tied to any partition
// Event Hubs service will round-robin the events across all Event Hubs partitions.
// This is the recommended & most reliable way to send to Event Hubs.
ehClient.sendSync(sendEvent);
}
System.out.println(Instant.now() + ": Send Complete...");
//System.in.read();
} finally {
ehClient.closeSync();
executorService.shutdownNow();
}