Return-Path: Delivered-To: apmail-geronimo-activemq-commits-archive@www.apache.org Received: (qmail 97047 invoked from network); 6 Jul 2006 03:18:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 6 Jul 2006 03:18:48 -0000 Received: (qmail 22239 invoked by uid 500); 6 Jul 2006 03:18:47 -0000 Delivered-To: apmail-geronimo-activemq-commits-archive@geronimo.apache.org Received: (qmail 22156 invoked by uid 500); 6 Jul 2006 03:18:46 -0000 Mailing-List: contact activemq-commits-help@geronimo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: activemq-dev@geronimo.apache.org Delivered-To: mailing list activemq-commits@geronimo.apache.org Received: (qmail 22067 invoked by uid 99); 6 Jul 2006 03:18:45 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Jul 2006 20:18:45 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Jul 2006 20:18:39 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 7799C1A981A; Wed, 5 Jul 2006 20:18:19 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r419422 [1/11] - in /incubator/activemq/trunk/openwire-cpp/src/main/cpp: activemq/ activemq/command/ activemq/protocol/openwire/ activemq/transport/ activemq/transport/tcp/ cms/ ppr/ ppr/io/ ppr/io/encoding/ ppr/net/ ppr/thread/ ppr/util/ Date: Thu, 06 Jul 2006 03:18:03 -0000 To: activemq-commits@geronimo.apache.org From: chirino@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060706031819.7799C1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: chirino Date: Wed Jul 5 20:17:58 2006 New Revision: 419422 URL: http://svn.apache.org/viewvc?rev=419422&view=rev Log: set the eol style to native Modified: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/BrokerException.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConnectionClosedException.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConnectionFactory.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConsumerClosedException.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/DestinationFilter.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/Dispatcher.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageConsumer.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageConsumerSynchronization.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageProducer.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/Session.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/TransactionContext.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQBytesMessage.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQDestination.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMapMessage.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQMessage.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQObjectMessage.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQQueue.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQStreamMessage.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTempDestination.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTempQueue.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTempTopic.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTextMessage.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ActiveMQTopic.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/BaseCommand.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/BaseDataStructure.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/BrokerError.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/BrokerId.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/BrokerInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ConnectionControl.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ConnectionError.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ConnectionId.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ConnectionInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ConsumerControl.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ConsumerId.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ConsumerInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ControlCommand.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/DataArrayResponse.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/DataResponse.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/DestinationInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/DiscoveryEvent.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ExceptionResponse.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/FlushCommand.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/IntegerResponse.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/JournalQueueAck.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/JournalTopicAck.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/JournalTrace.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/JournalTransaction.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/KeepAliveInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/LastPartialCommand.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/LocalTransactionId.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/Message.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/MessageAck.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/MessageDispatch.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/MessageDispatchNotification.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/MessageId.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/NetworkBridgeFilter.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/PartialCommand.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ProducerId.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ProducerInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/RemoveInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/RemoveSubscriptionInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ReplayCommand.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/Response.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/SessionId.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/SessionInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/ShutdownInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/SubscriptionInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/TransactionId.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/TransactionInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/WireFormatInfo.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/command/XATransactionId.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/protocol/openwire/OpenWireMarshaller.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/protocol/openwire/OpenWireProtocol.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/transport/CorrelatorFilter.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/transport/FutureResponse.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/transport/LoggingFilter.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/transport/MutexFilter.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/transport/TransportFactory.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/transport/TransportFilter.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/transport/tcp/TcpTransport.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/cms/CmsException.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/TraceException.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/io/BufferedInputStream.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/io/BufferedOutputStream.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/io/ByteArrayInputStream.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/io/ByteArrayOutputStream.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/io/DataInputStream.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/io/DataOutputStream.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/io/SocketInputStream.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/io/SocketOutputStream.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/io/encoding/AsciiToUTF8Encoder.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/io/encoding/CharsetEncoderRegistry.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/ServerSocket.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Socket.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/net/Uri.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/thread/Thread.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Guid.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Hex.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/MapItemHolder.cpp (contents, props changed) incubator/activemq/trunk/openwire-cpp/src/main/cpp/ppr/util/Time.cpp (contents, props changed) Modified: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/BrokerException.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/BrokerException.cpp?rev=419422&r1=419421&r2=419422&view=diff ============================================================================== --- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/BrokerException.cpp (original) +++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/BrokerException.cpp Wed Jul 5 20:17:58 2006 @@ -1,48 +1,48 @@ -/* - * Copyright 2006 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "activemq/BrokerException.hpp" - -using namespace apache::activemq; - -/* - * - */ -BrokerException::BrokerException(p brokerError) -{ - this->brokerError = brokerError ; - - // Build exception message - msg.assign( brokerError->getExceptionClass()->c_str() ) ; - msg.append( " : " ) ; - msg.append( brokerError->getMessage()->c_str() ) ; -} - -/* - * - */ -p BrokerException::getBrokerError() -{ - return brokerError ; -} - -/* - * - */ -p BrokerException::getJavaStackTrace() -{ - return brokerError->getStackTrace() ; -} +/* + * Copyright 2006 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "activemq/BrokerException.hpp" + +using namespace apache::activemq; + +/* + * + */ +BrokerException::BrokerException(p brokerError) +{ + this->brokerError = brokerError ; + + // Build exception message + msg.assign( brokerError->getExceptionClass()->c_str() ) ; + msg.append( " : " ) ; + msg.append( brokerError->getMessage()->c_str() ) ; +} + +/* + * + */ +p BrokerException::getBrokerError() +{ + return brokerError ; +} + +/* + * + */ +p BrokerException::getJavaStackTrace() +{ + return brokerError->getStackTrace() ; +} Propchange: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/BrokerException.cpp ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConnectionClosedException.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConnectionClosedException.cpp?rev=419422&r1=419421&r2=419422&view=diff ============================================================================== --- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConnectionClosedException.cpp (original) +++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConnectionClosedException.cpp Wed Jul 5 20:17:58 2006 @@ -1,29 +1,29 @@ -/* - * Copyright 2006 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "activemq/ConnectionClosedException.hpp" - -using namespace apache::activemq; - -/* - * - */ -ConnectionClosedException::ConnectionClosedException(const char* message) - : CmsException(message) -{ - // no-op -} - +/* + * Copyright 2006 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "activemq/ConnectionClosedException.hpp" + +using namespace apache::activemq; + +/* + * + */ +ConnectionClosedException::ConnectionClosedException(const char* message) + : CmsException(message) +{ + // no-op +} + Propchange: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConnectionClosedException.cpp ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConnectionFactory.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConnectionFactory.cpp?rev=419422&r1=419421&r2=419422&view=diff ============================================================================== --- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConnectionFactory.cpp (original) +++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConnectionFactory.cpp Wed Jul 5 20:17:58 2006 @@ -1,184 +1,184 @@ -/* - * Copyright 2006 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "activemq/ConnectionFactory.hpp" -#include "activemq/Connection.hpp" -#include "activemq/protocol/openwire/OpenWireProtocol.hpp" -#include "activemq/transport/tcp/TcpTransport.hpp" - -using namespace apache::activemq; - -/* - * - */ -ConnectionFactory::ConnectionFactory() -{ - // Use default URI - brokerUri = new Uri ("tcp://localhost:61616") ; - username = NULL ; - password = NULL ; - clientId = Guid::getGuidString() ; - transportFactory = new TransportFactory() ; -} - -/* - * - */ -ConnectionFactory::ConnectionFactory(p brokerUri) -{ - this->brokerUri = brokerUri; - username = NULL ; - password = NULL ; - clientId = Guid::getGuidString() ; - transportFactory = new TransportFactory() ; -} - - -// --- Attribute methods -------------------------------------------- - -/* - * - */ -p ConnectionFactory::getBrokerUri() -{ - return brokerUri ; -} - -/* - * - */ -void ConnectionFactory::setBrokerUri(p brokerUri) -{ - this->brokerUri = brokerUri ; -} - -/* - * - */ -p ConnectionFactory::getUsername() -{ - return username ; -} - -/* - * - */ -void ConnectionFactory::setUsername(const char* username) -{ - this->username = new string(username) ; -} - -/* - * - */ -p ConnectionFactory::getPassword() -{ - return password ; -} - -/* - * - */ -void ConnectionFactory::setPassword(const char* password) -{ - this->password = new string(password); - -} - -/* - * - */ -p ConnectionFactory::getClientId() -{ - return clientId ; -} - -/* - * - */ -void ConnectionFactory::setClientId(const char* clientId) -{ - this->clientId = new string(clientId) ; -} - - -// --- Operation methods -------------------------------------------- - -/* - * - */ -p ConnectionFactory::createConnection() throw (ConnectionException) -{ - return createConnection( (username != NULL) ? username->c_str() : NULL, - (password != NULL) ? password->c_str() : NULL ) ; -} - -/* - * - */ -p ConnectionFactory::createConnection(const char* username, const char* password) throw (ConnectionException) -{ - p connectionInfo ; - p transport ; - p connection ; - - - // Set up a new connection object - connectionInfo = createConnectionInfo(username, password) ; - transport = createTransport() ; - connection = new Connection(transport, connectionInfo) ; - connection->setClientId( clientId->c_str() ) ; - - return connection ; -} - - -// --- Implementation methods --------------------------------------- - -/* - * - */ -p ConnectionFactory::createConnectionInfo(const char* username, const char* password) -{ - p connectionInfo = new ConnectionInfo() ; - p connectionId = new ConnectionId() ; - p uid = (username != NULL) ? new string(username) : NULL ; - p pwd = (password != NULL) ? new string(password) : NULL ; - - connectionId->setValue( Guid::getGuidString() ) ; - connectionInfo->setConnectionId( connectionId ) ; - connectionInfo->setUserName( uid ) ; - connectionInfo->setPassword( pwd ) ; - connectionInfo->setClientId( clientId ) ; - - return connectionInfo ; -} - -/* - * - */ -p ConnectionFactory::createTransport() throw (ConnectionException) -{ - try - { - // Create a transport for given URI - return transportFactory->createTransport( brokerUri ) ; - } - catch( SocketException se ) - { - throw ConnectionException(__FILE__, __LINE__, "Failed to connect socket") ; - } -} +/* + * Copyright 2006 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "activemq/ConnectionFactory.hpp" +#include "activemq/Connection.hpp" +#include "activemq/protocol/openwire/OpenWireProtocol.hpp" +#include "activemq/transport/tcp/TcpTransport.hpp" + +using namespace apache::activemq; + +/* + * + */ +ConnectionFactory::ConnectionFactory() +{ + // Use default URI + brokerUri = new Uri ("tcp://localhost:61616") ; + username = NULL ; + password = NULL ; + clientId = Guid::getGuidString() ; + transportFactory = new TransportFactory() ; +} + +/* + * + */ +ConnectionFactory::ConnectionFactory(p brokerUri) +{ + this->brokerUri = brokerUri; + username = NULL ; + password = NULL ; + clientId = Guid::getGuidString() ; + transportFactory = new TransportFactory() ; +} + + +// --- Attribute methods -------------------------------------------- + +/* + * + */ +p ConnectionFactory::getBrokerUri() +{ + return brokerUri ; +} + +/* + * + */ +void ConnectionFactory::setBrokerUri(p brokerUri) +{ + this->brokerUri = brokerUri ; +} + +/* + * + */ +p ConnectionFactory::getUsername() +{ + return username ; +} + +/* + * + */ +void ConnectionFactory::setUsername(const char* username) +{ + this->username = new string(username) ; +} + +/* + * + */ +p ConnectionFactory::getPassword() +{ + return password ; +} + +/* + * + */ +void ConnectionFactory::setPassword(const char* password) +{ + this->password = new string(password); + +} + +/* + * + */ +p ConnectionFactory::getClientId() +{ + return clientId ; +} + +/* + * + */ +void ConnectionFactory::setClientId(const char* clientId) +{ + this->clientId = new string(clientId) ; +} + + +// --- Operation methods -------------------------------------------- + +/* + * + */ +p ConnectionFactory::createConnection() throw (ConnectionException) +{ + return createConnection( (username != NULL) ? username->c_str() : NULL, + (password != NULL) ? password->c_str() : NULL ) ; +} + +/* + * + */ +p ConnectionFactory::createConnection(const char* username, const char* password) throw (ConnectionException) +{ + p connectionInfo ; + p transport ; + p connection ; + + + // Set up a new connection object + connectionInfo = createConnectionInfo(username, password) ; + transport = createTransport() ; + connection = new Connection(transport, connectionInfo) ; + connection->setClientId( clientId->c_str() ) ; + + return connection ; +} + + +// --- Implementation methods --------------------------------------- + +/* + * + */ +p ConnectionFactory::createConnectionInfo(const char* username, const char* password) +{ + p connectionInfo = new ConnectionInfo() ; + p connectionId = new ConnectionId() ; + p uid = (username != NULL) ? new string(username) : NULL ; + p pwd = (password != NULL) ? new string(password) : NULL ; + + connectionId->setValue( Guid::getGuidString() ) ; + connectionInfo->setConnectionId( connectionId ) ; + connectionInfo->setUserName( uid ) ; + connectionInfo->setPassword( pwd ) ; + connectionInfo->setClientId( clientId ) ; + + return connectionInfo ; +} + +/* + * + */ +p ConnectionFactory::createTransport() throw (ConnectionException) +{ + try + { + // Create a transport for given URI + return transportFactory->createTransport( brokerUri ) ; + } + catch( SocketException se ) + { + throw ConnectionException(__FILE__, __LINE__, "Failed to connect socket") ; + } +} Propchange: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConnectionFactory.cpp ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConsumerClosedException.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConsumerClosedException.cpp?rev=419422&r1=419421&r2=419422&view=diff ============================================================================== --- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConsumerClosedException.cpp (original) +++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConsumerClosedException.cpp Wed Jul 5 20:17:58 2006 @@ -1,29 +1,29 @@ -/* - * Copyright 2006 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "activemq/ConsumerClosedException.hpp" - -using namespace apache::activemq; - -/* - * - */ -ConsumerClosedException::ConsumerClosedException(const char* message) - : CmsException(message) -{ - // no-op -} - +/* + * Copyright 2006 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "activemq/ConsumerClosedException.hpp" + +using namespace apache::activemq; + +/* + * + */ +ConsumerClosedException::ConsumerClosedException(const char* message) + : CmsException(message) +{ + // no-op +} + Propchange: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/ConsumerClosedException.cpp ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/DestinationFilter.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/DestinationFilter.cpp?rev=419422&r1=419421&r2=419422&view=diff ============================================================================== --- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/DestinationFilter.cpp (original) +++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/DestinationFilter.cpp Wed Jul 5 20:17:58 2006 @@ -1,47 +1,47 @@ -/* - * Copyright 2006 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "activemq/DestinationFilter.hpp" - -using namespace apache::activemq; - -// Init static constants -const char* DestinationFilter::ANY_DESCENDENT = ">" ; -const char* DestinationFilter::ANY_CHILD = "*" ; - -/* - * - */ -DestinationFilter::DestinationFilter() -{ - // no-op -} - -/* - * - */ -DestinationFilter::~DestinationFilter() -{ - // no-op -} - -/* - * - */ -bool DestinationFilter::matches(p message) -{ - return matches( message->getDestination() ) ; -} +/* + * Copyright 2006 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "activemq/DestinationFilter.hpp" + +using namespace apache::activemq; + +// Init static constants +const char* DestinationFilter::ANY_DESCENDENT = ">" ; +const char* DestinationFilter::ANY_CHILD = "*" ; + +/* + * + */ +DestinationFilter::DestinationFilter() +{ + // no-op +} + +/* + * + */ +DestinationFilter::~DestinationFilter() +{ + // no-op +} + +/* + * + */ +bool DestinationFilter::matches(p message) +{ + return matches( message->getDestination() ) ; +} Propchange: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/DestinationFilter.cpp ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/Dispatcher.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/Dispatcher.cpp?rev=419422&r1=419421&r2=419422&view=diff ============================================================================== --- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/Dispatcher.cpp (original) +++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/Dispatcher.cpp Wed Jul 5 20:17:58 2006 @@ -1,140 +1,140 @@ -/* - * Copyright 2006 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "activemq/Dispatcher.hpp" - -using namespace apache::activemq; - -/* - * - */ -Dispatcher::Dispatcher() -{ - dispatchQueue = new queue< p > ; - redeliverList = new list< p > ; -} - -/* - * - */ -void Dispatcher::redeliverRolledBackMessages() -{ - LOCKED_SCOPE (mutex); - - p > > replacementQueue = new queue< p > ; - //(dispatchQueue->size() + redeliverList->size() ) ; - - // Copy all messages to be redelivered to the new queue - while( !redeliverList->empty() ) - { - replacementQueue->push( redeliverList->front() ) ; - redeliverList->pop_front() ; - } - - // Copy all messages to be dispatched to the new queue - while( dispatchQueue->size() > 0 ) - { - // Get first element in queue - p element = p_cast (dispatchQueue->front()) ; - - // Remove first element from queue - dispatchQueue->pop() ; - - // Add element to the new queue - replacementQueue->push(element) ; - } - // Switch to the new queue - dispatchQueue = replacementQueue ; - - semaphore.notify() ; -} - -/* - * - */ -void Dispatcher::redeliver(p message) -{ - LOCKED_SCOPE (mutex); - redeliverList->push_back(message) ; -} - -/* - * - */ -void Dispatcher::enqueue(p message) -{ - LOCKED_SCOPE (mutex); - dispatchQueue->push(message) ; - semaphore.notify() ; -} - -/* - * - */ -p Dispatcher::dequeueNoWait() -{ - p msg = NULL ; - - { - LOCKED_SCOPE (mutex); - - if( dispatchQueue->size() > 0 ) - { - msg = p_cast (dispatchQueue->front()) ; - dispatchQueue->pop() ; - } - } - return msg ; -} - -/* - * - */ -p Dispatcher::dequeue(int timeout) -{ - p msg = NULL ; - - { - LOCKED_SCOPE (mutex); - - if( dispatchQueue->size() == 0 ) - semaphore.wait(timeout) ; - - if( dispatchQueue->size() > 0 ) - { - msg = p_cast (dispatchQueue->front()) ; - dispatchQueue->pop() ; - } - } - return msg ; -} - -/* - * - */ -p Dispatcher::dequeue() -{ - p msg = NULL ; - - { - LOCKED_SCOPE (mutex); - - msg = p_cast (dispatchQueue->front()) ; - dispatchQueue->pop() ; - } - - return msg ; -} +/* + * Copyright 2006 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "activemq/Dispatcher.hpp" + +using namespace apache::activemq; + +/* + * + */ +Dispatcher::Dispatcher() +{ + dispatchQueue = new queue< p > ; + redeliverList = new list< p > ; +} + +/* + * + */ +void Dispatcher::redeliverRolledBackMessages() +{ + LOCKED_SCOPE (mutex); + + p > > replacementQueue = new queue< p > ; + //(dispatchQueue->size() + redeliverList->size() ) ; + + // Copy all messages to be redelivered to the new queue + while( !redeliverList->empty() ) + { + replacementQueue->push( redeliverList->front() ) ; + redeliverList->pop_front() ; + } + + // Copy all messages to be dispatched to the new queue + while( dispatchQueue->size() > 0 ) + { + // Get first element in queue + p element = p_cast (dispatchQueue->front()) ; + + // Remove first element from queue + dispatchQueue->pop() ; + + // Add element to the new queue + replacementQueue->push(element) ; + } + // Switch to the new queue + dispatchQueue = replacementQueue ; + + semaphore.notify() ; +} + +/* + * + */ +void Dispatcher::redeliver(p message) +{ + LOCKED_SCOPE (mutex); + redeliverList->push_back(message) ; +} + +/* + * + */ +void Dispatcher::enqueue(p message) +{ + LOCKED_SCOPE (mutex); + dispatchQueue->push(message) ; + semaphore.notify() ; +} + +/* + * + */ +p Dispatcher::dequeueNoWait() +{ + p msg = NULL ; + + { + LOCKED_SCOPE (mutex); + + if( dispatchQueue->size() > 0 ) + { + msg = p_cast (dispatchQueue->front()) ; + dispatchQueue->pop() ; + } + } + return msg ; +} + +/* + * + */ +p Dispatcher::dequeue(int timeout) +{ + p msg = NULL ; + + { + LOCKED_SCOPE (mutex); + + if( dispatchQueue->size() == 0 ) + semaphore.wait(timeout) ; + + if( dispatchQueue->size() > 0 ) + { + msg = p_cast (dispatchQueue->front()) ; + dispatchQueue->pop() ; + } + } + return msg ; +} + +/* + * + */ +p Dispatcher::dequeue() +{ + p msg = NULL ; + + { + LOCKED_SCOPE (mutex); + + msg = p_cast (dispatchQueue->front()) ; + dispatchQueue->pop() ; + } + + return msg ; +} Propchange: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/Dispatcher.cpp ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageConsumer.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageConsumer.cpp?rev=419422&r1=419421&r2=419422&view=diff ============================================================================== --- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageConsumer.cpp (original) +++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageConsumer.cpp Wed Jul 5 20:17:58 2006 @@ -1,307 +1,307 @@ -/* - * Copyright 2006 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "activemq/MessageConsumer.hpp" -#include "activemq/Session.hpp" - -using namespace apache::activemq; - -/* - * - */ -MessageConsumer::MessageConsumer(p session, p consumerInfo, AcknowledgementMode acknowledgementMode) -{ - this->session = session ; - this->consumerInfo = consumerInfo ; - this->acknowledgementMode = acknowledgementMode ; - this->dispatcher = new Dispatcher() ; - this->listener = NULL ; - this->closed = false ; - this->maximumRedeliveryCount = 10 ; - this->redeliveryTimeout = 500 ; -} - -/* - * - */ -MessageConsumer::~MessageConsumer() -{ - // Make sure consumer is closed - close() ; -} - -// Attribute methods ------------------------------------------------ - -/* - * - */ -void MessageConsumer::setMessageListener(p listener) -{ - this->listener = listener ; -} - -/* - * - */ -p MessageConsumer::getMessageListener() -{ - return listener ; -} - -/* - * - */ -p MessageConsumer::getConsumerId() -{ - return consumerInfo->getConsumerId() ; -} - -/* - * - */ -void MessageConsumer::setMaximumRedeliveryCount(int count) -{ - this->maximumRedeliveryCount = count ; -} - -/* - * - */ -int MessageConsumer::getMaximumRedeliveryCount() -{ - return maximumRedeliveryCount ; -} - -/* - * - */ -void MessageConsumer::setRedeliveryTimeout(int timeout) -{ - this->redeliveryTimeout = timeout ; -} - -/* - * - */ -int MessageConsumer::getRedeliveryTimeout() -{ - return redeliveryTimeout ; -} - - -// Operation methods ------------------------------------------------ - -/* - * - */ -p MessageConsumer::receive() -{ - checkClosed() ; - return autoAcknowledge( dispatcher->dequeue() ) ; -} - -/* - * - */ -p MessageConsumer::receive(int timeout) -{ - checkClosed() ; - return autoAcknowledge( dispatcher->dequeue(timeout) ) ; -} - -/* - * - */ -p MessageConsumer::receiveNoWait() -{ - checkClosed() ; - return autoAcknowledge( dispatcher->dequeueNoWait() ) ; -} - -/* - * - */ -void MessageConsumer::redeliverRolledBackMessages() -{ - dispatcher->redeliverRolledBackMessages() ; -} - -/* - * Transport callback that handles messages dispatching - */ -void MessageConsumer::dispatch(p message) -{ - dispatcher->enqueue(message) ; - - // Activate background dispatch thread if async listener is set up - if( listener != NULL ) - session->dispatch() ; -} - -/* - * - */ -void MessageConsumer::dispatchAsyncMessages() -{ - while( listener != NULL ) - { - p message = dispatcher->dequeueNoWait() ; - - if( message != NULL ) - { - // Auto acknowledge message if selected - autoAcknowledge(message) ; - - // Let listener process message - listener->onMessage(message) ; - } - else - break ; - } -} - -/* - * IAcknowledger callback method. - */ -void MessageConsumer::acknowledge(p message) -{ - doClientAcknowledge(message) ; -} - -/* - * - */ -void MessageConsumer::close() -{ - if( !closed ) - { - closed = true ; - - // De-register consumer from broker - session->getConnection()->disposeOf( consumerInfo->getConsumerId() ) ; - - // Reset internal state (prevent cyclic references) - session = NULL ; - } -} - - -// Implementation methods ------------------------------------------------ - -/* - * - */ -void MessageConsumer::checkClosed() throw(CmsException) -{ - if( closed ) - throw ConnectionClosedException("Oops! Connection already closed") ; -} - -/* - * - */ -p MessageConsumer::autoAcknowledge(p message) -{ - try - { - // Is the message an ActiveMQMessage? (throws bad_cast otherwise) - p activeMessage = p_dyncast (message) ; - - // Register the handler for client acknowledgment - activeMessage->setAcknowledger( smartify(this) ) ; - - if( acknowledgementMode != ClientAckMode ) - doAcknowledge(activeMessage) ; - } - catch( bad_cast& bc ) - { - // ignore - } - return message ; -} - -/* - * - */ -void MessageConsumer::doClientAcknowledge(p message) -{ - if( acknowledgementMode == ClientAckMode ) - doAcknowledge(message); -} - -/* - * - */ -void MessageConsumer::doAcknowledge(p message) -{ - p ack = createMessageAck(message) ; - session->getConnection()->oneway(ack) ; -} - -/* - * - */ -p MessageConsumer::createMessageAck(p message) -{ - p ack = new MessageAck() ; - - // Set ack properties - ack->setAckType( ConsumedAck ) ; - ack->setConsumerId( consumerInfo->getConsumerId() ) ; - ack->setDestination( message->getDestination() ) ; - ack->setFirstMessageId( message->getMessageId() ) ; - ack->setLastMessageId( message->getMessageId() ) ; - ack->setMessageCount( 1 ) ; - - if( session->isTransacted() ) - { - session->doStartTransaction() ; - ack->setTransactionId( session->getTransactionContext()->getTransactionId() ) ; - session->getTransactionContext()->addSynchronization( new MessageConsumerSynchronization(smartify(this), message) ) ; - } - return ack ; -} - -/* - * - */ -void MessageConsumer::afterRollback(p message) -{ - // Try redeliver of the message again - message->setRedeliveryCounter( message->getRedeliveryCounter() + 1 ) ; - - // Check if redeliver count has exceeded maximum - if( message->getRedeliveryCounter() > maximumRedeliveryCount ) - { - // Send back a poisoned pill - p ack = new MessageAck() ; - ack->setAckType( PoisonAck ) ; - ack->setConsumerId( consumerInfo->getConsumerId() ) ; - ack->setDestination( message->getDestination() ) ; - ack->setFirstMessageId( message->getMessageId() ) ; - ack->setLastMessageId( message->getMessageId() ) ; - ack->setMessageCount( 1 ) ; - session->getConnection()->oneway(ack) ; - } - else - { - dispatcher->redeliver(message) ; - - // Re-dispatch the message at some point in the future - if( listener != NULL ) - session->dispatch( redeliveryTimeout ) ; - } -} +/* + * Copyright 2006 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "activemq/MessageConsumer.hpp" +#include "activemq/Session.hpp" + +using namespace apache::activemq; + +/* + * + */ +MessageConsumer::MessageConsumer(p session, p consumerInfo, AcknowledgementMode acknowledgementMode) +{ + this->session = session ; + this->consumerInfo = consumerInfo ; + this->acknowledgementMode = acknowledgementMode ; + this->dispatcher = new Dispatcher() ; + this->listener = NULL ; + this->closed = false ; + this->maximumRedeliveryCount = 10 ; + this->redeliveryTimeout = 500 ; +} + +/* + * + */ +MessageConsumer::~MessageConsumer() +{ + // Make sure consumer is closed + close() ; +} + +// Attribute methods ------------------------------------------------ + +/* + * + */ +void MessageConsumer::setMessageListener(p listener) +{ + this->listener = listener ; +} + +/* + * + */ +p MessageConsumer::getMessageListener() +{ + return listener ; +} + +/* + * + */ +p MessageConsumer::getConsumerId() +{ + return consumerInfo->getConsumerId() ; +} + +/* + * + */ +void MessageConsumer::setMaximumRedeliveryCount(int count) +{ + this->maximumRedeliveryCount = count ; +} + +/* + * + */ +int MessageConsumer::getMaximumRedeliveryCount() +{ + return maximumRedeliveryCount ; +} + +/* + * + */ +void MessageConsumer::setRedeliveryTimeout(int timeout) +{ + this->redeliveryTimeout = timeout ; +} + +/* + * + */ +int MessageConsumer::getRedeliveryTimeout() +{ + return redeliveryTimeout ; +} + + +// Operation methods ------------------------------------------------ + +/* + * + */ +p MessageConsumer::receive() +{ + checkClosed() ; + return autoAcknowledge( dispatcher->dequeue() ) ; +} + +/* + * + */ +p MessageConsumer::receive(int timeout) +{ + checkClosed() ; + return autoAcknowledge( dispatcher->dequeue(timeout) ) ; +} + +/* + * + */ +p MessageConsumer::receiveNoWait() +{ + checkClosed() ; + return autoAcknowledge( dispatcher->dequeueNoWait() ) ; +} + +/* + * + */ +void MessageConsumer::redeliverRolledBackMessages() +{ + dispatcher->redeliverRolledBackMessages() ; +} + +/* + * Transport callback that handles messages dispatching + */ +void MessageConsumer::dispatch(p message) +{ + dispatcher->enqueue(message) ; + + // Activate background dispatch thread if async listener is set up + if( listener != NULL ) + session->dispatch() ; +} + +/* + * + */ +void MessageConsumer::dispatchAsyncMessages() +{ + while( listener != NULL ) + { + p message = dispatcher->dequeueNoWait() ; + + if( message != NULL ) + { + // Auto acknowledge message if selected + autoAcknowledge(message) ; + + // Let listener process message + listener->onMessage(message) ; + } + else + break ; + } +} + +/* + * IAcknowledger callback method. + */ +void MessageConsumer::acknowledge(p message) +{ + doClientAcknowledge(message) ; +} + +/* + * + */ +void MessageConsumer::close() +{ + if( !closed ) + { + closed = true ; + + // De-register consumer from broker + session->getConnection()->disposeOf( consumerInfo->getConsumerId() ) ; + + // Reset internal state (prevent cyclic references) + session = NULL ; + } +} + + +// Implementation methods ------------------------------------------------ + +/* + * + */ +void MessageConsumer::checkClosed() throw(CmsException) +{ + if( closed ) + throw ConnectionClosedException("Oops! Connection already closed") ; +} + +/* + * + */ +p MessageConsumer::autoAcknowledge(p message) +{ + try + { + // Is the message an ActiveMQMessage? (throws bad_cast otherwise) + p activeMessage = p_dyncast (message) ; + + // Register the handler for client acknowledgment + activeMessage->setAcknowledger( smartify(this) ) ; + + if( acknowledgementMode != ClientAckMode ) + doAcknowledge(activeMessage) ; + } + catch( bad_cast& bc ) + { + // ignore + } + return message ; +} + +/* + * + */ +void MessageConsumer::doClientAcknowledge(p message) +{ + if( acknowledgementMode == ClientAckMode ) + doAcknowledge(message); +} + +/* + * + */ +void MessageConsumer::doAcknowledge(p message) +{ + p ack = createMessageAck(message) ; + session->getConnection()->oneway(ack) ; +} + +/* + * + */ +p MessageConsumer::createMessageAck(p message) +{ + p ack = new MessageAck() ; + + // Set ack properties + ack->setAckType( ConsumedAck ) ; + ack->setConsumerId( consumerInfo->getConsumerId() ) ; + ack->setDestination( message->getDestination() ) ; + ack->setFirstMessageId( message->getMessageId() ) ; + ack->setLastMessageId( message->getMessageId() ) ; + ack->setMessageCount( 1 ) ; + + if( session->isTransacted() ) + { + session->doStartTransaction() ; + ack->setTransactionId( session->getTransactionContext()->getTransactionId() ) ; + session->getTransactionContext()->addSynchronization( new MessageConsumerSynchronization(smartify(this), message) ) ; + } + return ack ; +} + +/* + * + */ +void MessageConsumer::afterRollback(p message) +{ + // Try redeliver of the message again + message->setRedeliveryCounter( message->getRedeliveryCounter() + 1 ) ; + + // Check if redeliver count has exceeded maximum + if( message->getRedeliveryCounter() > maximumRedeliveryCount ) + { + // Send back a poisoned pill + p ack = new MessageAck() ; + ack->setAckType( PoisonAck ) ; + ack->setConsumerId( consumerInfo->getConsumerId() ) ; + ack->setDestination( message->getDestination() ) ; + ack->setFirstMessageId( message->getMessageId() ) ; + ack->setLastMessageId( message->getMessageId() ) ; + ack->setMessageCount( 1 ) ; + session->getConnection()->oneway(ack) ; + } + else + { + dispatcher->redeliver(message) ; + + // Re-dispatch the message at some point in the future + if( listener != NULL ) + session->dispatch( redeliveryTimeout ) ; + } +} Propchange: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageConsumer.cpp ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageConsumerSynchronization.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageConsumerSynchronization.cpp?rev=419422&r1=419421&r2=419422&view=diff ============================================================================== --- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageConsumerSynchronization.cpp (original) +++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageConsumerSynchronization.cpp Wed Jul 5 20:17:58 2006 @@ -1,60 +1,60 @@ -/* - * Copyright 2006 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "activemq/MessageConsumerSynchronization.hpp" -#include "activemq/MessageConsumer.hpp" - -using namespace apache::activemq; - -/* - * - */ -MessageConsumerSynchronization::MessageConsumerSynchronization(p consumer, p message) -{ - this->consumer = consumer ; - this->message = message ; -} - -/* - * - */ -MessageConsumerSynchronization::~MessageConsumerSynchronization() -{ -} - -/* - * - */ -void MessageConsumerSynchronization::beforeCommit() -{ - // no-op -} - -/* - * - */ -void MessageConsumerSynchronization::afterCommit() -{ - // no-op -} - -/* - * - */ -void MessageConsumerSynchronization::afterRollback() -{ - consumer->afterRollback( p_cast (message)) ; -} +/* + * Copyright 2006 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "activemq/MessageConsumerSynchronization.hpp" +#include "activemq/MessageConsumer.hpp" + +using namespace apache::activemq; + +/* + * + */ +MessageConsumerSynchronization::MessageConsumerSynchronization(p consumer, p message) +{ + this->consumer = consumer ; + this->message = message ; +} + +/* + * + */ +MessageConsumerSynchronization::~MessageConsumerSynchronization() +{ +} + +/* + * + */ +void MessageConsumerSynchronization::beforeCommit() +{ + // no-op +} + +/* + * + */ +void MessageConsumerSynchronization::afterCommit() +{ + // no-op +} + +/* + * + */ +void MessageConsumerSynchronization::afterRollback() +{ + consumer->afterRollback( p_cast (message)) ; +} Propchange: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageConsumerSynchronization.cpp ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageProducer.cpp URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageProducer.cpp?rev=419422&r1=419421&r2=419422&view=diff ============================================================================== --- incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageProducer.cpp (original) +++ incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageProducer.cpp Wed Jul 5 20:17:58 2006 @@ -1,179 +1,179 @@ -/* - * Copyright 2006 The Apache Software Foundation or its licensors, as - * applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "activemq/MessageProducer.hpp" -#include "activemq/Session.hpp" - -using namespace apache::activemq; - - -// Constructors ----------------------------------------------------- - -/* - * - */ -MessageProducer::MessageProducer(p session, p producerInfo) -{ - this->session = session ; - this->producerInfo = producerInfo ; - this->priority = DEFAULT_PRIORITY ; - this->timeToLive = DEFAULT_TIMETOLIVE ; - this->messageCounter = 0 ; - this->persistent = false ; - this->disableMessageID = false ; - this->disableMessageTimestamp = false ; - this->closed = false ; -} - -/* - * - */ -MessageProducer::~MessageProducer() -{ - // Make sure the producer is closed - close() ; -} - - -// Attribute methods ------------------------------------------------ - -bool MessageProducer::getPersistent() -{ - return persistent ; -} - -void MessageProducer::setPersistent(bool persistent) -{ - this->persistent = persistent ; -} - -long long MessageProducer::getTimeToLive() -{ - return timeToLive ; -} - -void MessageProducer::getTimeToLive(long long ttl) -{ - this->timeToLive = ttl ; -} - -int MessageProducer::getPriority() -{ - return priority ; -} - -void MessageProducer::getPriority(int priority) -{ - this->priority = priority ; -} - -bool MessageProducer::getDisableMessageID() -{ - return disableMessageID ; -} - -void MessageProducer::getDisableMessageID(bool disable) -{ - this->disableMessageID = disable ; -} - -bool MessageProducer::getDisableMessageTimestamp() -{ - return disableMessageTimestamp ; -} - -void MessageProducer::getDisableMessageTimestamp(bool disable) -{ - this->disableMessageTimestamp = disable ; -} - - -// Operation methods ------------------------------------------------ - -/* - * - */ -void MessageProducer::send(p message) -{ - send(producerInfo->getDestination(), message, DEFAULT_PRIORITY, DEFAULT_TIMETOLIVE) ; -} - -/* - * - */ -void MessageProducer::send(p destination, p message) -{ - send(destination, message, DEFAULT_PRIORITY, DEFAULT_TIMETOLIVE) ; -} - -/* - * - */ -void MessageProducer::send(p destination, p message, char priority, long long timeToLive) -{ - p msgId = new MessageId() ; - msgId->setProducerId( producerInfo->getProducerId() ) ; - - // Acquire next sequence id - { - LOCKED_SCOPE (mutex); - msgId->setProducerSequenceId( ++messageCounter ) ; - } - - // Configure the message - p activeMessage = p_dyncast (message) ; - activeMessage->setMessageId( msgId ) ; - activeMessage->setProducerId( producerInfo->getProducerId() ) ; - activeMessage->setDestination( p_dyncast (destination) ) ; - activeMessage->setPriority(priority) ; - - if( session->isTransacted() ) - { - session->doStartTransaction() ; - activeMessage->setTransactionId( session->getTransactionContext()->getTransactionId() ) ; - } - - // Set time values if not disabled - if( !this->disableMessageTimestamp ) - { - long long timestamp = Time::getCurrentTimeMillis() ; - - // Set message time stamp/expiration - activeMessage->setTimestamp(timestamp) ; - if( timeToLive > 0 ) - activeMessage->setExpiration( timestamp + timeToLive ) ; - } - - // Finally, transmit the message - session->doSend(destination, message) ; -} - -/* - * - */ -void MessageProducer::close() -{ - if( !closed ) - { - closed = true ; - - // De-register producer from broker - session->getConnection()->disposeOf( producerInfo->getProducerId() ) ; - - // Reset internal state (prevent cyclic references) - session = NULL ; - } -} +/* + * Copyright 2006 The Apache Software Foundation or its licensors, as + * applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "activemq/MessageProducer.hpp" +#include "activemq/Session.hpp" + +using namespace apache::activemq; + + +// Constructors ----------------------------------------------------- + +/* + * + */ +MessageProducer::MessageProducer(p session, p producerInfo) +{ + this->session = session ; + this->producerInfo = producerInfo ; + this->priority = DEFAULT_PRIORITY ; + this->timeToLive = DEFAULT_TIMETOLIVE ; + this->messageCounter = 0 ; + this->persistent = false ; + this->disableMessageID = false ; + this->disableMessageTimestamp = false ; + this->closed = false ; +} + +/* + * + */ +MessageProducer::~MessageProducer() +{ + // Make sure the producer is closed + close() ; +} + + +// Attribute methods ------------------------------------------------ + +bool MessageProducer::getPersistent() +{ + return persistent ; +} + +void MessageProducer::setPersistent(bool persistent) +{ + this->persistent = persistent ; +} + +long long MessageProducer::getTimeToLive() +{ + return timeToLive ; +} + +void MessageProducer::getTimeToLive(long long ttl) +{ + this->timeToLive = ttl ; +} + +int MessageProducer::getPriority() +{ + return priority ; +} + +void MessageProducer::getPriority(int priority) +{ + this->priority = priority ; +} + +bool MessageProducer::getDisableMessageID() +{ + return disableMessageID ; +} + +void MessageProducer::getDisableMessageID(bool disable) +{ + this->disableMessageID = disable ; +} + +bool MessageProducer::getDisableMessageTimestamp() +{ + return disableMessageTimestamp ; +} + +void MessageProducer::getDisableMessageTimestamp(bool disable) +{ + this->disableMessageTimestamp = disable ; +} + + +// Operation methods ------------------------------------------------ + +/* + * + */ +void MessageProducer::send(p message) +{ + send(producerInfo->getDestination(), message, DEFAULT_PRIORITY, DEFAULT_TIMETOLIVE) ; +} + +/* + * + */ +void MessageProducer::send(p destination, p message) +{ + send(destination, message, DEFAULT_PRIORITY, DEFAULT_TIMETOLIVE) ; +} + +/* + * + */ +void MessageProducer::send(p destination, p message, char priority, long long timeToLive) +{ + p msgId = new MessageId() ; + msgId->setProducerId( producerInfo->getProducerId() ) ; + + // Acquire next sequence id + { + LOCKED_SCOPE (mutex); + msgId->setProducerSequenceId( ++messageCounter ) ; + } + + // Configure the message + p activeMessage = p_dyncast (message) ; + activeMessage->setMessageId( msgId ) ; + activeMessage->setProducerId( producerInfo->getProducerId() ) ; + activeMessage->setDestination( p_dyncast (destination) ) ; + activeMessage->setPriority(priority) ; + + if( session->isTransacted() ) + { + session->doStartTransaction() ; + activeMessage->setTransactionId( session->getTransactionContext()->getTransactionId() ) ; + } + + // Set time values if not disabled + if( !this->disableMessageTimestamp ) + { + long long timestamp = Time::getCurrentTimeMillis() ; + + // Set message time stamp/expiration + activeMessage->setTimestamp(timestamp) ; + if( timeToLive > 0 ) + activeMessage->setExpiration( timestamp + timeToLive ) ; + } + + // Finally, transmit the message + session->doSend(destination, message) ; +} + +/* + * + */ +void MessageProducer::close() +{ + if( !closed ) + { + closed = true ; + + // De-register producer from broker + session->getConnection()->disposeOf( producerInfo->getProducerId() ) ; + + // Reset internal state (prevent cyclic references) + session = NULL ; + } +} Propchange: incubator/activemq/trunk/openwire-cpp/src/main/cpp/activemq/MessageProducer.cpp ------------------------------------------------------------------------------ svn:eol-style = native