You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "sandeep jain (JIRA)" <ji...@apache.org> on 2012/06/12 19:02:43 UTC
[jira] [Comment Edited] (AMQCPP-412) when trying to to close
session or conenction when the producer is already down, close call hangs
forever
[ https://issues.apache.org/jira/browse/AMQCPP-412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13293768#comment-13293768 ]
sandeep jain edited comment on AMQCPP-412 at 6/12/12 5:02 PM:
--------------------------------------------------------------
int main () {
Connection* _connection;
Session* _session ;
Destination* destination;
MessageConsumer* consumer;
std::string _brokerIP1;
std::string _brokerIP2;
std::string _connectedIp;
start();
}
void
cleanup()
{
try {
if (_connection) {
_connection->close();
}
} catch (CMSException& ex) {
std::cout <<"error in closing connection";
}
if ( consumer ) {
delete consumer;
consumer =0;
}
if ( destination ) {
delete destination;
destination = 0;
}
if (_session) {
delete _session;
_session = 0;
}
if (_connection) {
delete _connection;
_connection = 0;
}
}
void
start()
{
_brokerIP1 = "127.0.0.1:61616";
_brokerIP2 = _brokerIP2;
std::string URI = _brokerIP1;
while (1){
std::string connectionURI = "failover:(tcp://"
+ URI +
")?randomize=false&maxReconnectAttempts=1";
activemq::core::ActiveMQConnectionFactory factory =
activemq::core::ActiveMQConnectionFactory (connectionURI);
try {
_connection = factory.createConnection();
} catch (CMSException& e){
//exception
}
if (_connection) {
break;
}
URI = ( URI == _brokerIP1) ? _brokerIP2 : _brokerIP1;
sleep(5);
}
_connectedIp = URI;
// Create a connection.
_connection->setExceptionListener(this);
_session = _connection->createSession(Session::AUTO_ACKNOWLEDGE);
desitnation = _session->createTopic("Topic");
consumer = _session->createConsumer(destination);
consumer->setMessageListener(this);
_connection->start();
}
void
onMessage(const Message* origMessage)
throw ()
{
try {
//reading data
} catch (CMSException& ex) {
//exception
} catch (std::exception &ex) {
//exception
}
}
void
onException(const CMSException& ex) {
std::cout << "disconnected from " << _connectedIp.c_str();
cleanup();
sleep(5);
start();
}
was (Author: sandeepjn):
Here is the sample code:
int main () {
Connection* _connection;
Session* _session ;
Destination* destination;
MessageConsumer* consumer;
std::string _brokerIP1;
std::string _brokerIP2;
std::string _connectedIp;
start();
}
void
cleanup()
{
try {
if (_connection) {
_connection->close();
}
} catch (CMSException& ex) {
std::cout <<"error in closing connection";
}
if ( consumer ) {
delete consumer;
consumer =0;
}
if ( destination ) {
delete destination;
destination = 0;
}
if (_session) {
delete _session;
_session = 0;
}
if (_connection) {
delete _connection;
_connection = 0;
}
}
void
start()
{
_brokerIP1 = "127.0.0.1:61616";
_brokerIP2 = _brokerIP2;
while (1){
std::string connectionURI = "failover:(tcp://"
+ brokerIP +
")?randomize=false&maxReconnectAttempts=1";
activemq::core::ActiveMQConnectionFactory factory =
activemq::core::ActiveMQConnectionFactory (connectionURI);
try {
_connection = factory.createConnection();
} catch (CMSException& e){
//exception
}
if (_connection) {
break;
}
sleep(5);
}
_connectedIp = connectionURI;
// Create a connection.
_connection->setExceptionListener(this);
_session = _connection->createSession(Session::AUTO_ACKNOWLEDGE);
desitnation = _session->createTopic("Topic");
consumer = _session->createConsumer(destination);
consumer->setMessageListener(this);
_connection->start();
}
void
onMessage(const Message* origMessage)
throw ()
{
try {
//reading data
} catch (CMSException& ex) {
//exception
} catch (std::exception &ex) {
//exception
}
}
void
onException(const CMSException& ex) {
std::cout << "disconnected from " << _connectedIp.c_str();
cleanup();
sleep(5);
start();
}
> when trying to to close session or conenction when the producer is already down, close call hangs forever
> ---------------------------------------------------------------------------------------------------------
>
> Key: AMQCPP-412
> URL: https://issues.apache.org/jira/browse/AMQCPP-412
> Project: ActiveMQ C++ Client
> Issue Type: Bug
> Components: Integration Tests
> Affects Versions: 3.0
> Environment: Unix
> Reporter: sandeep jain
> Assignee: Timothy Bish
> Labels: performance
>
> when trying to close the session on connection when producer is already down, the close call hangs forever and neither come out of the call nor throw any ex ception.
> backtrace for the same is:
> 0x28bb33ed in activemq::core::ActiveMQConnection::syncRequest ()
> from libactivemq-cpp.so.1
> #1 0x28bb3949 in activemq::core::ActiveMQConnection::disposeOf ()
> from libactivemq-cpp.so.1
> #2 0x28bb3ce4 in activemq::core::ActiveMQConnection::disconnect ()
> from libactivemq-cpp.so.1
> #3 0x28bb7c9a in activemq::core::ActiveMQConnection::close ()
> from libactivemq-cpp.so.1
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira