@@ -11,14 +11,21 @@ namespace ActiveMQ.Artemis.Client.Builders
1111{
1212 internal class ConnectionBuilder
1313 {
14+ const uint DefaultMaxFrameSize = 256 * 1024 ;
15+ const ushort ChannelMax = 255 ;
16+
1417 private readonly ILoggerFactory _loggerFactory ;
1518 private readonly Func < IMessageIdPolicy > _messageIdPolicyFactory ;
19+ private readonly Func < string > _clientIdFactory ;
1620 private readonly TaskCompletionSource < bool > _tcs ;
1721
18- public ConnectionBuilder ( ILoggerFactory loggerFactory , Func < IMessageIdPolicy > messageIdPolicyFactory )
22+ public ConnectionBuilder ( ILoggerFactory loggerFactory ,
23+ Func < IMessageIdPolicy > messageIdPolicyFactory ,
24+ Func < string > clientIdFactory )
1925 {
2026 _loggerFactory = loggerFactory ;
2127 _messageIdPolicyFactory = messageIdPolicyFactory ;
28+ _clientIdFactory = clientIdFactory ;
2229 _tcs = new TaskCompletionSource < bool > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
2330 }
2431
@@ -30,7 +37,8 @@ public async Task<IConnection> CreateAsync(Endpoint endpoint, CancellationToken
3037 var connectionFactory = new Amqp . ConnectionFactory ( ) ;
3138 try
3239 {
33- var connection = await connectionFactory . CreateAsync ( endpoint . Address , null , OnOpened ) . ConfigureAwait ( false ) ;
40+ var open = GetOpenFrame ( endpoint ) ;
41+ var connection = await connectionFactory . CreateAsync ( endpoint . Address , open , OnOpened ) . ConfigureAwait ( false ) ;
3442 connection . AddClosedCallback ( OnClosed ) ;
3543 await _tcs . Task . ConfigureAwait ( false ) ;
3644 connection . Closed -= OnClosed ;
@@ -42,6 +50,22 @@ public async Task<IConnection> CreateAsync(Endpoint endpoint, CancellationToken
4250 }
4351 }
4452
53+ private Open GetOpenFrame ( Endpoint endpoint )
54+ {
55+ if ( _clientIdFactory != null )
56+ {
57+ return new Open
58+ {
59+ ContainerId = _clientIdFactory ( ) ,
60+ HostName = endpoint . Host ,
61+ MaxFrameSize = DefaultMaxFrameSize ,
62+ ChannelMax = ChannelMax
63+ } ;
64+ }
65+
66+ return null ;
67+ }
68+
4569 private void OnOpened ( Amqp . IConnection connection , Open open )
4670 {
4771 if ( connection != null )
0 commit comments