15
15
*/
16
16
17
17
using System ;
18
- using System . Collections . Generic ;
19
18
using System . Threading ;
20
- using System . Collections ;
21
19
using System . Collections . ObjectModel ;
22
20
using System . Text . RegularExpressions ;
23
21
24
22
using Amqp ;
25
23
26
24
namespace ClientLib
27
25
{
26
+ /// <summary>
27
+ /// Connector client class
28
+ /// </summary>
28
29
public class ConnectorClient : CoreClient
29
30
{
31
+ /// <summary>
32
+ /// Method for run connector
33
+ /// </summary>
34
+ /// <param name="args">cmd line arguments</param>
30
35
public void Run ( string [ ] args )
31
36
{
32
- Collection < Connection > con_list = new Collection < Connection > ( ) ;
33
- Collection < Session > ssn_list = new Collection < Session > ( ) ;
34
- Collection < SenderLink > snd_list = new Collection < SenderLink > ( ) ;
35
- Collection < ReceiverLink > rcv_list = new Collection < ReceiverLink > ( ) ;
37
+ Collection < Connection > connections = new Collection < Connection > ( ) ;
38
+ Collection < Session > sessions = new Collection < Session > ( ) ;
39
+ Collection < SenderLink > senders = new Collection < SenderLink > ( ) ;
40
+ Collection < ReceiverLink > receivers = new Collection < ReceiverLink > ( ) ;
36
41
37
42
ConnectorOptions options = new ConnectorOptions ( ) ;
38
43
@@ -47,8 +52,7 @@ public void Run(string[] args)
47
52
48
53
for ( int i = 0 ; i < options . MsgCount ; i ++ )
49
54
{
50
- Connection tmp_con = new Connection ( new Address ( options . Url ) ) ;
51
- con_list . Add ( tmp_con ) ;
55
+ connections . Add ( new Connection ( new Address ( options . Url ) ) ) ;
52
56
}
53
57
}
54
58
@@ -57,65 +61,45 @@ public void Run(string[] args)
57
61
{
58
62
try
59
63
{
60
- foreach ( Connection conn in con_list )
64
+ foreach ( Connection conn in connections )
61
65
{
62
- //if connection is opened
63
- Session s = new Session ( conn ) ;
64
- ssn_list . Add ( s ) ;
65
- //if (options.syncMode == "action")
66
- //s.Sync();
67
- //else ssn_list.Add(null);
66
+ sessions . Add ( new Session ( conn ) ) ;
68
67
}
69
68
}
70
69
catch ( AmqpException ae )
71
70
{
72
71
Console . Error . WriteLine ( ae . Message ) ;
73
- for ( int i = ssn_list . Count ; i < con_list . Count ; i ++ )
72
+ for ( int i = sessions . Count ; i < connections . Count ; i ++ )
74
73
{
75
- ssn_list . Add ( null ) ;
74
+ sessions . Add ( null ) ;
76
75
Environment . Exit ( ReturnCode . ERROR_OTHER ) ;
77
76
}
78
77
}
79
78
80
- // further object require non-empty address
81
- string address = "jms.queue.connection_tests" ;
82
- //address = options.Address ???
79
+ string address = options . Address ;
83
80
84
- //not working currently
85
81
if ( address != String . Empty )
86
82
{
87
- // sender part (if address is specified)
88
- // create senders for opened sessions
89
83
if ( Regex . IsMatch ( options . ObjCtrl , "[S]" ) )
90
84
{
91
85
try
92
86
{
93
87
int i = 0 ;
94
- foreach ( Session s in ssn_list )
88
+ foreach ( Session s in sessions )
95
89
{
96
90
i ++ ;
97
91
if ( s != null )
98
- {
99
- SenderLink snd = new SenderLink ( s , "tmp_s" + i . ToString ( ) , address ) ;
100
- snd_list . Add ( snd ) ;
101
- //TODO
102
- if ( options . SyncMode == "action" )
103
- {
104
- //s.Sync();
105
- }
106
- }
92
+ senders . Add ( new SenderLink ( s , "sender" + i . ToString ( ) , address ) ) ;
107
93
else
108
- {
109
- snd_list . Add ( null ) ;
110
- }
94
+ senders . Add ( null ) ;
111
95
}
112
96
}
113
97
catch ( AmqpException ae )
114
98
{
115
99
Console . Error . WriteLine ( ae . Message ) ;
116
- for ( int i = snd_list . Count ; i < ssn_list . Count ; i ++ )
100
+ for ( int i = senders . Count ; i < sessions . Count ; i ++ )
117
101
{
118
- snd_list . Add ( null ) ;
102
+ senders . Add ( null ) ;
119
103
}
120
104
Environment . Exit ( ReturnCode . ERROR_OTHER ) ;
121
105
}
@@ -125,30 +109,21 @@ public void Run(string[] args)
125
109
try
126
110
{
127
111
int i = 0 ;
128
- foreach ( Session s in ssn_list )
112
+ foreach ( Session s in sessions )
129
113
{
130
114
i ++ ;
131
115
if ( s != null )
132
- {
133
- ReceiverLink rcv = new ReceiverLink ( s , "tmp_rcv" + i . ToString ( ) , address ) ;
134
- rcv_list . Add ( rcv ) ;
135
- if ( options . SyncMode == "action" )
136
- {
137
- //s.Sync();
138
- }
139
- }
116
+ receivers . Add ( new ReceiverLink ( s , "tmp_rcv" + i . ToString ( ) , address ) ) ;
140
117
else
141
- {
142
- rcv_list . Add ( null ) ;
143
- }
118
+ receivers . Add ( null ) ;
144
119
}
145
120
}
146
121
catch ( AmqpException ae )
147
122
{
148
123
Console . Error . WriteLine ( ae . Message ) ;
149
- for ( int i = rcv_list . Count ; i < ssn_list . Count ; i ++ )
124
+ for ( int i = receivers . Count ; i < sessions . Count ; i ++ )
150
125
{
151
- rcv_list . Add ( null ) ;
126
+ receivers . Add ( null ) ;
152
127
}
153
128
Environment . Exit ( ReturnCode . ERROR_OTHER ) ;
154
129
}
@@ -170,28 +145,28 @@ public void Run(string[] args)
170
145
if ( options . CloseSleep > 0 )
171
146
Thread . Sleep ( options . CloseSleep ) ;
172
147
173
- foreach ( ReceiverLink rec in rcv_list )
148
+ foreach ( ReceiverLink rec in receivers )
174
149
{
175
150
if ( rec != null )
176
151
{
177
152
rec . Close ( ) ;
178
153
}
179
154
}
180
- foreach ( SenderLink sen in snd_list )
155
+ foreach ( SenderLink sen in senders )
181
156
{
182
157
if ( sen != null )
183
158
{
184
159
sen . Close ( ) ;
185
160
}
186
161
}
187
- foreach ( Session ses in ssn_list )
162
+ foreach ( Session ses in sessions )
188
163
{
189
164
if ( ses != null )
190
165
{
191
166
ses . Close ( ) ;
192
167
}
193
168
}
194
- foreach ( Connection c in con_list )
169
+ foreach ( Connection c in connections )
195
170
{
196
171
if ( c != null )
197
172
{
0 commit comments