@@ -380,46 +380,45 @@ void TxSenderHandler::on_container_start(container &c)
380
380
for (std::vector< ::proton::symbol >::const_iterator i = caps.begin (); i != caps.end (); ++i) {
381
381
logger (debug) << *i;
382
382
}
383
- // connection_options conn_opts;
384
- //
385
- // if (!user.empty()) conn_opts.user(user);
386
- // if (!password.empty()) conn_opts.password(password);
387
- //
388
- // if (conn_sasl_enabled == "false") {
389
- // conn_opts.sasl_enabled(false);
390
- // } else {
391
- // conn_opts.sasl_enabled(true);
392
- // }
393
- //
394
- // conn_opts.sasl_allow_insecure_mechs(true);
395
- // conn_opts.sasl_allowed_mechs(sasl_mechanisms);
396
- // // conn_opts.max_frame_size(max_frame_size);
397
- // conn_opts.failover_urls(conn_urls);
398
- //
399
- // logger(debug) << "Setting a reconnect timer: " << conn_reconnect;
400
- // logger(debug) << "Custom reconnect: " << conn_reconnect_custom;
401
- //
402
- // configure_reconnect(conn_opts);
403
- // configure_ssl(c);
404
- //
405
- // if (conn_heartbeat != 0) {
406
- // logger(debug) << "Heartbeat: " << conn_heartbeat;
407
- //
408
- // duration heartbeat_seconds = conn_heartbeat * duration::SECOND;
409
- //
410
- // conn_opts.idle_timeout(heartbeat_seconds);
411
- // }
412
- //
413
- // logger(debug) << "Creating a sender";
414
- //
415
- // connection conn;
416
- // if (conn_use_config_file) {
417
- // conn = c.connect();
418
- // } else {
419
- // conn = c.connect(broker_url.getUri(), conn_opts);
420
- // }
421
-
422
- connection conn = c.connect (broker_url.getUri ());
383
+ connection_options conn_opts;
384
+
385
+ if (!user.empty ()) conn_opts.user (user);
386
+ if (!password.empty ()) conn_opts.password (password);
387
+
388
+ if (conn_sasl_enabled == " false" ) {
389
+ conn_opts.sasl_enabled (false );
390
+ } else {
391
+ conn_opts.sasl_enabled (true );
392
+ }
393
+
394
+ conn_opts.sasl_allow_insecure_mechs (true );
395
+ conn_opts.sasl_allowed_mechs (sasl_mechanisms);
396
+ // conn_opts.max_frame_size(max_frame_size);
397
+ conn_opts.failover_urls (conn_urls);
398
+
399
+ logger (debug) << " Setting a reconnect timer: " << conn_reconnect;
400
+ logger (debug) << " Custom reconnect: " << conn_reconnect_custom;
401
+
402
+ configure_reconnect (conn_opts);
403
+ configure_ssl (c);
404
+
405
+ if (conn_heartbeat != 0 ) {
406
+ logger (debug) << " Heartbeat: " << conn_heartbeat;
407
+
408
+ duration heartbeat_seconds = conn_heartbeat * duration::SECOND;
409
+
410
+ conn_opts.idle_timeout (heartbeat_seconds);
411
+ }
412
+
413
+ logger (debug) << " Creating a sender" ;
414
+
415
+ connection conn;
416
+ if (conn_use_config_file) {
417
+ conn = c.connect ();
418
+ } else {
419
+ conn = c.connect (broker_url.getUri (), conn_opts);
420
+ }
421
+
423
422
sndr = conn.open_sender (
424
423
broker_url.getPath (),
425
424
c.sender_options ()
@@ -428,26 +427,26 @@ void TxSenderHandler::on_container_start(container &c)
428
427
)
429
428
);
430
429
431
- // work_q = &sndr.work_queue();
432
- //
433
- // logger(trace) << "Setting up timer";
434
- //
435
- // if (duration_time > 0 && count > 0) {
436
- // interval = duration((duration_time * duration::SECOND) / count);
437
- //
438
- // logger(trace) << "Interval for duration: " << interval.milliseconds() << " ms";
439
- // }
440
- // #if defined(__REACTOR_HAS_TIMER)
441
- // work_q->schedule(duration::IMMEDIATE, make_work(&TxSenderHandler::timerEvent, this));
442
- //
443
- // if (duration_time > 0 && duration_mode == "after-send") {
444
- // work_q->schedule(duration::IMMEDIATE, make_work(&TxSenderHandler::checkIfCanSend, this));
445
- // } else if (duration_time > 0 && duration_mode == "before-send") {
446
- // work_q->schedule(interval, make_work(&TxSenderHandler::checkIfCanSend, this));
447
- // } else {
448
- // work_q->schedule(duration::IMMEDIATE, make_work(&TxSenderHandler::checkIfCanSend, this));
449
- // }
450
- // #endif
430
+ work_q = &sndr.work_queue ();
431
+
432
+ logger (trace) << " Setting up timer" ;
433
+
434
+ if (duration_time > 0 && count > 0 ) {
435
+ interval = duration ((duration_time * duration::SECOND) / count);
436
+
437
+ logger (trace) << " Interval for duration: " << interval.milliseconds () << " ms" ;
438
+ }
439
+ #if defined(__REACTOR_HAS_TIMER)
440
+ work_q->schedule (duration::IMMEDIATE, make_work (&TxSenderHandler::timerEvent, this ));
441
+
442
+ if (duration_time > 0 && duration_mode == " after-send" ) {
443
+ work_q->schedule (duration::IMMEDIATE, make_work (&TxSenderHandler::checkIfCanSend, this ));
444
+ } else if (duration_time > 0 && duration_mode == " before-send" ) {
445
+ work_q->schedule (interval, make_work (&TxSenderHandler::checkIfCanSend, this ));
446
+ } else {
447
+ work_q->schedule (duration::IMMEDIATE, make_work (&TxSenderHandler::checkIfCanSend, this ));
448
+ }
449
+ #endif
451
450
452
451
tx = transaction ();
453
452
logger (debug) << " [on_container_start] declare_txn started..." ;
0 commit comments