summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Simon <arnaudsimon@apache.org>2007-09-17 12:07:56 +0000
committerArnaud Simon <arnaudsimon@apache.org>2007-09-17 12:07:56 +0000
commit3109efbcda2018811b8f6a796f779871585e53be (patch)
tree8a6299bba6fc346e76b951751673cc27e9b6d458
parent4bb64ecababf9bbbeaf197b99bce71c5f4309c77 (diff)
downloadqpid-python-3109efbcda2018811b8f6a796f779871585e53be.tar.gz
0_10 implementation
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@576388 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java78
1 files changed, 70 insertions, 8 deletions
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java b/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
index 8213182907..42d67b0cd3 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_0_10.java
+++ b/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.");
}
}