From commits-nelsonholly@example.com Mon May 03 19:02:37 2010 Return-Path: <commits-nelsonholly@example.com> Delivered-To: nelsonholly@example.com Received: (qmail 85260 invoked from network); 3 May 2010 19:02:37 -0000 Received: from unknown (HELO mail.apache.org) (83.161.120.155) by 83.161.120.155 with SMTP; 3 May 2010 19:02:37 -0000 Received: (qmail 95588 invoked by uid 500); 3 May 2010 19:02:37 -0000 Delivered-To: nelsonholly@example.com Received: (qmail 95528 invoked by uid 500); 3 May 2010 19:02:37 -0000 Mailing-List: contact nelsonholly@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:nelsonholly@example.com> List-Unsubscribe: <mailto:nelsonholly@example.com> List-Post: <mailto:nelsonholly@example.com> List-Id: <commits.activemq.apache.org> Reply-To: nelsonholly@example.com Delivered-To: mailing list nelsonholly@example.com Received: (qmail 95521 invoked by uid 99); 3 May 2010 19:02:36 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 May 2010 19:02:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 May 2010 19:02:33 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A596023889B6; Mon, 3 May 2010 19:01:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r940571 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main: ./ activemq/library/ activemq/transport/tcp/ Date: Mon, 03 May 2010 19:01:41 -0000 To: nelsonholly@example.com From: nelsonholly@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <nelsonholly@example.com> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Mon May 3 19:01:41 2010 New Revision: 940571 URL: http://svn.apache.org/viewvc?rev=940571&view=rev Log: https://issues.apache.org/activemq/browse/AMQCPP-140 Add an initial SSLTransport and its associated Factory instance. Register it with the library and make a few changes to TcpTransport so it can be extended with other types of streaming Socket transports. Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.cpp (with props) activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.h (with props) activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransportFactory.cpp (with props) activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransportFactory.h (with props) Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/library/ActiveMQCPP.cpp activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.h Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=940571&r1=940570&r2=940571&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Mon May 3 19:01:41 2010 @@ -128,6 +128,8 @@ cc_sources = \ activemq/transport/mock/InternalCommandListener.cpp \ activemq/transport/mock/MockTransport.cpp \ activemq/transport/mock/MockTransportFactory.cpp \ + activemq/transport/tcp/SslTransport.cpp \ + activemq/transport/tcp/SslTransportFactory.cpp \ activemq/transport/tcp/TcpTransport.cpp \ activemq/transport/tcp/TcpTransportFactory.cpp \ activemq/util/ActiveMQProperties.cpp \ @@ -757,6 +759,8 @@ h_sources = \ activemq/transport/mock/MockTransport.h \ activemq/transport/mock/MockTransportFactory.h \ activemq/transport/mock/ResponseBuilder.h \ + activemq/transport/tcp/SslTransport.h \ + activemq/transport/tcp/SslTransportFactory.h \ activemq/transport/tcp/TcpTransport.h \ activemq/transport/tcp/TcpTransportFactory.h \ activemq/util/ActiveMQProperties.h \ Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/library/ActiveMQCPP.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/library/ActiveMQCPP.cpp?rev=940571&r1=940570&r2=940571&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/library/ActiveMQCPP.cpp (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/library/ActiveMQCPP.cpp Mon May 3 19:01:41 2010 @@ -26,6 +26,7 @@ #include <activemq/transport/mock/MockTransportFactory.h> #include <activemq/transport/tcp/TcpTransportFactory.h> +#include <activemq/transport/tcp/SslTransportFactory.h> #include <activemq/transport/failover/FailoverTransportFactory.h> using namespace activemq; @@ -81,6 +82,8 @@ void ActiveMQCPP888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4registerTransports() { TransportRegistry888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4getInstance().registerFactory( "tcp", new TcpTransportFactory() ); TransportRegistry888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4getInstance().registerFactory( + "ssl", new SslTransportFactory() ); + TransportRegistry888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4getInstance().registerFactory( "mock", new MockTransportFactory() ); TransportRegistry888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4getInstance().registerFactory( "failover", new FailoverTransportFactory() ); Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.cpp?rev=940571&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.cpp (added) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.cpp Mon May 3 19:01:41 2010 @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "SslTransport.h" + +#include <decaf/lang/Integer.h> +#include <decaf/lang/Boolean.h> +#include <decaf/net/ssl/SSLSocket.h> +#include <decaf/net/ssl/SSLSocketFactory.h> +#include <decaf/lang/exceptions/NullPointerException.h> +#include <decaf/lang/exceptions/IllegalArgumentException.h> + +#include <memory> + +using namespace std; +using namespace activemq; +using namespace activemq888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4io; +using namespace activemq888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4transport; +using namespace activemq888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4transport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4tcp; +using namespace activemq888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4xceptions; +using namespace decaf; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4ssl; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4io; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4lang; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4lang888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4xceptions; + +//////////////////////////////////////////////////////////////////////////////// +SslTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4SslTransport( const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4URI& uri, + const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties, + const Pointer<Transport>& next ) : + TcpTransport( uri, properties, next ) { +} + +//////////////////////////////////////////////////////////////////////////////// +SslTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4SslTransport( const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties, + const Pointer<Transport>& next ) : + TcpTransport( properties, next ) { +} + +//////////////////////////////////////////////////////////////////////////////// +SslTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4~SslTransport() { +} + +//////////////////////////////////////////////////////////////////////////////// +Socket* SslTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4reateSocket() { + + try { + st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4auto_ptr<SocketFactory> factory( SSLSocketFactory888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4getDefault() ); + return factory->createSocket(); + } + DECAF_CATCH_RETHROW( IOException ) + DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException ) + DECAF_CATCHALL_THROW( IOException ) +} + +//////////////////////////////////////////////////////////////////////////////// +void SslTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4onfigureSocket( Socket* socket, d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties ) { + + try{ + + if( socket == NULL ) { + throw NullPointerException( + __FILE__, __LINE__, "Socket instance passed was NULL" ); + } + + SSLSocket* sslSocket = dynamic_cast<SSLSocket*>( socket ); + if( sslSocket == NULL ) { + throw IllegalArgumentException( + __FILE__, __LINE__, "Socket passed was not an SSLSocket instance." ); + } + + TcpTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4onfigureSocket( socket, properties ); + } + DECAF_CATCH_RETHROW( NullPointerException ) + DECAF_CATCH_RETHROW( IllegalArgumentException ) + DECAF_CATCH_RETHROW( SocketException ) + DECAF_CATCH_EXCEPTION_CONVERT( Exception, SocketException ) + DECAF_CATCHALL_THROW( SocketException ) +} Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.h?rev=940571&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.h (added) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.h Mon May 3 19:01:41 2010 @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +#ifndef _ACTIVEMQ_TRANSPORT_TCP_SSLTRANSPORT_H_ +#define _ACTIVEMQ_TRANSPORT_TCP_SSLTRANSPORT_H_ + +#include <activemq/util/Config.h> + +#include <activemq/transport/tcp/TcpTransport.h> + +namespace activemq { +namespace transport { +namespace tcp { + + /** + * Transport for connecting to a Broker using an SSL Socket. This transport simply + * wraps the TcpTransport and provides the TcpTransport an SSL based Socket pointer + * allowing the core TcpTransport logic to be reused. + * + * @since 3.2.0 + */ + class AMQCPP_API SslTransport : public TcpTransport { + private: + + SslTransport( const SslTransport& ); + SslTransport& operator= ( const SslTransport& ); + + public: + + /** + * Creates a new instance of the SslTransport, the Broker URI is assumed + * to be set in the property "transport.uri". + * + * @param properties the configuration properties for this transport + * @param next the next transport in the chain + */ + SslTransport( const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties, + const Pointer<Transport>& next ); + + /** + * Creates a new instance of the SslTransport, the uri instance specifies the + * host and port to connect to. + * + * @param uri - The URI containing the host to connect to. + * @param properties the configuration properties for this transport + * @param next the next transport in the chain + */ + SslTransport( const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4URI& uri, + const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties, + const Pointer<Transport>& next ); + + virtual ~SslTransport(); + + protected: + + /** + * {@inheritDoc} + */ + virtual d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Socket* createSocket(); + + /** + * {@inheritDoc} + */ + virtual void configureSocket( d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Socket* socket, d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties ); + + }; + +}}} + +#endif /* _ACTIVEMQ_TRANSPORT_TCP_SSLTRANSPORT_H_ */ Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransport.h ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransportFactory.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransportFactory.cpp?rev=940571&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransportFactory.cpp (added) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransportFactory.cpp Mon May 3 19:01:41 2010 @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "SslTransportFactory.h" + +#include <activemq/transport/tcp/SslTransport.h> + +#include <activemq/transport/IOTransport.h> +#include <activemq/transport/inactivity/InactivityMonitor.h> + +#include <memory> + +using namespace std; +using namespace activemq; +using namespace activemq888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4io; +using namespace activemq888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4transport; +using namespace activemq888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4transport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4inactivity; +using namespace activemq888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4transport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4tcp; +using namespace activemq888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4xceptions; +using namespace decaf; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4io; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4lang; + +//////////////////////////////////////////////////////////////////////////////// +SslTransportFactory888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4~SslTransportFactory() { +} + +//////////////////////////////////////////////////////////////////////////////// +Pointer<Transport> SslTransportFactory888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4oCreateComposite( const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4URI& location, + const Pointer<wireformat888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4WireFormat>& wireFormat, + const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties ) + throw ( ActiveMQException ) { + + try { + + Pointer<Transport> transport( new SslTransport( + location, properties, Pointer<Transport>( new IOTransport( wireFormat ) ) ) ); + + if( properties.getProperty( "trnasport.useInactivityMonitor", "true" ) == "true" ) { + transport.reset( new InactivityMonitor( transport, properties, wireFormat ) ); + } + + // If there is a negotiator need then we create and wrap here. + if( wireFormat->hasNegotiator() ) { + transport = wireFormat->createNegotiator( transport ); + } + + return transport; + } + AMQ_CATCH_RETHROW( ActiveMQException ) + AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException ) + AMQ_CATCHALL_THROW( ActiveMQException ) +} Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransportFactory.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransportFactory.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransportFactory.h?rev=940571&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransportFactory.h (added) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransportFactory.h Mon May 3 19:01:41 2010 @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +#ifndef _ACTIVEMQ_TRANSPORT_TCP_SSLTRANSPORTFACTORY_H_ +#define _ACTIVEMQ_TRANSPORT_TCP_SSLTRANSPORTFACTORY_H_ + +#include <activemq/util/Config.h> + +#include <activemq/transport/tcp/TcpTransportFactory.h> + +namespace activemq { +namespace transport { +namespace tcp { + + using d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4lang888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Pointer; + + class SslTransportFactory : public TcpTransportFactory { + public: + + virtual ~SslTransportFactory(); + + protected: + + /** + * Creates a slimed down Transport instance which can be used in composite + * transport instances. + * + * @param location - URI location to connect to. + * @param wireFormat - the assigned WireFormat for the new Transport. + * @param properties - Properties to apply to the transport. + * + * @return new Pointer to a SslTransport. + * @throws ActiveMQexception if an error occurs + */ + virtual Pointer<Transport> doCreateComposite( const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4URI& location, + const Pointer<wireformat888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4WireFormat>& wireFormat, + const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties ) + throw ( exceptions888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4tiveMQException ); + + }; + +}}} + +#endif /* _ACTIVEMQ_TRANSPORT_TCP_SSLTRANSPORTFACTORY_H_ */ Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/SslTransportFactory.h ------------------------------------------------------------------------------ svn:eol-style = native Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp?rev=940571&r1=940570&r2=940571&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.cpp Mon May 3 19:01:41 2010 @@ -17,13 +17,14 @@ #include "TcpTransport.h" -#include <decaf/lang/Integer.h> -#include <decaf/net/SocketFactory.h> #include <activemq/transport/IOTransport.h> #include <activemq/transport/TransportFactory.h> +#include <decaf/lang/exceptions/NullPointerException.h> +#include <decaf/lang/exceptions/IllegalArgumentException.h> #include <decaf/lang/Integer.h> #include <decaf/lang/Boolean.h> +#include <decaf/net/SocketFactory.h> #include <memory> @@ -38,12 +39,13 @@ using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net; using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util; using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4io; using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4lang; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4lang888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4xceptions; //////////////////////////////////////////////////////////////////////////////// TcpTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4TcpTransport( const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4URI& uri, const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties, const Pointer<Transport>& next ) -: TransportFilter( next ) { +: TransportFilter( next ), connectTimeout( 0 ), closed( false ) { this->initialize( uri, properties ); } @@ -51,7 +53,7 @@ TcpTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4TcpTransport( const decaf: //////////////////////////////////////////////////////////////////////////////// TcpTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4TcpTransport( const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties, const Pointer<Transport>& next ) -: TransportFilter( next ) { +: TransportFilter( next ), connectTimeout( 0 ), closed( false ) { if( !properties.hasProperty( "transport.uri" ) ) { throw ActiveMQException( @@ -100,11 +102,22 @@ void TcpTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4initialize( const dec try { - st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4auto_ptr<SocketFactory> factory( SocketFactory888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4getDefault() ); + socket.reset( this->createSocket() ); - socket.reset( factory->createSocket() ); + // Set all Socket Options from the URI options. + this->configureSocket( socket.get(), properties ); + + // Ensure something is actually passed in for the URI + if( uri.getAuthority() == "" ) { + throw SocketException( __FILE__, __LINE__, + "Connection URI was not provided or is invalid: %s", uri.toString().c_str() ); + } + + // Connect the socket. + string host = uri.getHost(); + int port = uri.getPort(); - this->configureSocket( *socket, uri, properties ); + socket->connect( host, port, connectTimeout ); // Cast it to an IO transport so we can wire up the socket // input and output streams. @@ -161,18 +174,21 @@ void TcpTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4initialize( const dec } //////////////////////////////////////////////////////////////////////////////// -void TcpTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4onfigureSocket( Socket& socket, const URI& uri, const Properties& properties ) { +Socket* TcpTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4reateSocket() { try { + st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4auto_ptr<SocketFactory> factory( SocketFactory888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4getDefault() ); + return factory->createSocket(); + } + DECAF_CATCH_RETHROW( IOException ) + DECAF_CATCH_EXCEPTION_CONVERT( Exception, IOException ) + DECAF_CATCHALL_THROW( IOException ) +} - // Ensure something is actually passed in for the URI - if( uri.getAuthority() == "" ) { - throw SocketException( __FILE__, __LINE__, - "SocketTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4start() - uri not provided" ); - } +//////////////////////////////////////////////////////////////////////////////// +void TcpTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4onfigureSocket( Socket* socket, const Properties& properties ) { - string host = uri.getHost(); - int port = uri.getPort(); + try { // Get the linger flag. int soLinger = Integer888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4parseInt( @@ -195,27 +211,27 @@ void TcpTransport888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4onfigureSocket( Sock properties.getProperty( "tcpNoDelay", "true" ) ); // Get the socket connect timeout in microseconds. (default to infinite wait). - int connectTimeout = Integer888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4parseInt( properties.getProperty( "soConnectTimeout", "0" ) ); - - // Connect the socket. - socket.connect( host, port, connectTimeout ); + this->connectTimeout = Integer888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4parseInt( + properties.getProperty( "soConnectTimeout", "0" ) ); // Set the socket options. - socket.setKeepAlive( soKeepAlive ); - socket.setTcpNoDelay( tcpNoDelay ); + socket->setKeepAlive( soKeepAlive ); + socket->setTcpNoDelay( tcpNoDelay ); if( soLinger > 0 ) { - socket.setSoLinger( true, soLinger ); + socket->setSoLinger( true, soLinger ); } if( soReceiveBufferSize > 0 ){ - socket.setReceiveBufferSize( soReceiveBufferSize ); + socket->setReceiveBufferSize( soReceiveBufferSize ); } if( soSendBufferSize > 0 ){ - socket.setSendBufferSize( soSendBufferSize ); + socket->setSendBufferSize( soSendBufferSize ); } } + DECAF_CATCH_RETHROW( NullPointerException ) + DECAF_CATCH_RETHROW( IllegalArgumentException ) DECAF_CATCH_RETHROW( SocketException ) DECAF_CATCH_EXCEPTION_CONVERT( Exception, SocketException ) DECAF_CATCHALL_THROW( SocketException ) Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.h?rev=940571&r1=940570&r2=940571&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.h (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/activemq/transport/tcp/TcpTransport.h Mon May 3 19:01:41 2010 @@ -48,6 +48,11 @@ namespace tcp{ private: /** + * Stores the URI configured Socket connect timeout. + */ + int connectTimeout; + + /** * has close been called. */ bool closed; @@ -75,7 +80,9 @@ namespace tcp{ public: /** - * Constructor + * Creates a new instance of the TcpTransport, the Broker URI is assumed + * to be set in the property "transport.uri". + * * @param properties the configuration properties for this transport * @param next the next transport in the chain */ @@ -83,7 +90,9 @@ namespace tcp{ const Pointer<Transport>& next ); /** - * Constructor + * Creates a new instance of the TcpTransport, the uri instance specifies the + * host and port to connect to. + * * @param uri - The URI containing the host to connect to. * @param properties the configuration properties for this transport * @param next the next transport in the chain @@ -132,14 +141,39 @@ namespace tcp{ return this->closed; } + protected: + + /** + * Create an unconnected Socket instance to be used by the transport to communicate + * with the broker. + * + * @return a newly created unconnected Socket instance. + * + * @throw IOException if there is an error while creating the unconnected Socket. + */ + virtual d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Socket* createSocket(); + + /** + * Using options from configuration URI, configure the socket options before the + * Socket instance is connected to the Server. Subclasses can override this option + * to set more configuration options, they should called the base class version to + * allow the default set of Socket options to also be configured. + * + * @param socket + * The Socket instance to configure using options from the given Properties. + * + * @throw NullPointerException if the Socket instance is null. + * @throw IllegalArgumentException if the socket instance is not handled by the class. + * @throw SocketException if there is an error while setting one of the Socket options. + */ + virtual void configureSocket( d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Socket* socket, + const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties ); + private: void initialize( const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4URI& uri, const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties ); - void configureSocket( d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Socket& socket, - const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4URI& uri, - const d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4util888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4Properties& properties ); }; From commits-nelsonholly@example.com Mon May 03 21:29:46 2010 Return-Path: <commits-nelsonholly@example.com> Delivered-To: nelsonholly@example.com Received: (qmail 13459 invoked from network); 3 May 2010 21:29:46 -0000 Received: from unknown (HELO mail.apache.org) (83.161.120.155) by 83.161.120.155 with SMTP; 3 May 2010 21:29:46 -0000 Received: (qmail 47725 invoked by uid 500); 3 May 2010 21:29:46 -0000 Delivered-To: nelsonholly@example.com Received: (qmail 47662 invoked by uid 500); 3 May 2010 21:29:46 -0000 Mailing-List: contact nelsonholly@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:nelsonholly@example.com> List-Unsubscribe: <mailto:nelsonholly@example.com> List-Post: <mailto:nelsonholly@example.com> List-Id: <commits.activemq.apache.org> Reply-To: nelsonholly@example.com Delivered-To: mailing list nelsonholly@example.com Received: (qmail 47655 invoked by uid 99); 3 May 2010 21:29:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 May 2010 21:29:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 May 2010 21:29:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B67BE23888FE; Mon, 3 May 2010 21:28:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r940628 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/main: Makefile.am decaf/net/ssl/SSLParameters.cpp decaf/net/ssl/SSLParameters.h Date: Mon, 03 May 2010 21:28:51 -0000 To: nelsonholly@example.com From: nelsonholly@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <nelsonholly@example.com> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Mon May 3 21:28:51 2010 New Revision: 940628 URL: http://svn.apache.org/viewvc?rev=940628&view=rev Log: https://issues.apache.org/activemq/browse/AMQCPP-140 Add SSLParameters class for holding the Context configuration. Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLParameters.cpp (with props) activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLParameters.h (with props) Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am?rev=940628&r1=940627&r2=940628&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/Makefile.am Mon May 3 21:28:51 2010 @@ -564,6 +564,7 @@ cc_sources = \ decaf/net/URLDecoder.cpp \ decaf/net/URLEncoder.cpp \ decaf/net/ssl/SSLContent.cpp \ + decaf/net/ssl/SSLParameters.cpp \ decaf/net/ssl/SSLSocket.cpp \ decaf/net/ssl/SSLSocketFactory.cpp \ decaf/nio/Buffer.cpp \ @@ -1282,6 +1283,7 @@ h_sources = \ decaf/net/UnknownHostException.h \ decaf/net/UnknownServiceException.h \ decaf/net/ssl/SSLContent.h \ + decaf/net/ssl/SSLParameters.h \ decaf/net/ssl/SSLSocket.h \ decaf/net/ssl/SSLSocketFactory.h \ decaf/nio/Buffer.h \ Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLParameters.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLParameters.cpp?rev=940628&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLParameters.cpp (added) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLParameters.cpp Mon May 3 21:28:51 2010 @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 "SSLParameters.h" + +using namespace decaf; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net; +using namespace d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4net888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4ssl; + +//////////////////////////////////////////////////////////////////////////////// +SSLParameters888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4SSLParameters() : cipherSuites(), protocols(), needClientAuth( false ), wantClientAuth( false ) { +} + +//////////////////////////////////////////////////////////////////////////////// +SSLParameters888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4SSLParameters( const st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4vector<st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4string>& cipherSuites ) : + cipherSuites( cipherSuites ), protocols(), needClientAuth( false ), wantClientAuth( false ) { +} + +//////////////////////////////////////////////////////////////////////////////// +SSLParameters888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4SSLParameters( const st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4vector<st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4string>& cipherSuites, + const st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4vector<st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4string>& protocols ) : + cipherSuites( cipherSuites ), protocols( protocols ), needClientAuth( false ), wantClientAuth( false ) { +} + +//////////////////////////////////////////////////////////////////////////////// +SSLParameters888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4~SSLParameters() { +} Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLParameters.cpp ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLParameters.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLParameters.h?rev=940628&view=auto ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLParameters.h (added) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLParameters.h Mon May 3 21:28:51 2010 @@ -0,0 +1,144 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +#ifndef _DECAF_NET_SSL_SSLPARAMETERS_H_ +#define _DECAF_NET_SSL_SSLPARAMETERS_H_ + +#include <decaf/util/Config.h> + +#include <string> +#include <vector> + +namespace decaf { +namespace net { +namespace ssl { + + class DECAF_API SSLParameters { + private: + + st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4vector<st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4string> cipherSuites; + st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4vector<st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4string> protocols; + bool needClientAuth; + bool wantClientAuth; + + public: + + /** + * Creates a new SSLParameters instance with empty vectors for the protocols and the + * cipherSuites, the wantClientAuth and needClientAuth flags are set to false. + */ + SSLParameters(); + + /** + * Creates a new SSLParameters instance with the given cipherSuites value, the protocols + * vector is empty and the wantClientAuth and needClientAuth flags are set to false. + * + * @param cipherSuites + * The vector of cipherSuites for this SSLParameters instance (can be empty). + */ + SSLParameters( const st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4vector<st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4string>& cipherSuites ); + + /** + * Creates a new SSLParameters instance with the given cipherSuites value and protocols + * value, the wantClientAuth and needClientAuth flags are set to false. + * + * @param cipherSuites + * The vector of cipherSuites for this SSLParameters instance (can be empty). + * @param protocols + * The vector of protocols for this SSLParameters instance (can be empty). + */ + SSLParameters( const st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4vector<st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4string>& cipherSuites, + const st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4vector<st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4string>& protocols ); + + virtual ~SSLParameters(); + + /** + * @returns a copy of the vector of ciphersuites or an empty vector if none have been set. + */ + st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4vector<st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4string> getCipherSuites() const { + return this->cipherSuites; + } + + /** + * Sets the vector of ciphersuites. + * + * @param cipherSuites + * The vector of cipherSuites (can be an empty vector). + */ + void setCipherSuites( const st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4vector<st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4string>& cipherSuites ) { + this->cipherSuites = cipherSuites; + } + + /** + * @returns a copy of the vector of protocols or an empty vector if none have been set. + */ + st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4vector<st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4string> getProtocols() const { + return this->protocols; + } + + /** + * Sets the vector of protocols. + * + * @param protocols + * the vector of protocols (or an empty vector) + */ + void setProtocols( const st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4vector<st888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4string>& protocols ) { + this->protocols = protocols; + } + + /** + * @returns whether client authentication should be requested. + */ + bool getWantClientAuth() const { + return this->wantClientAuth; + } + + /** + * Sets whether client authentication should be requested. Calling this method clears the + * needClientAuth flag. + * + * @param whether client authentication should be requested. + */ + void setWantClientAuth( bool wantClientAuth ) { + this->wantClientAuth = wantClientAuth; + this->needClientAuth = false; + } + + /** + * @returns whether client authentication should be required. + */ + bool getNeedClientAuth() const { + return this->needClientAuth; + } + + /** + * Sets whether client authentication should be required. Calling this method clears the + * wantClientAuth flag. + * + * @param needClientAuth + * whether client authentication should be required. + */ + void setNeedClientAuth( bool needClientAuth ) { + this->needClientAuth = needClientAuth; + this->wantClientAuth = false; + } + + }; + +}}} + +#endif /* _DECAF_NET_SSL_SSLPARAMETERS_H_ */ Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/net/ssl/SSLParameters.h ------------------------------------------------------------------------------ svn:eol-style = native From commits-nelsonholly@example.com Tue May 04 15:53:23 2010 Return-Path: <commits-nelsonholly@example.com> Delivered-To: nelsonholly@example.com Received: (qmail 51646 invoked from network); 4 May 2010 15:53:23 -0000 Received: from unknown (HELO mail.apache.org) (83.161.120.155) by 83.161.120.155 with SMTP; 4 May 2010 15:53:23 -0000 Received: (qmail 2467 invoked by uid 500); 4 May 2010 15:53:23 -0000 Delivered-To: nelsonholly@example.com Received: (qmail 2422 invoked by uid 500); 4 May 2010 15:53:23 -0000 Mailing-List: contact nelsonholly@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:nelsonholly@example.com> List-Unsubscribe: <mailto:nelsonholly@example.com> List-Post: <mailto:nelsonholly@example.com> List-Id: <commits.activemq.apache.org> Reply-To: nelsonholly@example.com Delivered-To: mailing list nelsonholly@example.com Received: (qmail 2415 invoked by uid 99); 4 May 2010 15:53:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 May 2010 15:53:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 May 2010 15:53:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 837ED23888DD; Tue, 4 May 2010 15:52:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r940919 - in /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk: ./ src/main/csharp/Commands/ src/main/csharp/Protocol/ src/test/csharp/ src/test/csharp/Commands/ Date: Tue, 04 May 2010 15:52:23 -0000 To: nelsonholly@example.com From: nelsonholly@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <nelsonholly@example.com> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Tue May 4 15:52:22 2010 New Revision: 940919 URL: http://svn.apache.org/viewvc?rev=940919&view=rev Log: https://issues.apache.org/activemq/browse/AMQNET-248 Fix issue with MessageID not getting converted to a String correctly. Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ConsumerIdTest.cs (with props) activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ProducerIdTest.cs (with props) Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseDataStructure.cs activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerId.cs activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompHelper.cs activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/MessageTest.cs activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/StompHelperTest.cs activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseDataStructure.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseDataStructure.cs?rev=940919&r1=940918&r2=940919&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseDataStructure.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/BaseDataStructure.cs Tue May 4 15:52:22 2010 @@ -16,6 +16,7 @@ */ using System; +using System.Text; using Apache.NMS.Stomp.Protocol; namespace Apache.NMS.Stomp.Commands @@ -82,5 +83,6 @@ namespace Apache.NMS.Stomp.Commands // if we had any. return this.MemberwiseClone(); } + } } Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerId.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerId.cs?rev=940919&r1=940918&r2=940919&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerId.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ConsumerId.cs Tue May 4 15:52:22 2010 @@ -24,6 +24,8 @@ namespace Apache.NMS.Stomp.Commands { public const byte ID_CONSUMERID = 122; + private string key; + private SessionId parentId = null; string connectionId; @@ -34,6 +36,43 @@ namespace Apache.NMS.Stomp.Commands { } + public ConsumerId( string consumerKey ) + { + this.key = consumerKey; + + // We give the Connection ID the key for now so there's at least some + // data stored into the Id. + this.ConnectionId = consumerKey; + + int idx = consumerKey.LastIndexOf(':'); + if( idx >= 0 ) + { + try + { + this.Value = Int32.Parse(consumerKey.Substring(idx + 1)); + consumerKey = consumerKey.Substring(0, idx); + idx = consumerKey.LastIndexOf(':'); + if (idx >= 0) + { + try + { + this.SessionId = Int32.Parse(consumerKey.Substring(idx + 1)); + consumerKey = consumerKey.Substring(0, idx); + } + catch(Exception ex) + { + Tracer.Debug(ex.Message); + } + } + this.ConnectionId = consumerKey; + } + catch(Exception ex) + { + Tracer.Debug(ex.Message); + } + } + } + public ConsumerId( SessionId sessionId, long consumerId ) { this.connectionId = sessionId.ConnectionId; @@ -60,7 +99,12 @@ namespace Apache.NMS.Stomp.Commands /// public override string ToString() { - return ConnectionId + ":" + SessionId + ":" + Value; + if( key == null ) + { + this.key = ConnectionId + ":" + SessionId + ":" + Value; + } + + return key; } public SessionId ParentId @@ -114,6 +158,11 @@ namespace Apache.NMS.Stomp.Commands public virtual bool Equals(ConsumerId that) { + if(this.key != null && that.key != null) + { + return this.key.Equals(that.key); + } + if(!Equals(this.ConnectionId, that.ConnectionId)) { return false; Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs?rev=940919&r1=940918&r2=940919&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/Message.cs Tue May 4 15:52:22 2010 @@ -208,9 +208,7 @@ namespace Apache.NMS.Stomp.Commands { if(null != MessageId) { - return MessageId.ProducerId.ConnectionId + ":" + - MessageId.ProducerId.SessionId + ":" + - MessageId.ProducerId.Value; + return MessageId.ToString(); } return String.Empty; Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs?rev=940919&r1=940918&r2=940919&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/MessageId.cs Tue May 4 15:52:22 2010 @@ -62,7 +62,7 @@ namespace Apache.NMS.Stomp.Commands /// public override string ToString() { - if(key == null) + if( key == null ) { key = producerId.ToString() + ":" + producerSequenceId; } Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs?rev=940919&r1=940918&r2=940919&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Commands/ProducerId.cs Tue May 4 15:52:22 2010 @@ -24,6 +24,8 @@ namespace Apache.NMS.Stomp.Commands { private SessionId parentId; + private string key = null; + string connectionId; long value; long sessionId; @@ -41,13 +43,30 @@ namespace Apache.NMS.Stomp.Commands public ProducerId(string producerKey) { - // Parse off the producerId - int p = producerKey.LastIndexOf(":"); - if(p >= 0) - { - value = Int64.Parse(producerKey.Substring(p + 1)); - producerKey = producerKey.Substring(0, p); + // Store the original. + this.key = producerKey; + + // Try and get back the AMQ version of the data. + int idx = producerKey.LastIndexOf(':'); + if(idx >= 0) + { + try + { + this.Value = Int32.Parse(producerKey.Substring(idx + 1)); + producerKey = producerKey.Substring(0, idx); + idx = producerKey.LastIndexOf(':'); + if(idx >= 0) + { + this.SessionId = Int32.Parse(producerKey.Substring(idx + 1)); + producerKey = producerKey.Substring(0, idx); + } + } + catch(Exception ex) + { + Tracer.Debug(ex.Message); + } } + this.ConnectionId = producerKey; } /// @@ -69,7 +88,12 @@ namespace Apache.NMS.Stomp.Commands /// public override string ToString() { - return ConnectionId + ":" + SessionId + ":" + Value; + if( this.key == null ) + { + this.key = ConnectionId + ":" + SessionId + ":" + Value; + } + + return this.key; } public SessionId ParentId Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompHelper.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompHelper.cs?rev=940919&r1=940918&r2=940919&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompHelper.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompHelper.cs Tue May 4 15:52:22 2010 @@ -26,30 +26,6 @@ namespace Apache.NMS.Stomp.Protocol /// </summary> public class StompHelper { - private static int ParseInt(string text) - { - StringBuilder sbtext = new StringBuilder(); - - for(int idx = 0; idx < text.Length; idx++) - { - if(char.IsNumber(text, idx) || text[idx] == '-') - { - sbtext.Append(text[idx]); - } - else - { - break; - } - } - - if(sbtext.Length > 0) - { - return Int32.Parse(sbtext.ToString()); - } - - return 0; - } - public static Destination ToDestination(string text) { if(text == null) @@ -134,135 +110,6 @@ namespace Apache.NMS.Stomp.Protocol return "client"; } } - - public static string ToStomp(ConsumerId id) - { - return id.ConnectionId + ":" + id.SessionId + ":" + id.Value; - } - - public static ConsumerId ToConsumerId(string text) - { - if(text == null) - { - return null; - } - - ConsumerId answer = new ConsumerId(); - int idx = text.LastIndexOf(':'); - if (idx >= 0) - { - try - { - answer.Value = ParseInt(text.Substring(idx + 1)); - text = text.Substring(0, idx); - idx = text.LastIndexOf(':'); - if (idx >= 0) - { - try - { - answer.SessionId = ParseInt(text.Substring(idx + 1)); - text = text.Substring(0, idx); - } - catch(Exception ex) - { - Tracer.Debug(ex.Message); - } - } - } - catch(Exception ex) - { - Tracer.Debug(ex.Message); - } - } - answer.ConnectionId = text; - return answer; - } - - public static string ToStomp(ProducerId id) - { - StringBuilder producerBuilder = new StringBuilder(); - - producerBuilder.Append(id.ConnectionId); - producerBuilder.Append(":"); - producerBuilder.Append(id.SessionId); - producerBuilder.Append(":"); - producerBuilder.Append(id.Value); - - return producerBuilder.ToString(); - } - - public static ProducerId ToProducerId(string text) - { - if(text == null) - { - return null; - } - - ProducerId answer = new ProducerId(); - int idx = text.LastIndexOf(':'); - if(idx >= 0) - { - try - { - answer.Value = ParseInt(text.Substring(idx + 1)); - text = text.Substring(0, idx); - idx = text.LastIndexOf(':'); - if(idx >= 0) - { - answer.SessionId = ParseInt(text.Substring(idx + 1)); - text = text.Substring(0, idx); - } - } - catch(Exception ex) - { - Tracer.Debug(ex.Message); - } - } - answer.ConnectionId = text; - return answer; - } - - public static string ToStomp(MessageId id) - { - StringBuilder messageBuilder = new StringBuilder(); - - messageBuilder.Append(ToStomp(id.ProducerId)); - messageBuilder.Append(":"); - messageBuilder.Append(id.ProducerSequenceId); - - return messageBuilder.ToString(); - } - - public static MessageId ToMessageId(string text) - { - if(text == null) - { - return null; - } - - MessageId answer = new MessageId(); - int idx = text.LastIndexOf(':'); - if (idx >= 0) - { - try - { - answer.ProducerSequenceId = ParseInt(text.Substring(idx + 1)); - text = text.Substring(0, idx); - } - catch(Exception ex) - { - Tracer.Debug(ex.Message); - } - } - answer.ProducerId = ToProducerId(text); - - return answer; - } - - public static string ToStomp(TransactionId id) - { - return id.ConnectionId.Value + ":" + id.Value; - } public static bool ToBool(string text, bool defaultValue) { Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs?rev=940919&r1=940918&r2=940919&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs Tue May 4 15:52:22 2010 @@ -216,12 +216,12 @@ namespace Apache.NMS.Stomp.Protocol message.Type = frame.RemoveProperty("type"); message.Destination = StompHelper.ToDestination(frame.RemoveProperty("destination")); message.ReplyTo = StompHelper.ToDestination(frame.RemoveProperty("reply-to")); - message.TargetConsumerId = StompHelper.ToConsumerId(frame.RemoveProperty("subscription")); + message.TargetConsumerId = new ConsumerId(frame.RemoveProperty("subscription")); message.CorrelationId = frame.RemoveProperty("correlation-id"); Tracer.Debug("RECV - Inbound MessageId = " + frame.GetProperty("message-id")); - message.MessageId = StompHelper.ToMessageId(frame.RemoveProperty("message-id")); + message.MessageId = new MessageId(frame.RemoveProperty("message-id")); message.Persistent = StompHelper.ToBool(frame.RemoveProperty("persistent"), false); // If it came from NMS.Stomp we added this header to ensure its reported on the @@ -320,7 +320,7 @@ namespace Apache.NMS.Stomp.Protocol } if(command.TransactionId!=null) { - frame.SetProperty("transaction", StompHelper.ToStomp(command.TransactionId)); + frame.SetProperty("transaction", command.TransactionId.ToString()); } frame.SetProperty("persistent", command.Persistent.ToString().ToLower()); @@ -372,13 +372,13 @@ namespace Apache.NMS.Stomp.Protocol frame.SetProperty("receipt", "ignore:" + command.CommandId); } - frame.SetProperty("message-id", StompHelper.ToStomp(command.LastMessageId)); + frame.SetProperty("message-id", command.LastMessageId.ToString()); Tracer.Debug("ACK - Outbound MessageId = " + frame.GetProperty("message-id")); if(command.TransactionId != null) { - frame.SetProperty("transaction", StompHelper.ToStomp(command.TransactionId)); + frame.SetProperty("transaction", command.TransactionId.ToString()); } frame.ToStream(dataOut); @@ -415,7 +415,7 @@ namespace Apache.NMS.Stomp.Protocol } frame.SetProperty("destination", StompHelper.ToStomp(command.Destination)); - frame.SetProperty("id", StompHelper.ToStomp(command.ConsumerId)); + frame.SetProperty("id", command.ConsumerId.ToString()); frame.SetProperty("durable-subscriber-name", command.SubscriptionName); frame.SetProperty("selector", command.Selector); frame.SetProperty("ack", StompHelper.ToStomp(command.AckMode)); @@ -477,7 +477,7 @@ namespace Apache.NMS.Stomp.Protocol { frame.SetProperty("receipt", command.CommandId); } - frame.SetProperty("id", StompHelper.ToStomp(consumerId)); + frame.SetProperty("id", consumerId.ToString() ); frame.ToStream(dataOut); } } @@ -507,7 +507,7 @@ namespace Apache.NMS.Stomp.Protocol frame.SetProperty("receipt", command.CommandId); } - frame.SetProperty("transaction", StompHelper.ToStomp(command.TransactionId)); + frame.SetProperty("transaction", command.TransactionId.ToString()); frame.ToStream(dataOut); } Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ConsumerIdTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ConsumerIdTest.cs?rev=940919&view=auto ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ConsumerIdTest.cs (added) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ConsumerIdTest.cs Tue May 4 15:52:22 2010 @@ -0,0 +1,67 @@ +// /* +// * Licensed to the Apache Software Foundation (ASF) under one or more +// * contributor license agreements. See the NOTICE file distributed with +// * this work for additional information regarding copyright ownership. +// * The ASF licenses this file to You 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. +// */ +// + +using System; +using NUnit.Framework; +using Apache.NMS.Stomp.Commands; + +namespace Apache.NMS.Stomp.Test.Commands +{ + [TestFixture()] + public class ConsumerIdTest + { + [Test()] + public void TestAmqTypeProcessing() + { + ConsumerId id = new ConsumerId(); + id.ConnectionId = "cheese"; + id.SessionId = 2; + id.Value = 3; + + string text = id.ToString(); + Assert.AreEqual("cheese:2:3", text, "ConsumerId as stomp"); + + ConsumerId another = new ConsumerId("abc:5:6"); + Assert.AreEqual("abc", another.ConnectionId, "extracting consumerId.ConnectionId"); + Assert.AreEqual(5, another.SessionId, "extracting consumerId.SessionId"); + Assert.AreEqual(6, another.Value, "extracting consumerId.Value"); + } + + [Test()] + public void TestNonAmqTypeProcessing() + { + ConsumerId id = new ConsumerId(); + id.ConnectionId = "cheese"; + id.SessionId = 2; + id.Value = 3; + + string text = id.ToString(); + Assert.AreEqual("cheese:2:3", text, "ConsumerId as stomp"); + + ConsumerId another = new ConsumerId("abc56"); + Assert.AreEqual("abc56", another.ConnectionId, "extracting consumerId.ConnectionId"); + Assert.AreEqual(0, another.SessionId, "extracting consumerId.SessionId"); + Assert.AreEqual(0, another.Value, "extracting consumerId.Value"); + + another = new ConsumerId("abc:def"); + Assert.AreEqual("abc:def", another.ConnectionId, "extracting consumerId.ConnectionId"); + Assert.AreEqual(0, another.SessionId, "extracting consumerId.SessionId"); + Assert.AreEqual(0, another.Value, "extracting consumerId.Value"); + } + } +} Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ConsumerIdTest.cs ------------------------------------------------------------------------------ svn:eol-style = native Added: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ProducerIdTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ProducerIdTest.cs?rev=940919&view=auto ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ProducerIdTest.cs (added) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ProducerIdTest.cs Tue May 4 15:52:22 2010 @@ -0,0 +1,67 @@ +// /* +// * Licensed to the Apache Software Foundation (ASF) under one or more +// * contributor license agreements. See the NOTICE file distributed with +// * this work for additional information regarding copyright ownership. +// * The ASF licenses this file to You 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. +// */ +// + +using System; +using NUnit.Framework; +using Apache.NMS.Stomp.Commands; + +namespace Apache.NMS.Stomp.Test.Commands +{ + [TestFixture] + public class ProducerIdTest + { + [Test] + public void TestAmqTypeProcessing() + { + ProducerId id = new ProducerId(); + id.ConnectionId = "cheese"; + id.SessionId = 2; + id.Value = 3; + + string text = id.ToString(); + Assert.AreEqual("cheese:2:3", text, "ConsumerId as stomp"); + + ProducerId another = new ProducerId("abc:5:6"); + Assert.AreEqual("abc", another.ConnectionId, "extracting consumerId.ConnectionId"); + Assert.AreEqual(5, another.SessionId, "extracting consumerId.SessionId"); + Assert.AreEqual(6, another.Value, "extracting consumerId.Value"); + } + + [Test] + public void TestNonAmqTypeProcessing() + { + ProducerId id = new ProducerId(); + id.ConnectionId = "cheese"; + id.SessionId = 2; + id.Value = 3; + + string text = id.ToString(); + Assert.AreEqual("cheese:2:3", text, "ConsumerId as stomp"); + + ProducerId another = new ProducerId("abc56"); + Assert.AreEqual("abc56", another.ConnectionId, "extracting consumerId.ConnectionId"); + Assert.AreEqual(0, another.SessionId, "extracting consumerId.SessionId"); + Assert.AreEqual(0, another.Value, "extracting consumerId.Value"); + + another = new ProducerId("abc:def"); + Assert.AreEqual("abc:def", another.ConnectionId, "extracting consumerId.ConnectionId"); + Assert.AreEqual(0, another.SessionId, "extracting consumerId.SessionId"); + Assert.AreEqual(0, another.Value, "extracting consumerId.Value"); + } + } +} Propchange: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/Commands/ProducerIdTest.cs ------------------------------------------------------------------------------ svn:eol-style = native Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/MessageTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/MessageTest.cs?rev=940919&r1=940918&r2=940919&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/MessageTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/MessageTest.cs Tue May 4 15:52:22 2010 @@ -47,6 +47,45 @@ namespace Apache.NMS.Stomp.Test [RowTest] [Row(MsgDeliveryMode.Persistent)] [Row(MsgDeliveryMode.NonPersistent)] + public void SendReceiveMessageIdComparisonTest(MsgDeliveryMode deliveryMode) + { + using(IConnection connection = CreateConnection(TEST_CLIENT_ID + ":" + new Random().Next())) + { + connection.Start(); + using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge)) + { + IDestination destination = SessionUtil.GetDestination(session, DESTINATION_NAME); + using(IMessageConsumer consumer = session.CreateConsumer(destination)) + using(IMessageProducer producer = session.CreateProducer(destination)) + { + producer.DeliveryMode = deliveryMode; + producer.RequestTimeout = receiveTimeout; + IMessage request1 = session.CreateMessage(); + IMessage request2 = session.CreateMessage(); + IMessage request3 = session.CreateMessage(); + + producer.Send(request1); + producer.Send(request2); + producer.Send(request3); + + IMessage message1 = consumer.Receive(receiveTimeout); + Assert.IsNotNull(message1, "No message returned!"); + IMessage message2 = consumer.Receive(receiveTimeout); + Assert.IsNotNull(message2, "No message returned!"); + IMessage message3 = consumer.Receive(receiveTimeout); + Assert.IsNotNull(message3, "No message returned!"); + + Assert.AreNotEqual(message1.NMSMessageId, message2.NMSMessageId); + Assert.AreNotEqual(message1.NMSMessageId, message3.NMSMessageId); + Assert.AreNotEqual(message2.NMSMessageId, message3.NMSMessageId); + } + } + } + } + + [RowTest] + [Row(MsgDeliveryMode.Persistent)] + [Row(MsgDeliveryMode.NonPersistent)] public void SendReceiveMessageProperties(MsgDeliveryMode deliveryMode) { using(IConnection connection = CreateConnection(TEST_CLIENT_ID + ":" + new Random().Next())) Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/StompHelperTest.cs URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/StompHelperTest.cs?rev=940919&r1=940918&r2=940919&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/StompHelperTest.cs (original) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/test/csharp/StompHelperTest.cs Tue May 4 15:52:22 2010 @@ -31,10 +31,10 @@ namespace Apache.NMS.Stomp.Test id.SessionId = 2; id.Value = 3; - string text = StompHelper.ToStomp(id); + string text = id.ToString(); Assert.AreEqual("cheese:2:3", text, "ConsumerId as stomp"); - ConsumerId another = StompHelper.ToConsumerId("abc:5:6"); + ConsumerId another = new ConsumerId("abc:5:6"); Assert.AreEqual("abc", another.ConnectionId, "extracting consumerId.ConnectionId"); Assert.AreEqual(5, another.SessionId, "extracting consumerId.SessionId"); Assert.AreEqual(6, another.Value, "extracting consumerId.Value"); @@ -53,10 +53,10 @@ namespace Apache.NMS.Stomp.Test mid.BrokerSequenceId = 5; mid.ProducerSequenceId = 6; - string text = StompHelper.ToStomp(mid); + string text = mid.ToString(); Assert.AreEqual("cheese:2:3:6", text, "MessageId as stomp"); - MessageId mid2 = StompHelper.ToMessageId("abc:5:6:7:8"); + MessageId mid2 = new MessageId("abc:5:6:7:8"); Assert.AreEqual(8, mid2.ProducerSequenceId, "extracting mid2.ProducerSequenceId"); ProducerId another = mid2.ProducerId; Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj?rev=940919&r1=940918&r2=940919&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj (original) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp-test.csproj Tue May 4 15:52:22 2010 @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> @@ -31,6 +31,7 @@ <BootstrapperEnabled>true</BootstrapperEnabled> <SignAssembly>true</SignAssembly> <AssemblyOriginatorKeyFile>keyfile\NMSKey.snk</AssemblyOriginatorKeyFile> + <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -52,14 +53,6 @@ <DefineConstants>NET,NET_2_0</DefineConstants> </PropertyGroup> <ItemGroup> - <Reference Include="Apache.NMS, Version=83.161.120.1555, Culture=neutral, PublicKeyToken=82756feee3957618, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>lib\Apache.NMS\net-2.0\Apache.NMS.dll</HintPath> - </Reference> - <Reference Include="Apache.NMS.Test, Version=83.161.120.1555, Culture=neutral, PublicKeyToken=82756feee3957618, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>lib\Apache.NMS\net-2.0\Apache.NMS.Test.dll</HintPath> - </Reference> <Reference Include="nunit.framework, Version=83.161.120.155, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>lib\NUnit\net-2.0\nunit.framework.dll</HintPath> @@ -70,6 +63,14 @@ </Reference> <Reference Include="System" /> <Reference Include="System.Xml" /> + <Reference Include="Apache.NMS, Version=83.161.120.1556, Culture=neutral, PublicKeyToken=82756feee3957618"> + <SpecificVersion>False</SpecificVersion> + <HintPath>build\mono-2.0\debug\Apache.NMS.dll</HintPath> + </Reference> + <Reference Include="Apache.NMS.Stomp, Version=83.161.120.1559, Culture=neutral, PublicKeyToken=82756feee3957618"> + <SpecificVersion>False</SpecificVersion> + <HintPath>build\mono-2.0\debug\Apache.NMS.Stomp.dll</HintPath> + </Reference> </ItemGroup> <ItemGroup> <BootstrapperPackage Include="Microsoft.Net.Framework.2.0"> @@ -133,5 +134,7 @@ <Compile Include="src\test\csharp\Commands\MapMessageTest.cs" /> <Compile Include="src\test\csharp\Protocol\XmlPrimitiveMapMarshalerTest.cs" /> <Compile Include="src\test\csharp\MapMessageTest.cs" /> + <Compile Include="src\test\csharp\Commands\ConsumerIdTest.cs" /> + <Compile Include="src\test\csharp\Commands\ProducerIdTest.cs" /> </ItemGroup> </Project> \ No newline at end of file Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj?rev=940919&r1=940918&r2=940919&view=diff ============================================================================== --- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj (original) +++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/vs2008-stomp.csproj Tue May 4 15:52:22 2010 @@ -53,12 +53,12 @@ <DefineConstants>TRACE;NET,NET_2_0</DefineConstants> </PropertyGroup> <ItemGroup> - <Reference Include="Apache.NMS, Version=83.161.120.1555, Culture=neutral, PublicKeyToken=82756feee3957618, processorArchitecture=MSIL"> - <SpecificVersion>False</SpecificVersion> - <HintPath>lib\Apache.NMS\net-2.0\Apache.NMS.dll</HintPath> - </Reference> <Reference Include="System" /> <Reference Include="System.Xml" /> + <Reference Include="Apache.NMS, Version=83.161.120.1553, Culture=neutral, PublicKeyToken=82756feee3957618"> + <SpecificVersion>False</SpecificVersion> + <HintPath>build\mono-2.0\debug\Apache.NMS.dll</HintPath> + </Reference> </ItemGroup> <ItemGroup> <BootstrapperPackage Include="Microsoft.Net.Framework.2.0"> From commits-nelsonholly@example.com Tue May 04 20:48:47 2010 Return-Path: <commits-nelsonholly@example.com> Delivered-To: nelsonholly@example.com Received: (qmail 28784 invoked from network); 4 May 2010 20:48:47 -0000 Received: from unknown (HELO mail.apache.org) (83.161.120.155) by 83.161.120.155 with SMTP; 4 May 2010 20:48:47 -0000 Received: (qmail 48153 invoked by uid 500); 4 May 2010 20:48:47 -0000 Delivered-To: nelsonholly@example.com Received: (qmail 48089 invoked by uid 500); 4 May 2010 20:48:47 -0000 Mailing-List: contact nelsonholly@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:nelsonholly@example.com> List-Unsubscribe: <mailto:nelsonholly@example.com> List-Post: <mailto:nelsonholly@example.com> List-Id: <commits.activemq.apache.org> Reply-To: nelsonholly@example.com Delivered-To: mailing list nelsonholly@example.com Received: (qmail 48082 invoked by uid 99); 4 May 2010 20:48:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 May 2010 20:48:47 +0000 X-ASF-Spam-Status: No, hits=-1240.5 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 May 2010 20:48:46 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D8CAA23889D2; Tue, 4 May 2010 20:47:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r941035 - /activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.cpp Date: Tue, 04 May 2010 20:47:55 -0000 To: nelsonholly@example.com From: nelsonholly@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <nelsonholly@example.com> Author: tabish Date: Tue May 4 20:47:55 2010 New Revision: 941035 URL: http://svn.apache.org/viewvc?rev=941035&view=rev Log: https://issues.apache.org/activemq/browse/AMQCPP-277 Apply some user supplied suggestions to the Windows Thread code to try and fix a hang on Windows. Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.cpp Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.cpp?rev=941035&r1=941034&r2=941035&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.cpp (original) +++ activemq/activemq-cpp/trunk/activemq-cpp/src/main/decaf/lang/Thread.cpp Tue May 4 20:47:55 2010 @@ -117,6 +117,8 @@ namespace lang{ #ifdef HAVE_PTHREAD_H pthread_attr_destroy( &attributes ); + #else + 888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4loseHandle( handle ); #endif } @@ -205,17 +207,13 @@ namespace{ 888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4TlsSetValue( currentThreadKey, NULL ); + properties->state = Thr888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4TERMINATED; + #ifndef _WIN32_WCE _endthreadex( 0 ); #else ExitThread( 0 ); #endif - - 888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4loseHandle( properties->handle ); - - properties->state = Thr888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4TERMINATED; - - return NULL; } #endif @@ -420,7 +418,7 @@ void Thr888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4join() throw( d888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4lang888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4 void* theReturn = 0; pthread_join( properties->handle, &theReturn ); #else - Thr888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4join( INFINITE, 0 ); + 888a:dbb7:2d49:b3f6:8605:bf4e:caed:e5a4WaitForSingleObject( properties->handle, INFINITE ); #endif } } From commits-nelsonholly@example.com Wed May 05 07:10:31 2010 Return-Path: <commits-nelsonholly@example.com> Delivered-To: nelsonholly@example.com Received: (qmail 46690 invoked from network); 5 May 2010 07:10:31 -0000 Received: from unknown (HELO mail.apache.org) (83.161.120.155) by 83.161.120.155 with SMTP; 5 May 2010 07:10:31 -0000 Received: (qmail 46012 invoked by uid 500); 5 May 2010 07:10:31 -0000 Delivered-To: nelsonholly@example.com Received: (qmail 45955 invoked by uid 500); 5 May 2010 07:10:30 -0000 Mailing-List: contact nelsonholly@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:nelsonholly@example.com> List-Unsubscribe: <mailto:nelsonholly@example.com> List-Post: <mailto:nelsonholly@example.com> List-Id: <commits.activemq.apache.org> Reply-To: nelsonholly@example.com Delivered-To: mailing list nelsonholly@example.com Received: (qmail 45948 invoked by uid 99); 5 May 2010 07:10:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 May 2010 07:10:30 +0000 X-ASF-Spam-Status: No, hits=-1434.9 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 May 2010 07:10:28 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 00CC4238897A; Wed, 5 May 2010 07:09:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r941174 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/region/Queue.java test/java/org/apache/activemq/bugs/OutOfOrderTestCase.java Date: Wed, 05 May 2010 07:09:37 -0000 To: nelsonholly@example.com From: nelsonholly@example.com X-Mailer: svnmailer-1.0.8 Message-Id: <nelsonholly@example.com> Author: dejanb Date: Wed May 5 07:09:37 2010 New Revision: 941174 URL: http://svn.apache.org/viewvc?rev=941174&view=rev Log: https://issues.apache.org/activemq/browse/AMQ-2719 - order of redelivered messages Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/OutOfOrderTestCase.java Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java?rev=941174&r1=941173&r2=941174&view=diff ============================================================================== --- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java (original) +++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/region/Queue.java Wed May 5 07:09:37 2010 @@ -95,6 +95,7 @@ public class Queue extends BaseDestinati private final LinkedHashMap<MessageId, QueueMessageReference> pagedInMessages = new LinkedHashMap<MessageId, QueueMessageReference>(); // Messages that are paged in but have not yet been targeted at a subscription private List<QueueMessageReference> pagedInPendingDispatch = new ArrayList<QueueMessageReference>(100); + private List<QueueMessageReference> redeliveredWaitingDispatch = new ArrayList<QueueMessageReference>(); private MessageGroupMap messageGroupOwners; private DispatchPolicy dispatchPolicy = new RoundRobinDispatchPolicy(); private MessageGroupMapFactory messageGroupMapFactory = new MessageGroupHashBucketFactory(); @@ -377,7 +378,7 @@ public class Queue extends BaseDestinati wakeup(); } } - + public void removeSubscription(ConnectionContext context, Subscription sub, long lastDeiveredSequenceId) throws Exception { destinationStatistics.getConsumers().decrement(); // synchronize with dispatch method so that no new messages are sent @@ -406,7 +407,7 @@ public class Queue extends BaseDestinati getMessageGroupOwners().removeConsumer(consumerId); // redeliver inflight messages - List<QueueMessageReference> list = new ArrayList<QueueMessageReference>(); + for (MessageReference ref : sub.remove(context, this)) { QueueMessageReference qmr = (QueueMessageReference) ref; if (qmr.getLockOwner() == sub) { @@ -416,11 +417,10 @@ public class Queue extends BaseDestinati qmr.incrementRedeliveryCounter(); } } - list.add(qmr); + redeliveredWaitingDispatch.add(qmr); } - - if (!list.isEmpty()) { - doDispatch(list); + if (!redeliveredWaitingDispatch.isEmpty()) { + doDispatch(new ArrayList()); } } if (!(this.optimizedDispatch || isSlave())) { @@ -1220,7 +1220,7 @@ public class Queue extends BaseDestinati // Perhaps we should page always into the pagedInPendingDispatch list if // !messages.isEmpty(), and then if !pagedInPendingDispatch.isEmpty() // then we do a dispatch. - if (pageInMoreMessages || pendingBrowserDispatch != null) { + if (pageInMoreMessages || pendingBrowserDispatch != null || !redeliveredWaitingDispatch.isEmpty()) { try { pageInMessages(pendingBrowserDispatch != null); @@ -1494,8 +1494,12 @@ public class Queue extends BaseDestinati synchronized (dispatchMutex) { synchronized (pagedInPendingDispatch) { + if (!redeliveredWaitingDispatch.isEmpty()) { + // Try first to dispatch redelivered messages to keep an proper order + redeliveredWaitingDispatch = doActualDispatch(redeliveredWaitingDispatch); + } if (!pagedInPendingDispatch.isEmpty()) { - // Try to first dispatch anything that had not been + // Next dispatch anything that had not been // dispatched before. pagedInPendingDispatch = doActualDispatch(pagedInPendingDispatch); } Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/OutOfOrderTestCase.java URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/OutOfOrderTestCase.java?rev=941174&view=auto ============================================================================== --- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/OutOfOrderTestCase.java (added) +++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/OutOfOrderTestCase.java Wed May 5 07:09:37 2010 @@ -0,0 +1,118 @@ +package org.apache.activemq.bugs; + +import java.util.Date; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; + +import junit.framework.TestCase; + +import org.apache.activemq.ActiveMQConnectionFactory; +import org.apache.activemq.broker.BrokerService; +import org.apache.activemq.bugs.AMQ1866.ConsumerThread; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class OutOfOrderTestCase extends TestCase { + + private static final Log log = LogFactory.getLog(OutOfOrderTestCase.class); + + public static final String BROKER_URL = "tcp://localhost:61616"; + private static final int PREFETCH = 10; + private static final String CONNECTION_URL = BROKER_URL + "?jms.prefetchPolicy.all=" + PREFETCH; + + public static final String QUEUE_NAME = "QUEUE"; + private static final String DESTINATION = "QUEUE?consumer.exclusive=true"; + + BrokerService brokerService; + Session session; + Connection connection; + + int seq = 0; + + public void setUp() throws Exception { + brokerService = new BrokerService(); + brokerService.setUseJmx(true); + brokerService.addConnector(BROKER_URL); + brokerService.deleteAllMessages(); + brokerService.start(); + + ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(CONNECTION_URL); + connection = connectionFactory.createConnection(); + connection.start(); + session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); + + } + + + protected void tearDown() throws Exception { + session.close(); + connection.close(); + brokerService.stop(); + } + + + + public void testOrder() throws Exception { + + log.info("Producing messages 0-29 . . ."); + Destination destination = session.createQueue(DESTINATION); + final MessageProducer messageProducer = session + .createProducer(destination); + try { + for (int i = 0; i < 30; ++i) { + final Message message = session + .createTextMessage(createMessageText(i)); + message.setStringProperty("JMSXGroupID", "FOO"); + + messageProducer.send(message); + log.info("sent " + toString(message)); + } + } finally { + messageProducer.close(); + } + + log.info("Consuming messages 0-9 . . ."); + consumeBatch(); + + log.info("Consuming messages 10-19 . . ."); + consumeBatch(); + + log.info("Consuming messages 20-29 . . ."); + consumeBatch(); + } + + protected void consumeBatch() throws Exception { + Destination destination = session.createQueue(DESTINATION); + final MessageConsumer messageConsumer = session.createConsumer(destination); + try { + for (int i = 0; i < 10; ++i) { + final Message message = messageConsumer.receive(1000L); + log.info("received " + toString(message)); + assertEquals("Message out of order", createMessageText(seq++), ((TextMessage) message).getText()); + message.acknowledge(); + } + } finally { + messageConsumer.close(); + } + } + + private String toString(final Message message) throws JMSException { + String ret = "received message '" + ((TextMessage) message).getText() + "' - " + message.getJMSMessageID(); + if (message.getJMSRedelivered()) + ret += " (redelivered)"; + return ret; + + } + + private static String createMessageText(final int index) { + return "message #" + index; + } +} \ No newline at end of file From commits-nelsonholly@example.com Wed May 05 13:38:09 2010 Return-Path: <commits-nelsonholly@example.com> Delivered-To: nelsonholly@example.com Received: (qmail 27229 invoked from network); 5 May 2010 13:38:09 -0000 Received: from unknown (HELO mail.apache.org) (83.161.120.155) by 83.161.120.155 with SMTP; 5 May 2010 13:38:09 -0000 Received: (qmail 16322 invoked by uid 500); 5 May 2010 13:38:09 -0000 Delivered-To: nelsonholly@example.com Received: (qmail 16270 invoked by uid 500); 5 May 2010 13:38:08 -0000 Mailing-List: contact nelsonholly@example.com; run by ezmlm Precedence: bulk List-Help: <mailto:nelsonholly@example.com> List-Unsubscribe: <mailto:nelsonholly@example.com> List-Post: <mailto:nelsonholly@example.com> List-Id: <commits.activemq.apache.org> Reply-To: nelsonholly@example.com Delivered-To: mailing list nelsonholly@example.com Received: (qmail 16263 invoked by uid 99); 5 May 2010 13:38:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 May 2010 13:38:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 May 2010 13:38:05 +0000 Received: by
{'source': 'Apache Software Foundation Public Mail Archives'}