Skip to content

Commit b2d60e6

Browse files
committed
create authenticatedchannelfactory
Signed-off-by: Emelia Lei <[email protected]>
1 parent 6b1be26 commit b2d60e6

10 files changed

+841
-417
lines changed

src/groups/bmq/bmqimp/README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ its components directly, but rather use the accessor public APIs from 'bmqa'.
1313

1414
Component Synopsis
1515
------------------
16-
Component | Provides ...
17-
----------------------------------|-----------------------------------------------------------
18-
`bmqimp_application` | the top level object to manipulate a session with bmqbrkr.
19-
`bmqimp_brokersession` | the implementation of a session with the bmqbrkr.
20-
`bmqimp_event` | a value-semantic type representing an event.
21-
`bmqimp_eventqueue` | a thread safe queue of pooled bmqimp::Event items.
22-
`bmqpimp_eventsstats` | a mechanism to keep track of Events statistics.
23-
`bmqpimp_queue` | a type object to represent information about a queue.
24-
`bmqimp_stat` | utilities for stat manipulation.
25-
`bmqimp_connectionchannelfactory` | a channel factory that negotiates with a peer.
16+
Component | Provides ...
17+
-------------------------------------|-----------------------------------------------------------
18+
`bmqimp_application` | the top level object to manipulate a session with bmqbrkr.
19+
`bmqimp_brokersession` | the implementation of a session with the bmqbrkr.
20+
`bmqimp_event` | a value-semantic type representing an event.
21+
`bmqimp_eventqueue` | a thread safe queue of pooled bmqimp::Event items.
22+
`bmqpimp_eventsstats` | a mechanism to keep track of Events statistics.
23+
`bmqpimp_queue` | a type object to represent information about a queue.
24+
`bmqimp_stat` | utilities for stat manipulation.
25+
`bmqimp_authenticatedchannelfactory` | a channel factory that authenticates with a peer.
26+
`bmqimp_negotiatedchannelfactory` | a channel factory that negotiates with a peer.

src/groups/bmq/bmqimp/bmqimp_application.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
// BMQ
2121
#include <bmqex_executionpolicy.h>
2222
#include <bmqex_systemexecutor.h>
23-
#include <bmqimp_connectionchannelfactory.h>
23+
#include <bmqimp_authenticatedchannelfactory.h>
24+
#include <bmqimp_negotiatedchannelfactory.h>
2425
#include <bmqio_channelutil.h>
2526
#include <bmqio_connectoptions.h>
2627
#include <bmqio_status.h>
@@ -389,7 +390,7 @@ bmqt::GenericResult::Enum Application::startChannel()
389390
.setAttemptInterval(attemptInterval)
390391
.setAutoReconnect(true);
391392

392-
d_connectionChannelFactory.connect(
393+
d_negotiatedChannelFactory.connect(
393394
&status,
394395
&d_connectHandle_mp,
395396
options,
@@ -603,11 +604,16 @@ Application::Application(
603604
bdlf::PlaceHolders::_2), // handle
604605
allocator),
605606
allocator)
606-
, d_connectionChannelFactory(
607-
ConnectionChannelFactoryConfig(&d_statChannelFactory,
607+
, d_authenticatedChannelFactory(
608+
AuthenticatedChannelFactoryConfig(&d_statChannelFactory,
609+
sessionOptions.authnCredentialCb(),
610+
sessionOptions.connectTimeout(),
611+
d_blobSpPool_sp.get(),
612+
allocator))
613+
, d_negotiatedChannelFactory(
614+
NegotiatedChannelFactoryConfig(&d_authenticatedChannelFactory,
608615
negotiationMessage,
609616
sessionOptions.connectTimeout(),
610-
sessionOptions.authnCredentialCb(),
611617
d_blobSpPool_sp.get(),
612618
allocator),
613619
allocator)
@@ -719,16 +725,8 @@ int Application::start(const bsls::TimeInterval& timeout)
719725
<< "::: START (SYNC) << [state: " << d_brokerSession.state()
720726
<< "] :::";
721727

722-
int rc = d_connectionChannelFactory.start();
728+
int rc = d_brokerSession.start(timeout);
723729
if (rc != 0) {
724-
BALL_LOG_ERROR << id() << "Failed to start connectionChannelFactory "
725-
<< "[rc: " << rc << "]";
726-
return rc; // RETURN
727-
}
728-
729-
rc = d_brokerSession.start(timeout);
730-
if (rc != 0) {
731-
d_connectionChannelFactory.stop();
732730
return rc; // RETURN
733731
}
734732

@@ -767,9 +765,6 @@ void Application::stop()
767765

768766
// Stop the brokerSession
769767
d_brokerSession.stop();
770-
771-
// Stop the channel factories
772-
d_connectionChannelFactory.stop();
773768
}
774769

775770
void Application::stopAsync()
@@ -791,7 +786,7 @@ Application::createMonitor(const bsl::shared_ptr<bmqio::Channel>& channel)
791786

792787
channel->properties().load(
793788
&maxMissedHeartbeats,
794-
ConnectionChannelFactory::k_CHANNEL_PROPERTY_MAX_MISSED_HEARTBEATS);
789+
NegotiatedChannelFactory::k_CHANNEL_PROPERTY_MAX_MISSED_HEARTBEATS);
795790

796791
bsl::shared_ptr<bmqp::HeartbeatMonitor> monitor(
797792
new (d_allocator) bmqp::HeartbeatMonitor(maxMissedHeartbeats),
@@ -814,7 +809,7 @@ void Application::startHeartbeat(
814809

815810
channel->properties().load(
816811
&heartbeatIntervalMs,
817-
ConnectionChannelFactory::k_CHANNEL_PROPERTY_HEARTBEAT_INTERVAL_MS);
812+
NegotiatedChannelFactory::k_CHANNEL_PROPERTY_HEARTBEAT_INTERVAL_MS);
818813

819814
bsls::TimeInterval interval;
820815
interval.addMilliseconds(heartbeatIntervalMs);

src/groups/bmq/bmqimp/bmqimp_application.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@
3636

3737
// BMQ
3838

39+
#include <bmqimp_authenticatedchannelfactory.h>
3940
#include <bmqimp_brokersession.h>
40-
#include <bmqimp_connectionchannelfactory.h>
4141
#include <bmqimp_eventqueue.h>
42+
#include <bmqimp_negotiatedchannelfactory.h>
4243
#include <bmqp_ctrlmsg_messages.h>
4344
#include <bmqp_heartbeatmonitor.h>
4445
#include <bmqt_sessionoptions.h>
@@ -134,7 +135,9 @@ class Application {
134135

135136
bmqio::StatChannelFactory d_statChannelFactory;
136137

137-
ConnectionChannelFactory d_connectionChannelFactory;
138+
AuthenticatedChannelFactory d_authenticatedChannelFactory;
139+
140+
NegotiatedChannelFactory d_negotiatedChannelFactory;
138141

139142
ChannelFactoryOpHandleMp d_connectHandle_mp;
140143

0 commit comments

Comments
 (0)