@Override public void prepare(Map<String, Object> config, TopologyContext context, OutputCollector collector) { this.collector = collector; String myPartitionId = null; if (boltConfig.getPartitionMode()) { // We can use the task index (starting from 0) as the partition ID myPartitionId = "" + context.getThisTaskIndex(); } logger.info("creating sender: " + boltConfig.getConnectionString() + ", " + boltConfig.getEntityPath() + ", " + myPartitionId); try { ehClient = EventHubClient.createFromConnectionStringSync(boltConfig.getConnectionString()); if (boltConfig.getPartitionMode()) { sender = ehClient.createPartitionSenderSync(Integer.toString(context.getThisTaskIndex())); } } catch (Exception ex) { collector.reportError(ex); throw new RuntimeException(ex); } }
private PartitionSender createPartitionSender(EventHubClient client, String partitionId) { try { return client.createPartitionSenderSync(partitionId); } catch (EventHubException e) { throw new EventHubRuntimeException("Error when creating event hub partition sender", e); } }
private PartitionSender createPartitionSender(EventHubClient client, String partitionId) { try { return client.createPartitionSenderSync(partitionId); } catch (EventHubException e) { throw new EventHubRuntimeException("Error when creating event hub partition sender", e); } }
createOrGetEventHubClientManagerForPartition(streamId, i); PartitionSender partitionSender = perPartitionClientManager.getEventHubClient().createPartitionSenderSync(partitionId); partitionSenders.put(i, partitionSender);
PowerMockito.when(mockEventHubClient.createPartitionSenderSync("0")).thenReturn(mockPartitionSender0); PowerMockito.when(mockEventHubClient.createPartitionSenderSync("1")).thenReturn(mockPartitionSender1);