From 26cd2b67b267b69ece35458d1d3cc4c4bc5707cc Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Tue, 11 Sep 2007 12:59:01 +0000 Subject: This is the first pass at refactoring the Connection stuff. The AMQConnection was not made abstract to preserve the widely usd AMQConsutructor in test cases. Instead 0-8,0-10 specific functionality was delegated to a version specific delegate. The version is selected via a JVM argument (and based on the URL format) Currently this mean that we can test only a single code path (o-8 or 0-10) at a time. Next Step is to refactor the URL stuff. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@574582 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/client/AMQConnectionDelegate_0_10.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java new file mode 100644 index 0000000000..8213182907 --- /dev/null +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -0,0 +1,43 @@ +package org.apache.qpid.client; + +import java.io.IOException; + +import javax.jms.JMSException; + +import org.apache.qpid.AMQException; +import org.apache.qpid.client.failover.FailoverException; +import org.apache.qpid.jms.BrokerDetails; +import org.apache.qpid.jms.Session; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate +{ + + private static final Logger _logger = LoggerFactory.getLogger(AMQConnectionDelegate_0_10.class); + private AMQConnection _conn; + + public AMQConnectionDelegate_0_10(AMQConnection conn) + { + _conn = conn; + } + + public Session createSession(boolean transacted, int acknowledgeMode, int prefetchHigh, int prefetchLow) throws JMSException + { + // TODO Auto-generated method stub + return null; + } + + public void makeBrokerConnection(BrokerDetails brokerDetail) throws IOException, AMQException + { + // TODO Auto-generated method stub + + } + + public void resubscribeSessions() throws JMSException, AMQException, FailoverException + { + // TODO Auto-generated method stub + + } + +} -- cgit v1.2.1 From 142731d6b097ab983cc3a5d3dc234378e2285fc8 Mon Sep 17 00:00:00 2001 From: Arnaud Simon Date: Mon, 17 Sep 2007 12:07:56 +0000 Subject: 0_10 implementation git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@576388 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/client/AMQConnectionDelegate_0_10.java | 78 +++++++++++++++++++--- 1 file changed, 70 insertions(+), 8 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 8213182907..42d67b0cd3 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -5,39 +5,101 @@ import java.io.IOException; import javax.jms.JMSException; import org.apache.qpid.AMQException; +import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.Session; +import org.apache.qpidity.client.Client; +import org.apache.qpidity.QpidException; +import org.apache.qpidity.jms.SessionImpl; +import org.apache.qpidity.jms.ExceptionHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate { - + /** + * This class logger. + */ private static final Logger _logger = LoggerFactory.getLogger(AMQConnectionDelegate_0_10.class); + + /** + * The AMQ Connection. + */ private AMQConnection _conn; + /** + * The QpidConeection instance that is mapped with thie JMS connection. + */ + org.apache.qpidity.client.Connection _qpidConnection; + + //--- constructor public AMQConnectionDelegate_0_10(AMQConnection conn) { _conn = conn; } - public Session createSession(boolean transacted, int acknowledgeMode, int prefetchHigh, int prefetchLow) throws JMSException + /** + * create a Session and start it if required. + */ + public Session createSession(boolean transacted, int acknowledgeMode, int prefetchHigh, int prefetchLow) + throws JMSException { - // TODO Auto-generated method stub - return null; + _conn.checkNotClosed(); + int channelId = _conn._idFactory.incrementAndGet(); + AMQSession session = + new AMQSession_0_10(_conn, channelId, transacted, acknowledgeMode, prefetchHigh, prefetchLow); + try + { + // create the qpid session with an expiry <= 0 so that the session does not expire + _qpidConnection.createSession(0); + _conn.registerSession(channelId, session); + if (_conn._started) + { + session.start(); + } + } + catch (Exception e) + { + throw new JMSAMQException("cannot create session", e); + } + return session; } + /** + * Make a connection with the broker + * + * @param brokerDetail The detail of the broker to connect to. + * @throws IOException + * @throws AMQException + */ public void makeBrokerConnection(BrokerDetails brokerDetail) throws IOException, AMQException { - // TODO Auto-generated method stub - + _qpidConnection = Client.createConnection(); + try + { + if (_logger.isDebugEnabled()) + { + _logger.debug("creating connection with broker " + " host: " + brokerDetail + .getHost() + " port: " + brokerDetail.getPort() + " virtualhost: " + _conn + .getVirtualHost() + "user name: " + _conn.getUsername() + "password: " + _conn.getPassword()); + } + _qpidConnection.connect(brokerDetail.getHost(), brokerDetail.getPort(), _conn.getVirtualHost(), + _conn.getUsername(), _conn.getPassword()); + } + catch (QpidException e) + { + throw new AMQException(AMQConstant.CHANNEL_ERROR, "cannot connect to broker", e); + } } + /** + * Not supported at this level. + */ public void resubscribeSessions() throws JMSException, AMQException, FailoverException { - // TODO Auto-generated method stub - + //NOT implemented as railover is handled at a lower level + throw new FailoverException("failing to reconnect during failover, operation not supported."); } } -- cgit v1.2.1 From ed3fa3cbbc9a960d701bc1463bab75bd4f426265 Mon Sep 17 00:00:00 2001 From: Arnaud Simon Date: Mon, 17 Sep 2007 12:22:08 +0000 Subject: changed qpid session propagation git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@576396 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 42d67b0cd3..93a12b602b 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -47,12 +47,10 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate { _conn.checkNotClosed(); int channelId = _conn._idFactory.incrementAndGet(); - AMQSession session = - new AMQSession_0_10(_conn, channelId, transacted, acknowledgeMode, prefetchHigh, prefetchLow); + AMQSession session; try - { - // create the qpid session with an expiry <= 0 so that the session does not expire - _qpidConnection.createSession(0); + { + session = new AMQSession_0_10(_qpidConnection, _conn, channelId, transacted, acknowledgeMode, prefetchHigh, prefetchLow); _conn.registerSession(channelId, session); if (_conn._started) { @@ -98,8 +96,8 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate */ public void resubscribeSessions() throws JMSException, AMQException, FailoverException { - //NOT implemented as railover is handled at a lower level - throw new FailoverException("failing to reconnect during failover, operation not supported."); + //NOT implemented as railover is handled at a lower level + throw new FailoverException("failing to reconnect during failover, operation not supported."); } } -- cgit v1.2.1 From bd056ec091ebb90024ae0f0e85e4191ccf4f59af Mon Sep 17 00:00:00 2001 From: Arnaud Simon Date: Mon, 17 Sep 2007 15:58:20 +0000 Subject: fixed several bugs after running samples against 0_10 git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@576491 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/client/AMQConnectionDelegate_0_10.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 93a12b602b..8b6b416f88 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -49,8 +49,9 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate int channelId = _conn._idFactory.incrementAndGet(); AMQSession session; try - { - session = new AMQSession_0_10(_qpidConnection, _conn, channelId, transacted, acknowledgeMode, prefetchHigh, prefetchLow); + { + session = new AMQSession_0_10(_qpidConnection, _conn, channelId, transacted, acknowledgeMode, prefetchHigh, + prefetchLow); _conn.registerSession(channelId, session); if (_conn._started) { @@ -100,4 +101,17 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate throw new FailoverException("failing to reconnect during failover, operation not supported."); } + + public void closeConneciton(long timeout) throws JMSException, AMQException + { + try + { + _qpidConnection.close(); + } + catch (QpidException e) + { + throw new AMQException(AMQConstant.CHANNEL_ERROR, "cannot close connection", e); + } + + } } -- cgit v1.2.1 From 12e0121b392be8fa1707eb5c73d29d55317f813c Mon Sep 17 00:00:00 2001 From: Arnaud Simon Date: Tue, 18 Sep 2007 14:37:09 +0000 Subject: Added XA support (for 0_10 only) git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@576933 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/client/AMQConnectionDelegate_0_10.java | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 8b6b416f88..cd657570bf 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -3,6 +3,7 @@ package org.apache.qpid.client; import java.io.IOException; import javax.jms.JMSException; +import javax.jms.XASession; import org.apache.qpid.AMQException; import org.apache.qpid.protocol.AMQConstant; @@ -11,8 +12,6 @@ import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.Session; import org.apache.qpidity.client.Client; import org.apache.qpidity.QpidException; -import org.apache.qpidity.jms.SessionImpl; -import org.apache.qpidity.jms.ExceptionHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,6 +64,31 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate return session; } + /** + * create an XA Session and start it if required. + */ + public XASession createXASession(int prefetchHigh, int prefetchLow) throws JMSException + { + _conn.checkNotClosed(); + int channelId = _conn._idFactory.incrementAndGet(); + XASessionImpl session; + try + { + session = new XASessionImpl(_qpidConnection, _conn, channelId, prefetchHigh, prefetchLow); + _conn.registerSession(channelId, session); + if (_conn._started) + { + session.start(); + } + } + catch (Exception e) + { + throw new JMSAMQException("cannot create session", e); + } + return session; + } + + /** * Make a connection with the broker * -- cgit v1.2.1 From 7fb79e5c52217f6f2a9aed378dcda621044eb7de Mon Sep 17 00:00:00 2001 From: Arnaud Simon Date: Wed, 19 Sep 2007 09:58:02 +0000 Subject: renamed qpidity.jms to qpidity.njms and qpidity.client to qpidity.nclient git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@577227 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index cd657570bf..78090b45ad 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -10,7 +10,7 @@ import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.Session; -import org.apache.qpidity.client.Client; +import org.apache.qpidity.nclient.Client; import org.apache.qpidity.QpidException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,7 +30,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate /** * The QpidConeection instance that is mapped with thie JMS connection. */ - org.apache.qpidity.client.Connection _qpidConnection; + org.apache.qpidity.nclient.Connection _qpidConnection; //--- constructor public AMQConnectionDelegate_0_10(AMQConnection conn) -- cgit v1.2.1 From 8dcb1d30b0414a3aa139dd93319ce2fe42c9049a Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Tue, 29 Jan 2008 22:24:40 +0000 Subject: added support to notify connection.close to the JMSExceptionListener git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@616542 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 78090b45ad..1bf1c5bc7f 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -11,11 +11,13 @@ import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.Session; import org.apache.qpidity.nclient.Client; +import org.apache.qpidity.nclient.ClosedListener; +import org.apache.qpidity.ErrorCode; import org.apache.qpidity.QpidException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate +public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, ClosedListener { /** * This class logger. @@ -138,4 +140,13 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate } } + + public void onClosed(ErrorCode errorCode, String reason) + { + if (_logger.isDebugEnabled()) + { + _logger.debug("Received a connection close from the broker: Error code : " + errorCode.getCode()); + } + _conn._exceptionListener.onException(new JMSException(reason,String.valueOf(errorCode.getCode()))); + } } -- cgit v1.2.1 From cd5a66bba5e6f7a066e26f30652c2f6a207a29c7 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Tue, 5 Feb 2008 02:37:13 +0000 Subject: Added code to connect the network error exceptions to the JMS Exception listener. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@618519 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 1bf1c5bc7f..e3c12a3f50 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -111,6 +111,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed } _qpidConnection.connect(brokerDetail.getHost(), brokerDetail.getPort(), _conn.getVirtualHost(), _conn.getUsername(), _conn.getPassword()); + _qpidConnection.setClosedListener(this); } catch (QpidException e) { -- cgit v1.2.1 From f1ca5f19a2d6cb8db8bc89597ab649e00ea45dfb Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Wed, 6 Feb 2008 22:36:02 +0000 Subject: Added code to pass in the throwable to the closedListener so that it can be included in the JMS Exception thrown via the ExceptionListener git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@619189 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index e3c12a3f50..e7a2a62e19 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -142,12 +142,17 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed } - public void onClosed(ErrorCode errorCode, String reason) + public void onClosed(ErrorCode errorCode, String reason, Throwable t) { if (_logger.isDebugEnabled()) { _logger.debug("Received a connection close from the broker: Error code : " + errorCode.getCode()); } - _conn._exceptionListener.onException(new JMSException(reason,String.valueOf(errorCode.getCode()))); + JMSException ex = new JMSException(reason,String.valueOf(errorCode.getCode())); + if (t != null) + { + ex.initCause(t); + } + _conn._exceptionListener.onException(ex); } } -- cgit v1.2.1 From 52e81e74a91433167ebc4c6ca22c088d16d9fbbd Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Thu, 7 Feb 2008 18:15:20 +0000 Subject: added test for exception listener; fixed NPE git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@619538 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index e7a2a62e19..bf1ed49492 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -148,11 +148,15 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed { _logger.debug("Received a connection close from the broker: Error code : " + errorCode.getCode()); } - JMSException ex = new JMSException(reason,String.valueOf(errorCode.getCode())); - if (t != null) + if (_conn._exceptionListener != null) { - ex.initCause(t); + JMSException ex = new JMSException(reason,String.valueOf(errorCode.getCode())); + if (t != null) + { + ex.initCause(t); + } + + _conn._exceptionListener.onException(ex); } - _conn._exceptionListener.onException(ex); } } -- cgit v1.2.1 From 42dcda5fb197d0fa85788c9aa04d6c1b2ae1822d Mon Sep 17 00:00:00 2001 From: Arnaud Simon Date: Wed, 2 Apr 2008 09:55:27 +0000 Subject: QPID-829 Remove 0.10 specific URL. The code path is now selected based on broker response. We first try the highest protocol version and update the handler if the broker replies with a different protocol version. NOTE that we need to update the current java broker and 0.8 client for handling protocol headers. This should happen with the M2.1 merge. For the moment we only support an in VM 0.8 broker. Moreover, we'll need to migrate to a 0.10 vs 99.0 protocol version. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@643822 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index bf1ed49492..bde60c433f 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -6,6 +6,7 @@ import javax.jms.JMSException; import javax.jms.XASession; import org.apache.qpid.AMQException; +import org.apache.qpid.AMQProtocolException; import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.jms.BrokerDetails; @@ -14,6 +15,7 @@ import org.apache.qpidity.nclient.Client; import org.apache.qpidity.nclient.ClosedListener; import org.apache.qpidity.ErrorCode; import org.apache.qpidity.QpidException; +import org.apache.qpidity.ProtocolException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -113,6 +115,10 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed _conn.getUsername(), _conn.getPassword()); _qpidConnection.setClosedListener(this); } + catch(ProtocolException pe) + { + throw new AMQProtocolException(null, pe.getMessage(), pe); + } catch (QpidException e) { throw new AMQException(AMQConstant.CHANNEL_ERROR, "cannot connect to broker", e); -- cgit v1.2.1 From 01238260de081423705f65442687af75720acca6 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Thu, 5 Jun 2008 17:53:32 +0000 Subject: QPID-1116: fixed a race condition in connection/session close, session close now waits for the session to be detached before returning, this guarantees we won't have any active sessions when the connection close is attempted git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@663677 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index bde60c433f..e741d4071c 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -152,7 +152,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed { if (_logger.isDebugEnabled()) { - _logger.debug("Received a connection close from the broker: Error code : " + errorCode.getCode()); + _logger.debug("Received a connection close from the broker: Error code : " + errorCode.getCode(), t); } if (_conn._exceptionListener != null) { -- cgit v1.2.1 From 2f71b0fca0c47b53c24e185d0770f2baabddd425 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Mon, 16 Jun 2008 21:04:01 +0000 Subject: QPID-1139: use RFC1982 comparisons for rollback mark and update rollback mark to track dispatched messages git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@668311 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index e741d4071c..61c06df7a5 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -63,6 +63,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed } catch (Exception e) { + _logger.error("exception creating session:", e); throw new JMSAMQException("cannot create session", e); } return session; -- cgit v1.2.1 From fed24c803a9c901f3fdc680c136230326a166580 Mon Sep 17 00:00:00 2001 From: Aidan Skinner Date: Thu, 3 Jul 2008 14:33:10 +0000 Subject: QPID-962 Exception handling was... unpleasing... Fix up of patch from rhs AMQConnection.java: Refactor listener and stack exceptions in a list. Add get lastException, which can now be any Exception. Don't set connected, let the delegate decide. AMQConnectionDelegate_8_0.java, AMQConnectionDelete_0_10.java: set _connected to true if we suceed AMQProtocolHandler.java: attainState can now throw any sort of Exception AMQStateManager.java: attainState can now throw any Exception ConnectionTest.java: check that exception cause is not null AMQConnectionFailureException.java: Add ability to store a Collection of Exceptions in case there are multiple possible causes of the failure. Which there shouldn't be, but it can happen. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@673688 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 61c06df7a5..825a52c5cb 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -115,6 +115,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed _qpidConnection.connect(brokerDetail.getHost(), brokerDetail.getPort(), _conn.getVirtualHost(), _conn.getUsername(), _conn.getPassword()); _qpidConnection.setClosedListener(this); + _conn._connected = true; } catch(ProtocolException pe) { -- cgit v1.2.1 From 404c17dcd4357950a5707595df5446891786eaf8 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Tue, 29 Jul 2008 02:07:20 +0000 Subject: QPID-1201: fixed up version of aidan's patch, there are still failures when running against an external java broker, however we seem to get past basic connection negotiation now git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@680602 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 825a52c5cb..ce10553210 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -9,13 +9,14 @@ import org.apache.qpid.AMQException; import org.apache.qpid.AMQProtocolException; import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.client.failover.FailoverException; +import org.apache.qpid.framing.ProtocolVersion; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.Session; import org.apache.qpidity.nclient.Client; import org.apache.qpidity.nclient.ClosedListener; import org.apache.qpidity.ErrorCode; import org.apache.qpidity.QpidException; -import org.apache.qpidity.ProtocolException; +import org.apache.qpidity.transport.ProtocolVersionException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -101,7 +102,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed * @throws IOException * @throws AMQException */ - public void makeBrokerConnection(BrokerDetails brokerDetail) throws IOException, AMQException + public ProtocolVersion makeBrokerConnection(BrokerDetails brokerDetail) throws IOException, AMQException { _qpidConnection = Client.createConnection(); try @@ -117,14 +118,16 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed _qpidConnection.setClosedListener(this); _conn._connected = true; } - catch(ProtocolException pe) + catch(ProtocolVersionException pe) { - throw new AMQProtocolException(null, pe.getMessage(), pe); + return new ProtocolVersion(pe.getMajor(), pe.getMinor()); } catch (QpidException e) { throw new AMQException(AMQConstant.CHANNEL_ERROR, "cannot connect to broker", e); } + + return null; } /** -- cgit v1.2.1 From a344e91b126c4923eadd3d2b0024d681e8570f70 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Tue, 29 Jul 2008 19:03:34 +0000 Subject: QPID-1072: renamed org.apache.qpidity -> org.apache.qpid git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@680803 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index ce10553210..a2df2f3cf2 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -12,11 +12,11 @@ import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.framing.ProtocolVersion; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.Session; -import org.apache.qpidity.nclient.Client; -import org.apache.qpidity.nclient.ClosedListener; -import org.apache.qpidity.ErrorCode; -import org.apache.qpidity.QpidException; -import org.apache.qpidity.transport.ProtocolVersionException; +import org.apache.qpid.nclient.Client; +import org.apache.qpid.nclient.ClosedListener; +import org.apache.qpid.ErrorCode; +import org.apache.qpid.QpidException; +import org.apache.qpid.transport.ProtocolVersionException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed /** * The QpidConeection instance that is mapped with thie JMS connection. */ - org.apache.qpidity.nclient.Connection _qpidConnection; + org.apache.qpid.nclient.Connection _qpidConnection; //--- constructor public AMQConnectionDelegate_0_10(AMQConnection conn) -- cgit v1.2.1 From 32b6fe75c94f7d016c9a101e63d179a656d3ea14 Mon Sep 17 00:00:00 2001 From: Aidan Skinner Date: Fri, 22 Aug 2008 15:21:08 +0000 Subject: QPID-1258 add ASL to java files that were missing it git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@688094 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/client/AMQConnectionDelegate_0_10.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index a2df2f3cf2..c723709d27 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -1,4 +1,25 @@ package org.apache.qpid.client; +/* + * + * 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. + * + */ + import java.io.IOException; -- cgit v1.2.1 From a09ed43cc8ed5862996e684b924f3405e09734c3 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Thu, 9 Oct 2008 17:07:59 +0000 Subject: QPID-1339: refactor of low level client API to permit connections to exist in a disconnected state as well as to provide a central point from which to track session state git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@703208 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/client/AMQConnectionDelegate_0_10.java | 50 ++++++++++++++-------- 1 file changed, 31 insertions(+), 19 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index c723709d27..a7f04a2090 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -23,6 +23,7 @@ package org.apache.qpid.client; import java.io.IOException; +import javax.jms.ExceptionListener; import javax.jms.JMSException; import javax.jms.XASession; @@ -33,15 +34,18 @@ import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.framing.ProtocolVersion; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.Session; -import org.apache.qpid.nclient.Client; -import org.apache.qpid.nclient.ClosedListener; import org.apache.qpid.ErrorCode; -import org.apache.qpid.QpidException; +import org.apache.qpid.transport.Connection; +import org.apache.qpid.transport.ConnectionClose; +import org.apache.qpid.transport.ConnectionException; +import org.apache.qpid.transport.ConnectionListener; import org.apache.qpid.transport.ProtocolVersionException; +import org.apache.qpid.transport.TransportException; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, ClosedListener +public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, ConnectionListener { /** * This class logger. @@ -56,7 +60,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed /** * The QpidConeection instance that is mapped with thie JMS connection. */ - org.apache.qpid.nclient.Connection _qpidConnection; + org.apache.qpid.transport.Connection _qpidConnection; //--- constructor public AMQConnectionDelegate_0_10(AMQConnection conn) @@ -125,7 +129,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed */ public ProtocolVersion makeBrokerConnection(BrokerDetails brokerDetail) throws IOException, AMQException { - _qpidConnection = Client.createConnection(); + _qpidConnection = new Connection(); try { if (_logger.isDebugEnabled()) @@ -134,16 +138,16 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed .getHost() + " port: " + brokerDetail.getPort() + " virtualhost: " + _conn .getVirtualHost() + "user name: " + _conn.getUsername() + "password: " + _conn.getPassword()); } + _qpidConnection.setConnectionListener(this); _qpidConnection.connect(brokerDetail.getHost(), brokerDetail.getPort(), _conn.getVirtualHost(), _conn.getUsername(), _conn.getPassword()); - _qpidConnection.setClosedListener(this); _conn._connected = true; } catch(ProtocolVersionException pe) { return new ProtocolVersion(pe.getMajor(), pe.getMinor()); } - catch (QpidException e) + catch (ConnectionException e) { throw new AMQException(AMQConstant.CHANNEL_ERROR, "cannot connect to broker", e); } @@ -161,34 +165,42 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Closed } - public void closeConneciton(long timeout) throws JMSException, AMQException + public void closeConnection(long timeout) throws JMSException, AMQException { try { _qpidConnection.close(); } - catch (QpidException e) + catch (TransportException e) { - throw new AMQException(AMQConstant.CHANNEL_ERROR, "cannot close connection", e); + throw new AMQException(e.getMessage(), e); } - } - public void onClosed(ErrorCode errorCode, String reason, Throwable t) + public void opened(Connection conn) {} + + public void exception(Connection conn, ConnectionException exc) { - if (_logger.isDebugEnabled()) + ExceptionListener listener = _conn._exceptionListener; + if (listener == null) { - _logger.debug("Received a connection close from the broker: Error code : " + errorCode.getCode(), t); + _logger.error("connection exception: " + conn, exc); } - if (_conn._exceptionListener != null) + else { - JMSException ex = new JMSException(reason,String.valueOf(errorCode.getCode())); - if (t != null) + ConnectionClose close = exc.getClose(); + String code = null; + if (close != null) { - ex.initCause(t); + code = close.getReplyCode().toString(); } + JMSException ex = new JMSException(exc.getMessage(), code); + ex.initCause(exc); _conn._exceptionListener.onException(ex); } } + + public void closed(Connection conn) {} + } -- cgit v1.2.1 From f2a61c95c3a13151ed03dd53ef802a1aa6e44c6b Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Thu, 23 Oct 2008 19:44:12 +0000 Subject: This is related to QPID-1296. I missed these two files in the previous commit. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@707458 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index a7f04a2090..6480a0da76 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -140,7 +140,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec } _qpidConnection.setConnectionListener(this); _qpidConnection.connect(brokerDetail.getHost(), brokerDetail.getPort(), _conn.getVirtualHost(), - _conn.getUsername(), _conn.getPassword()); + _conn.getUsername(), _conn.getPassword(), brokerDetail.useSSL()); _conn._connected = true; } catch(ProtocolVersionException pe) -- cgit v1.2.1 From 939ccc98d866a00c3246880a6206d61e38debf1b Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Mon, 27 Oct 2008 06:19:08 +0000 Subject: QPID-1339: - Modified QpidTestCase to start/stop multiple brokers for failover testing. - Modified QpidTestCase to substitute port variables into broker start/stop commands. - Modified test profiles to use the new port variables. - Modified QpidTestCase to permit multiple exclude files. - Modified test profiles to make use of a common exclude list: ExcludeList - Added ConnectionTest.testResumeEmptyReplayBuffer. - Made default exception handling for Connection and Session log the exception. - Added SenderExcetion to specifically signal problems with transmitting connection data. - Modified Session to catch and deal with connection send failures for sessions with positive expiry. - Modified FailoverBaseCase to work for non VM brokers. - Made FailoverTest fail if failover times out. - Modified JMS implementation to make use of the recently added low level session resume. - Unexcluded failover tests from 0-10 test profiles. - Excluded MultipleJCAProviderRegistrationTest due to its testing strategy resulting in spurious failure when running as part of the larger test suite. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@708093 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/client/AMQConnectionDelegate_0_10.java | 80 +++++++++++++++++++--- 1 file changed, 69 insertions(+), 11 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 6480a0da76..8a9abcc398 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -23,6 +23,9 @@ package org.apache.qpid.client; import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + import javax.jms.ExceptionListener; import javax.jms.JMSException; import javax.jms.XASession; @@ -31,6 +34,7 @@ import org.apache.qpid.AMQException; import org.apache.qpid.AMQProtocolException; import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.client.failover.FailoverException; +import org.apache.qpid.client.failover.FailoverProtectedOperation; import org.apache.qpid.framing.ProtocolVersion; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.Session; @@ -61,11 +65,14 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec * The QpidConeection instance that is mapped with thie JMS connection. */ org.apache.qpid.transport.Connection _qpidConnection; + private ConnectionException exception = null; //--- constructor public AMQConnectionDelegate_0_10(AMQConnection conn) { _conn = conn; + _qpidConnection = new Connection(); + _qpidConnection.setConnectionListener(this); } /** @@ -129,16 +136,16 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec */ public ProtocolVersion makeBrokerConnection(BrokerDetails brokerDetail) throws IOException, AMQException { - _qpidConnection = new Connection(); try { if (_logger.isDebugEnabled()) { - _logger.debug("creating connection with broker " + " host: " + brokerDetail - .getHost() + " port: " + brokerDetail.getPort() + " virtualhost: " + _conn - .getVirtualHost() + "user name: " + _conn.getUsername() + "password: " + _conn.getPassword()); + _logger.debug("connecting to host: " + brokerDetail.getHost() + + " port: " + brokerDetail.getPort() + + " vhost: " + _conn.getVirtualHost() + + " username: " + _conn.getUsername() + + " password: " + _conn.getPassword()); } - _qpidConnection.setConnectionListener(this); _qpidConnection.connect(brokerDetail.getHost(), brokerDetail.getPort(), _conn.getVirtualHost(), _conn.getUsername(), _conn.getPassword(), brokerDetail.useSSL()); _conn._connected = true; @@ -160,8 +167,13 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec */ public void resubscribeSessions() throws JMSException, AMQException, FailoverException { - //NOT implemented as railover is handled at a lower level - throw new FailoverException("failing to reconnect during failover, operation not supported."); + List sessions = new ArrayList(_conn.getSessions().values()); + _logger.info(String.format("Resubscribing sessions = %s sessions.size=%s", sessions, sessions.size())); + for (AMQSession s : sessions) + { + ((AMQSession_0_10) s)._qpidConnection = _qpidConnection; + s.resubscribe(); + } } @@ -181,6 +193,43 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec public void exception(Connection conn, ConnectionException exc) { + if (exception != null) + { + _logger.error("previous exception", exception); + } + + exception = exc; + } + + public void closed(Connection conn) + { + ConnectionException exc = exception; + exception = null; + + ConnectionClose close = exc.getClose(); + if (close == null) + { + try + { + if (_conn.firePreFailover(false) && _conn.attemptReconnection()) + { + _qpidConnection.resume(); + + if (_conn.firePreResubscribe()) + { + _conn.resubscribeSessions(); + } + + _conn.fireFailoverComplete(); + return; + } + } + catch (Exception e) + { + _logger.error("error during failover", e); + } + } + ExceptionListener listener = _conn._exceptionListener; if (listener == null) { @@ -188,19 +237,28 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec } else { - ConnectionClose close = exc.getClose(); String code = null; if (close != null) { code = close.getReplyCode().toString(); } + JMSException ex = new JMSException(exc.getMessage(), code); ex.initCause(exc); - - _conn._exceptionListener.onException(ex); + listener.onException(ex); } } - public void closed(Connection conn) {} + public T executeRetrySupport(FailoverProtectedOperation operation) throws E + { + try + { + return operation.execute(); + } + catch (FailoverException e) + { + throw new RuntimeException(e); + } + } } -- cgit v1.2.1 From b6584aa4ff42b04827fe2c19e2879bd09efe8d58 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Tue, 4 Nov 2008 20:13:07 +0000 Subject: QPID-1430: fixed an NPE on connection close git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@711377 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 8a9abcc398..0539d2f234 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -206,7 +206,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec ConnectionException exc = exception; exception = null; - ConnectionClose close = exc.getClose(); + ConnectionClose close = (exc == null ? null : exc.getClose()); if (close == null) { try -- cgit v1.2.1 From 22bc5c3d65f45621a36c052ccb0d53aff5aa4c36 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Thu, 6 Nov 2008 18:47:46 +0000 Subject: QPID-1430: *ahem* better fix for NPE on connection close git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@711939 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 0539d2f234..30ea4dcf8d 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -206,7 +206,12 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec ConnectionException exc = exception; exception = null; - ConnectionClose close = (exc == null ? null : exc.getClose()); + if (exc == null) + { + return; + } + + ConnectionClose close = exc.getClose(); if (close == null) { try -- cgit v1.2.1 From 19c49dee096d829c2e5cc38f42c358130a772e63 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Wed, 21 Jan 2009 14:19:20 +0000 Subject: QPID-1605: added an assertion to catch acknowledgments of message-ids outside the range permitted on a session; added code to pause failover until messages from old sessions have been cleared out of the dispatcher queue git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@736316 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 30ea4dcf8d..a2e5ac9800 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -162,9 +162,15 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec return null; } - /** - * Not supported at this level. - */ + public void failoverPrep() + { + List sessions = new ArrayList(_conn.getSessions().values()); + for (AMQSession s : sessions) + { + s.failoverPrep(); + } + } + public void resubscribeSessions() throws JMSException, AMQException, FailoverException { List sessions = new ArrayList(_conn.getSessions().values()); @@ -218,6 +224,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec { if (_conn.firePreFailover(false) && _conn.attemptReconnection()) { + _conn.failoverPrep(); _qpidConnection.resume(); if (_conn.firePreResubscribe()) -- cgit v1.2.1 From 886fe779e9bad664eaec653044b4018c9a890860 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Fri, 23 Jan 2009 18:07:49 +0000 Subject: This is related to QPID-1609. Currently we only check idle state on the incomming side. In the future we plan to add code to send a heartbeat when we reach the idle state on the outgoing side. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@737125 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/client/AMQConnectionDelegate_0_10.java | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index a2e5ac9800..77860ed60c 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -22,7 +22,6 @@ package org.apache.qpid.client; import java.io.IOException; - import java.util.ArrayList; import java.util.List; @@ -31,21 +30,19 @@ import javax.jms.JMSException; import javax.jms.XASession; import org.apache.qpid.AMQException; -import org.apache.qpid.AMQProtocolException; -import org.apache.qpid.protocol.AMQConstant; +import org.apache.qpid.client.configuration.ClientProperties; import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.client.failover.FailoverProtectedOperation; import org.apache.qpid.framing.ProtocolVersion; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.Session; -import org.apache.qpid.ErrorCode; +import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.transport.Connection; import org.apache.qpid.transport.ConnectionClose; import org.apache.qpid.transport.ConnectionException; import org.apache.qpid.transport.ConnectionListener; import org.apache.qpid.transport.ProtocolVersionException; import org.apache.qpid.transport.TransportException; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -146,6 +143,17 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec " username: " + _conn.getUsername() + " password: " + _conn.getPassword()); } + + if (brokerDetail.getProperty(BrokerDetails.OPTIONS_IDLE_TIMEOUT) != null) + { + this.setIdleTimeout(Long.parseLong(brokerDetail.getProperty(BrokerDetails.OPTIONS_IDLE_TIMEOUT))); + } + else + { + // use the default value set for all connections + this.setIdleTimeout(Long.getLong(ClientProperties.IDLE_TIMEOUT_PROP_NAME,0)); + } + _qpidConnection.connect(brokerDetail.getHost(), brokerDetail.getPort(), _conn.getVirtualHost(), _conn.getUsername(), _conn.getPassword(), brokerDetail.useSSL()); _conn._connected = true; @@ -273,4 +281,8 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec } } + public void setIdleTimeout(long l) + { + _qpidConnection.setIdleTimeout(l); + } } -- cgit v1.2.1 From 217b24c7e05ac60981d3e2e7c45f3ac27674d36f Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Mon, 9 Feb 2009 05:01:28 +0000 Subject: This is related to QPID-1649 There is some code in AMQConnectionDelegate_0_10.java related to QPID-1645 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@742260 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 77860ed60c..29f1aec2f5 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -154,16 +154,21 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec this.setIdleTimeout(Long.getLong(ClientProperties.IDLE_TIMEOUT_PROP_NAME,0)); } + String saslMechs = brokerDetail.getProperty("sasl_mechs")!= null? + brokerDetail.getProperty("sasl_mechs"): + System.getProperty("qpid.sasl_mechs","PLAIN"); + _qpidConnection.connect(brokerDetail.getHost(), brokerDetail.getPort(), _conn.getVirtualHost(), - _conn.getUsername(), _conn.getPassword(), brokerDetail.useSSL()); + _conn.getUsername(), _conn.getPassword(), brokerDetail.useSSL(),saslMechs); _conn._connected = true; + _conn._failoverPolicy.attainedConnection(); } catch(ProtocolVersionException pe) { return new ProtocolVersion(pe.getMajor(), pe.getMinor()); } catch (ConnectionException e) - { + { throw new AMQException(AMQConstant.CHANNEL_ERROR, "cannot connect to broker", e); } -- cgit v1.2.1 From a7484073368b0334cd174074bc4576f031a5ebe1 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Wed, 25 Feb 2009 23:21:13 +0000 Subject: Made the various receive variants check that the server queue is empty before returning null. Also modified AMQQueueBrowser to use receiveNoWait() when browsing queues using 0-10. These changes uncovered numerous second order bugs, mostly in failover. These are also fixed. This fixes QPID-1642 and QPID-1643. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@747963 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 6 ------ 1 file changed, 6 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 29f1aec2f5..c2fb05d94e 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -239,12 +239,6 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec { _conn.failoverPrep(); _qpidConnection.resume(); - - if (_conn.firePreResubscribe()) - { - _conn.resubscribeSessions(); - } - _conn.fireFailoverComplete(); return; } -- cgit v1.2.1 From 281b5aaeb6efb3f27848207a4b846e6dd3e5f40d Mon Sep 17 00:00:00 2001 From: Aidan Skinner Date: Tue, 21 Apr 2009 15:23:17 +0000 Subject: QPID-1823: Allow recycling of channel IDs AMQConnection.getNextChannelID: add method to abstract channel id assignment, allow max to be set AMQConnectionDelegate*: add getMaxChannelID AMQConnectionDelegate_0_10: use getNextChannelID for this session-id SessionCreateTest: add test that attempts to create 65555 sessions on one connection AMQConnectionTest: add unit test for getNextChannelID SessionCreateTest takes a long, long time to run so is excluded by default git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@767185 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index c2fb05d94e..927929c94a 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -79,7 +79,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec throws JMSException { _conn.checkNotClosed(); - int channelId = _conn._idFactory.incrementAndGet(); + int channelId = _conn.getNextChannelID(); AMQSession session; try { @@ -105,7 +105,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec public XASession createXASession(int prefetchHigh, int prefetchLow) throws JMSException { _conn.checkNotClosed(); - int channelId = _conn._idFactory.incrementAndGet(); + int channelId = _conn.getNextChannelID(); XASessionImpl session; try { @@ -284,4 +284,10 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec { _qpidConnection.setIdleTimeout(l); } + + @Override + public int getMaxChannelID() + { + return Integer.MAX_VALUE; + } } -- cgit v1.2.1 From 6516117db5080ac5808db4de3439b48e7c42ccaf Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Thu, 8 Oct 2009 12:40:23 +0000 Subject: QPID-1440 : Code review changes from QPID-1289. All actioned except adding new createConsumer() method. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@823149 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 927929c94a..211f72e9ba 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -99,6 +99,18 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec return session; } + /** + * Create an XASession with default prefetch values of: + * High = MaxPrefetch + * Low = MaxPrefetch / 2 + * @return XASession + * @throws JMSException + */ + public XASession createXASession() throws JMSException + { + return createXASession((int) _conn.getMaxPrefetch(), (int) _conn.getMaxPrefetch() / 2); + } + /** * create an XA Session and start it if required. */ -- cgit v1.2.1 From 9904f496554fb9a36a8ba3b8088a78afc8d4e9e1 Mon Sep 17 00:00:00 2001 From: Aidan Skinner Date: Sun, 11 Oct 2009 19:51:53 +0000 Subject: Fix compiler compliance levels, not allowed @Override on interfaces in 1.5 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@824129 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 1 - 1 file changed, 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 211f72e9ba..4d10180667 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -297,7 +297,6 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec _qpidConnection.setIdleTimeout(l); } - @Override public int getMaxChannelID() { return Integer.MAX_VALUE; -- cgit v1.2.1 From 6f5d96325706a81a91e5bdfbdafb37a296478bf0 Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Fri, 18 Dec 2009 16:23:19 +0000 Subject: QPID-2273 : Fix Protocol Negotiation git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@892301 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 4d10180667..af21eb7ed0 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -301,4 +301,9 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec { return Integer.MAX_VALUE; } + + public ProtocolVersion getProtocolVersion() + { + return ProtocolVersion.v0_10; + } } -- cgit v1.2.1 From fd6d92c5fb399654fe65fb16d083c785f88dadb9 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Mon, 11 Jan 2010 16:11:12 +0000 Subject: This is a fix for QPID-2336 The fix allows an idle_timeout of zero to be set as the heartbeat interval with a warning message to say heartbeats are disabled. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@897922 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index af21eb7ed0..9b5277257c 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -163,7 +163,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec else { // use the default value set for all connections - this.setIdleTimeout(Long.getLong(ClientProperties.IDLE_TIMEOUT_PROP_NAME,0)); + this.setIdleTimeout(Long.getLong(ClientProperties.IDLE_TIMEOUT_PROP_NAME,ClientProperties.DEFAULT_IDLE_TIMEOUT)); } String saslMechs = brokerDetail.getProperty("sasl_mechs")!= null? -- cgit v1.2.1 From dd02cfaa3720b1b6b5cc967ffed565d10c3a6da0 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Tue, 12 Jan 2010 20:53:51 +0000 Subject: This is a fix for QPID-2174 I couldn't find any straight forward way to grab the proper ID from the SASL client. Therefore I had to use the java GSSAPI classes to create a security context to grab the ID. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@898505 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 9b5277257c..57a52ff0e2 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -173,6 +173,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec _qpidConnection.connect(brokerDetail.getHost(), brokerDetail.getPort(), _conn.getVirtualHost(), _conn.getUsername(), _conn.getPassword(), brokerDetail.useSSL(),saslMechs); _conn._connected = true; + _conn.setUsername(_qpidConnection.getUserID()); _conn._failoverPolicy.attainedConnection(); } catch(ProtocolVersionException pe) -- cgit v1.2.1 From 781629ebe94318e506567e28cd01b5666d29a819 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Mon, 18 Jan 2010 22:53:15 +0000 Subject: This is a first step towards QPID-2343 The common module also contains code for the client, and therefore contains configuration required for the client to be accessible from within the common module. Therefore the ClientProperties.java is best be placed inside the common module. The goal is to have a place holder for all configuration properties. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@900595 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 57a52ff0e2..cbae916b64 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -29,8 +29,8 @@ import javax.jms.ExceptionListener; import javax.jms.JMSException; import javax.jms.XASession; +import org.apache.configuration.ClientProperties; import org.apache.qpid.AMQException; -import org.apache.qpid.client.configuration.ClientProperties; import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.client.failover.FailoverProtectedOperation; import org.apache.qpid.framing.ProtocolVersion; -- cgit v1.2.1 From 10faf43196760585ea6cadf8fb3a8775e231969c Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Tue, 19 Jan 2010 23:28:45 +0000 Subject: Changed the setIdleTimeout method to take an int instead of a long. The socket interface takes the so_timeout as an int and also the AMQP heartbeat interval is taken as an int. This change will help simplify the code that handles heartbeats. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@901000 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index cbae916b64..a4c6263435 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -295,7 +295,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec public void setIdleTimeout(long l) { - _qpidConnection.setIdleTimeout(l); + _qpidConnection.setIdleTimeout((int)l); } public int getMaxChannelID() -- cgit v1.2.1 From 6974c985d4bb9d6dd365b304916d25c44418403e Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Thu, 21 Jan 2010 02:45:35 +0000 Subject: The commit contains fixes for QPID-2351, QPID-2350 and some ground work for QPID-2352 - Modified Connection.java to add more than one ConnectionListener. This was done to facilitate the SASL encryption patch - QPID-2352. - Changed the access modifier for getSaslClient method to "public" to allow the SaslClient to be retrieved by the SASL encryption code -QPID-2352. - Introduced ConnectionSettings object to hold all the configuration options. Previous constructor methods remains unchanged. - Modified the ClientDelegate to handle heartbeat and idelTimeout value properly. - Added support to specify config options via the connection URL - QPID-2351 - Added support to handle the heartbeat/idle_timeout options properly in the 0-10 code - QPID-2350. However once QPID-2343 is completed, the code will be further simplified. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@901506 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/client/AMQConnectionDelegate_0_10.java | 114 +++++++++++++++------ 1 file changed, 80 insertions(+), 34 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index a4c6263435..0d1a89a6c0 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -41,6 +41,7 @@ import org.apache.qpid.transport.Connection; import org.apache.qpid.transport.ConnectionClose; import org.apache.qpid.transport.ConnectionException; import org.apache.qpid.transport.ConnectionListener; +import org.apache.qpid.transport.ConnectionSettings; import org.apache.qpid.transport.ProtocolVersionException; import org.apache.qpid.transport.TransportException; import org.slf4j.Logger; @@ -69,7 +70,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec { _conn = conn; _qpidConnection = new Connection(); - _qpidConnection.setConnectionListener(this); + _qpidConnection.addConnectionListener(this); } /** @@ -149,40 +150,64 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec { if (_logger.isDebugEnabled()) { - _logger.debug("connecting to host: " + brokerDetail.getHost() + - " port: " + brokerDetail.getPort() + - " vhost: " + _conn.getVirtualHost() + - " username: " + _conn.getUsername() + - " password: " + _conn.getPassword()); + _logger.debug("connecting to host: " + brokerDetail.getHost() + + " port: " + brokerDetail.getPort() + " vhost: " + + _conn.getVirtualHost() + " username: " + + _conn.getUsername() + " password: " + + _conn.getPassword()); } - - if (brokerDetail.getProperty(BrokerDetails.OPTIONS_IDLE_TIMEOUT) != null) - { - this.setIdleTimeout(Long.parseLong(brokerDetail.getProperty(BrokerDetails.OPTIONS_IDLE_TIMEOUT))); - } - else - { - // use the default value set for all connections - this.setIdleTimeout(Long.getLong(ClientProperties.IDLE_TIMEOUT_PROP_NAME,ClientProperties.DEFAULT_IDLE_TIMEOUT)); - } - - String saslMechs = brokerDetail.getProperty("sasl_mechs")!= null? - brokerDetail.getProperty("sasl_mechs"): - System.getProperty("qpid.sasl_mechs","PLAIN"); - - _qpidConnection.connect(brokerDetail.getHost(), brokerDetail.getPort(), _conn.getVirtualHost(), - _conn.getUsername(), _conn.getPassword(), brokerDetail.useSSL(),saslMechs); + + String saslMechs = brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_MECHS) != null ? + brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_MECHS): + System.getProperty("qpid.sasl_mechs", "PLAIN"); + + // Sun SASL Kerberos client uses the + // protocol + servername as the service key. + String protocol = brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_PROTOCOL_NAME) != null ? + brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_PROTOCOL_NAME): + System.getProperty("qpid.sasl_protocol", "AMQP"); + + String saslServerName = brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_SERVER_NAME) != null ? + brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_SERVER_NAME): + System.getProperty("qpid.sasl_server_name", "localhost"); + + boolean useSSL = brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SASL_ENCRYPTION); + + boolean useSASLEncryption = brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SASL_ENCRYPTION)? + brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SASL_ENCRYPTION): + Boolean.getBoolean("qpid.sasl_encryption"); + + boolean useTcpNodelay = brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY)? + brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY): + Boolean.getBoolean("amqj.tcp_nodelay"); + + + ConnectionSettings conSettings = new ConnectionSettings(); + conSettings.setHost(brokerDetail.getHost()); + conSettings.setPort(brokerDetail.getPort()); + conSettings.setVhost(_conn.getVirtualHost()); + conSettings.setUsername(_conn.getUsername()); + conSettings.setPassword(_conn.getPassword()); + conSettings.setUseSASLEncryption(useSASLEncryption); + conSettings.setUseSSL(useSSL); + conSettings.setSaslMechs(saslMechs); + conSettings.setTcpNodelay(useTcpNodelay); + conSettings.setSaslProtocol(protocol); + conSettings.setSaslServerName(saslServerName); + conSettings.setHeartbeatInterval(getHeartbeatInterval(brokerDetail)); + + _qpidConnection.connect(conSettings); + _conn._connected = true; _conn.setUsername(_qpidConnection.getUserID()); _conn._failoverPolicy.attainedConnection(); - } - catch(ProtocolVersionException pe) + } catch (ProtocolVersionException pe) { return new ProtocolVersion(pe.getMajor(), pe.getMinor()); - } - catch (ConnectionException e) - { - throw new AMQException(AMQConstant.CHANNEL_ERROR, "cannot connect to broker", e); + } catch (ConnectionException e) + { + throw new AMQException(AMQConstant.CHANNEL_ERROR, + "cannot connect to broker", e); } return null; @@ -293,11 +318,6 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec } } - public void setIdleTimeout(long l) - { - _qpidConnection.setIdleTimeout((int)l); - } - public int getMaxChannelID() { return Integer.MAX_VALUE; @@ -307,4 +327,30 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec { return ProtocolVersion.v0_10; } + + // The idle_timeout prop is in milisecs while + // the new heartbeat prop is in secs + private int getHeartbeatInterval(BrokerDetails brokerDetail) + { + int heartbeat = 0; + if (brokerDetail.getProperty(BrokerDetails.OPTIONS_IDLE_TIMEOUT) != null) + { + _logger.warn("Broker property idle_timeout= is deprecated, please use heartbeat="); + heartbeat = Integer.parseInt(brokerDetail.getProperty(BrokerDetails.OPTIONS_IDLE_TIMEOUT))/1000; + } + else if (brokerDetail.getProperty(BrokerDetails.OPTIONS_HEARTBEAT) != null) + { + heartbeat = Integer.parseInt(brokerDetail.getProperty(BrokerDetails.OPTIONS_HEARTBEAT)); + } + else if (Integer.getInteger(ClientProperties.IDLE_TIMEOUT_PROP_NAME) != null) + { + heartbeat = Integer.getInteger(ClientProperties.IDLE_TIMEOUT_PROP_NAME)/1000; + _logger.warn("JVM arg -Didle_timeout= is deprecated, please use -Dqpid.heartbeat="); + } + else + { + heartbeat = Integer.getInteger(ClientProperties.HEARTBEAT,ClientProperties.HEARTBEAT_DEFAULT); + } + return 0; + } } -- cgit v1.2.1 From 2d7e270a3cb77934b733c53f3e17c0c1eb8b0730 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Wed, 3 Feb 2010 17:31:04 +0000 Subject: This is related to QPID-1831 I added the patch attached to the above JIRA with modifications. The modifications include integration with the address parser added by Rafi, and several refactoring and bug fixes to the original patch. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@906142 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 0d1a89a6c0..38e5b4fee0 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -29,10 +29,10 @@ import javax.jms.ExceptionListener; import javax.jms.JMSException; import javax.jms.XASession; -import org.apache.configuration.ClientProperties; import org.apache.qpid.AMQException; import org.apache.qpid.client.failover.FailoverException; import org.apache.qpid.client.failover.FailoverProtectedOperation; +import org.apache.qpid.configuration.ClientProperties; import org.apache.qpid.framing.ProtocolVersion; import org.apache.qpid.jms.BrokerDetails; import org.apache.qpid.jms.Session; -- cgit v1.2.1 From 215b2bd963f4aaa5723962e82524c76c141680e7 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Thu, 11 Feb 2010 21:15:44 +0000 Subject: Fixed an error in retrieving the SSL parameter Added a log message in IoTransport to denote successfull creation of SSL Sender and Receiver git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@909150 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 38e5b4fee0..5ad297580e 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -171,7 +171,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_SERVER_NAME): System.getProperty("qpid.sasl_server_name", "localhost"); - boolean useSSL = brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SASL_ENCRYPTION); + boolean useSSL = brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SSL); boolean useSASLEncryption = brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SASL_ENCRYPTION)? brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SASL_ENCRYPTION): -- cgit v1.2.1 From 066c7ab4a285748e824fd4dfe1a11bf4f133c29f Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Fri, 19 Mar 2010 15:56:03 +0000 Subject: Added support for QPID-2444 QPID-2446 1. You could specify ssl_verify_hostname as a Broker argument in the Connection URL to explicitly enable SSL hostname verification. 2. You could specify a per connection trust store and key store to allow each connection to use it's own client certificate. trust_store,trust_store_passowrd, key_store, key_store_password could be specified as Broker arguments in the Connection URL. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@925289 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/client/AMQConnectionDelegate_0_10.java | 121 ++++++++++++++------- 1 file changed, 83 insertions(+), 38 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 5ad297580e..9bded39af4 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -157,45 +157,9 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec + _conn.getPassword()); } - String saslMechs = brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_MECHS) != null ? - brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_MECHS): - System.getProperty("qpid.sasl_mechs", "PLAIN"); - - // Sun SASL Kerberos client uses the - // protocol + servername as the service key. - String protocol = brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_PROTOCOL_NAME) != null ? - brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_PROTOCOL_NAME): - System.getProperty("qpid.sasl_protocol", "AMQP"); - - String saslServerName = brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_SERVER_NAME) != null ? - brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_SERVER_NAME): - System.getProperty("qpid.sasl_server_name", "localhost"); - - boolean useSSL = brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SSL); - - boolean useSASLEncryption = brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SASL_ENCRYPTION)? - brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SASL_ENCRYPTION): - Boolean.getBoolean("qpid.sasl_encryption"); - - boolean useTcpNodelay = brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY)? - brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY): - Boolean.getBoolean("amqj.tcp_nodelay"); - - ConnectionSettings conSettings = new ConnectionSettings(); - conSettings.setHost(brokerDetail.getHost()); - conSettings.setPort(brokerDetail.getPort()); - conSettings.setVhost(_conn.getVirtualHost()); - conSettings.setUsername(_conn.getUsername()); - conSettings.setPassword(_conn.getPassword()); - conSettings.setUseSASLEncryption(useSASLEncryption); - conSettings.setUseSSL(useSSL); - conSettings.setSaslMechs(saslMechs); - conSettings.setTcpNodelay(useTcpNodelay); - conSettings.setSaslProtocol(protocol); - conSettings.setSaslServerName(saslServerName); - conSettings.setHeartbeatInterval(getHeartbeatInterval(brokerDetail)); - + retriveConnectionSettings(conSettings,brokerDetail); + _qpidConnection.connect(conSettings); _conn._connected = true; @@ -328,6 +292,87 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec return ProtocolVersion.v0_10; } + private void retriveConnectionSettings(ConnectionSettings conSettings, BrokerDetails brokerDetail) + { + + conSettings.setHost(brokerDetail.getHost()); + conSettings.setPort(brokerDetail.getPort()); + conSettings.setVhost(_conn.getVirtualHost()); + conSettings.setUsername(_conn.getUsername()); + conSettings.setPassword(_conn.getPassword()); + + // ------------ sasl options --------------- + if (brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_MECHS) != null) + { + conSettings.setSaslMechs( + brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_MECHS)); + } + + // Sun SASL Kerberos client uses the + // protocol + servername as the service key. + + if (brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_PROTOCOL_NAME) != null) + { + conSettings.setSaslProtocol( + brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_PROTOCOL_NAME)); + } + + + if (brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_SERVER_NAME) != null) + { + conSettings.setSaslServerName( + brokerDetail.getProperty(BrokerDetails.OPTIONS_SASL_SERVER_NAME)); + } + + conSettings.setUseSASLEncryption( + brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SASL_ENCRYPTION)); + + // ------------- ssl options --------------------- + conSettings.setUseSSL(brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SSL)); + + if (brokerDetail.getProperty(BrokerDetails.OPTIONS_TRUST_STORE) != null) + { + conSettings.setTrustStorePath( + brokerDetail.getProperty(BrokerDetails.OPTIONS_TRUST_STORE)); + } + + if (brokerDetail.getProperty(BrokerDetails.OPTIONS_TRUST_STORE_PASSWORD) != null) + { + conSettings.setTrustStorePassword( + brokerDetail.getProperty(BrokerDetails.OPTIONS_TRUST_STORE_PASSWORD)); + } + + if (brokerDetail.getProperty(BrokerDetails.OPTIONS_KEY_STORE) != null) + { + conSettings.setKeyStorePath( + brokerDetail.getProperty(BrokerDetails.OPTIONS_KEY_STORE)); + } + + if (brokerDetail.getProperty(BrokerDetails.OPTIONS_KEY_STORE_PASSWORD) != null) + { + conSettings.setKeyStorePassword( + brokerDetail.getProperty(BrokerDetails.OPTIONS_KEY_STORE_PASSWORD)); + } + + if (brokerDetail.getProperty(BrokerDetails.OPTIONS_SSL_CERT_ALIAS) != null) + { + conSettings.setCertAlias( + brokerDetail.getProperty(BrokerDetails.OPTIONS_SSL_CERT_ALIAS)); + } + // ---------------------------- + + conSettings.setVerifyHostname(brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SSL_VERIFY_HOSTNAME)); + + + if (brokerDetail.getProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY) != null) + { + conSettings.setTcpNodelay( + brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY)); + } + + conSettings.setHeartbeatInterval(getHeartbeatInterval(brokerDetail)); + } + // The idle_timeout prop is in milisecs while // the new heartbeat prop is in secs private int getHeartbeatInterval(BrokerDetails brokerDetail) -- cgit v1.2.1 From a72470efc052426431707cad02bbe611e1eaa53f Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Mon, 22 Mar 2010 22:38:31 +0000 Subject: This is related to QPID-2447 Added QpidClientX509KeyManager (a customer KeyManager) which will return the ssl_client_alias specified in the Connection URL. Note the alias here is actually the certificate name and not the alias used in the keytool. I also fixed a minor bug in SSLUtil to retrive the identitiy of the local certificate instead of the peer's certificate. Added a test for the above JIRA. Added AMQTestConnection_0_10 which allows the SecurityLayer to be exposed for testing purposes. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@926380 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 9bded39af4..4717a9495b 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -398,4 +398,9 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec } return 0; } + + protected org.apache.qpid.transport.Connection getQpidConnection() + { + return _qpidConnection; + } } -- cgit v1.2.1 From ce37ea331edac07423334e7052af33b7713e29ae Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Thu, 6 May 2010 00:10:07 +0000 Subject: The heartbeat wasn't being set properly and these mistakes went uncaught due to lack of proper test. I have added a test case to AMQConnectionTest called testHeartBeat. This test fails once in a while even when I have an external script to clean the broker instance. It seems once it's wedged with kill -STOP, it somestimes doesn't get cleaned up properly with kill -9. Despite the occasional failure, I think it's worth to have this test as a lot of our users rely on heartbeat functionality. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@941553 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 4717a9495b..32c7bb33b0 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -396,7 +396,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec { heartbeat = Integer.getInteger(ClientProperties.HEARTBEAT,ClientProperties.HEARTBEAT_DEFAULT); } - return 0; + return heartbeat; } protected org.apache.qpid.transport.Connection getQpidConnection() -- cgit v1.2.1 From 221f0c66dce3d8b0fd2dff1c09e8959a36cc8e28 Mon Sep 17 00:00:00 2001 From: Rajith Muditha Attapattu Date: Tue, 11 May 2010 17:35:08 +0000 Subject: Commiting a patch by Emmanuel Bourg attached to QPID-2594 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@943200 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 1 + 1 file changed, 1 insertion(+) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 32c7bb33b0..8f67274f53 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -265,6 +265,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec } JMSException ex = new JMSException(exc.getMessage(), code); + ex.setLinkedException(exc); ex.initCause(exc); listener.onException(ex); } -- cgit v1.2.1 From 4d02e072b47235cfb56635412aea6a4ed30e6869 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Thu, 22 Jul 2010 16:09:40 +0000 Subject: QPID-2657: Make Exceptions propagate to client for 0-10 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@966722 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/client/AMQConnectionDelegate_0_10.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 8f67274f53..2ee0a86e7c 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -165,13 +165,20 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec _conn._connected = true; _conn.setUsername(_qpidConnection.getUserID()); _conn._failoverPolicy.attainedConnection(); - } catch (ProtocolVersionException pe) + } + catch (ProtocolVersionException pe) { return new ProtocolVersion(pe.getMajor(), pe.getMinor()); - } catch (ConnectionException e) + } + catch (ConnectionException ce) { - throw new AMQException(AMQConstant.CHANNEL_ERROR, - "cannot connect to broker", e); + AMQConstant code = AMQConstant.REPLY_SUCCESS; + if (ce.getClose() != null && ce.getClose().getReplyCode() != null) + { + code = AMQConstant.getConstant(ce.getClose().getReplyCode().getValue()); + } + String msg = "Cannot connect to broker: " + ce.getMessage(); + throw new AMQException(code, msg, ce); } return null; -- cgit v1.2.1 From a5b1a1073e2596da8b5fbcd24769aec87107d212 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Sun, 3 Oct 2010 16:00:24 +0000 Subject: QPID-2835 Implement CON Operational Logging on 0-10 Committed patch from SorinS git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1003984 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 2ee0a86e7c..adfd178ec3 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -23,7 +23,9 @@ package org.apache.qpid.client; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.jms.ExceptionListener; import javax.jms.JMSException; @@ -159,7 +161,6 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec ConnectionSettings conSettings = new ConnectionSettings(); retriveConnectionSettings(conSettings,brokerDetail); - _qpidConnection.connect(conSettings); _conn._connected = true; @@ -371,6 +372,17 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec conSettings.setVerifyHostname(brokerDetail.getBooleanProperty(BrokerDetails.OPTIONS_SSL_VERIFY_HOSTNAME)); + // Pass client name from connection URL + Map clientProps = new HashMap(); + try + { + clientProps.put("clientName", _conn.getClientID()); + conSettings.setClientProperties(clientProps); + } + catch (JMSException e) + { + // Ignore + } if (brokerDetail.getProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY) != null) { -- cgit v1.2.1 From d79e40667ca674d9c206b43f1ffbb1dcbecfc7ff Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Fri, 4 Feb 2011 16:15:27 +0000 Subject: QPID-3029: actually set and negotiate the supported max num channels per connection during connection handshake. Enable/make the 0-10 client use channel numbers 0 to N-1 in line with the spec, rather than 1-N. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1067210 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/client/AMQConnectionDelegate_0_10.java | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index adfd178ec3..4b4417b6ef 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -37,6 +37,7 @@ import org.apache.qpid.client.failover.FailoverProtectedOperation; import org.apache.qpid.configuration.ClientProperties; import org.apache.qpid.framing.ProtocolVersion; import org.apache.qpid.jms.BrokerDetails; +import org.apache.qpid.jms.ChannelLimitReachedException; import org.apache.qpid.jms.Session; import org.apache.qpid.protocol.AMQConstant; import org.apache.qpid.transport.Connection; @@ -82,6 +83,12 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec throws JMSException { _conn.checkNotClosed(); + + if (_conn.channelLimitReached()) + { + throw new ChannelLimitReachedException(_conn.getMaximumChannelCount()); + } + int channelId = _conn.getNextChannelID(); AMQSession session; try @@ -120,6 +127,12 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec public XASession createXASession(int prefetchHigh, int prefetchLow) throws JMSException { _conn.checkNotClosed(); + + if (_conn.channelLimitReached()) + { + throw new ChannelLimitReachedException(_conn.getMaximumChannelCount()); + } + int channelId = _conn.getNextChannelID(); XASessionImpl session; try @@ -165,6 +178,7 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec _conn._connected = true; _conn.setUsername(_qpidConnection.getUserID()); + _conn.setMaximumChannelCount(_qpidConnection.getChannelMax()); _conn._failoverPolicy.attainedConnection(); } catch (ProtocolVersionException pe) @@ -293,7 +307,13 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec public int getMaxChannelID() { - return Integer.MAX_VALUE; + //For a negotiated channelMax N, there are channels 0 to N-1 available. + return _qpidConnection.getChannelMax() - 1; + } + + public int getMinChannelID() + { + return Connection.MIN_USABLE_CHANNEL_NUM; } public ProtocolVersion getProtocolVersion() -- cgit v1.2.1 From 4a6d824f6344a4978f3be22264614e0fc34ab6dd Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Thu, 17 Feb 2011 14:50:28 +0000 Subject: QPID-3008: Fix failover behaviour in 0-10 for QueueBrowserAutoAckTest git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1071631 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 4b4417b6ef..b0bd8f8e97 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.CountDownLatch; import javax.jms.ExceptionListener; import javax.jms.JMSException; @@ -211,15 +212,13 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec public void resubscribeSessions() throws JMSException, AMQException, FailoverException { List sessions = new ArrayList(_conn.getSessions().values()); - _logger.info(String.format("Resubscribing sessions = %s sessions.size=%s", sessions, sessions.size())); + _logger.info(String.format("Resubscribing sessions = %s sessions.size=%d", sessions, sessions.size())); for (AMQSession s : sessions) { - ((AMQSession_0_10) s)._qpidConnection = _qpidConnection; s.resubscribe(); } } - public void closeConnection(long timeout) throws JMSException, AMQException { try @@ -257,12 +256,14 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec ConnectionClose close = exc.getClose(); if (close == null) { + _conn.getProtocolHandler().setFailoverLatch(new CountDownLatch(1)); + try { if (_conn.firePreFailover(false) && _conn.attemptReconnection()) { _conn.failoverPrep(); - _qpidConnection.resume(); + _conn.resubscribeSessions(); _conn.fireFailoverComplete(); return; } @@ -271,6 +272,11 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec { _logger.error("error during failover", e); } + finally + { + _conn.getProtocolHandler().getFailoverLatch().countDown(); + _conn.getProtocolHandler().setFailoverLatch(null); + } } ExceptionListener listener = _conn._exceptionListener; -- cgit v1.2.1 From beecf10566322045174797782b6f2828432d2671 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 1 Mar 2011 16:11:19 +0000 Subject: QPID-2979: Added SASL client plugin for ANONYMOUS; added call to register available plugins for 0-10 codepath. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1075871 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index b0bd8f8e97..891819c227 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -69,6 +69,12 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec org.apache.qpid.transport.Connection _qpidConnection; private ConnectionException exception = null; + static + { + // Register any configured SASL client factories. + org.apache.qpid.client.security.DynamicSaslRegistrar.registerSaslProviders(); + } + //--- constructor public AMQConnectionDelegate_0_10(AMQConnection conn) { -- cgit v1.2.1 From bb99ca79e611db78b50171336f8db7bcd0ac2633 Mon Sep 17 00:00:00 2001 From: Andrew Donald Kennedy Date: Fri, 1 Apr 2011 20:47:59 +0000 Subject: QPID-3177: Add missing call to connection resume git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1087890 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java') diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java index 891819c227..d50c9e16fe 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java @@ -217,6 +217,8 @@ public class AMQConnectionDelegate_0_10 implements AMQConnectionDelegate, Connec public void resubscribeSessions() throws JMSException, AMQException, FailoverException { + _logger.info("Resuming connection"); + getQpidConnection().resume(); List sessions = new ArrayList(_conn.getSessions().values()); _logger.info(String.format("Resubscribing sessions = %s sessions.size=%d", sessions, sessions.size())); for (AMQSession s : sessions) -- cgit v1.2.1