66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/logstash/outputs/azure_event_hub.rb', line 66
def register
@executor_service = Executors.newScheduledThreadPool(@client_threads)
try = 0
retry_interval = 2
begin
if !@connection_string.nil? and @connection_string !~ /\A\s*\Z/
@eventhub_client = EventHubClient.createSync(@connection_string, @executor_service)
@codec.on_event(&method(:send_record))
else
@logger.warn("Connection String is empty, azure_event_hub output will be ignored and should not be called...")
@codec.on_event(&method(:log_no_msg_sent))
end
rescue IllegalConnectionStringFormatException, IOException => e
@logger.error(
"Unable to establish connection to Azure Event Hubs.",
:error_message => e.getMessage(),
:class => e.class.name
)
close()
exit(1)
rescue EventHubException, ExecutionException => e
if (e.is_a?(EventHubException) and e.getIsTransient() != true) or try >= @connection_retry_count
@logger.error(
"Unable to establish connection to Azure Event Hubs.",
:error_message => e.getMessage(),
:class => e.class.name
)
close()
exit(1)
end
@logger.error(
"Connection to Event Hubs failed, will attempt connection again.",
:error_message => e.getMessage(),
:class => e.class.name,
:retry_in_seconds => retry_interval
)
sleep(retry_interval)
try += 1
retry
end
end
|