diff options
15 files changed, 877 insertions, 0 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/FieldTable.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/FieldTable.java new file mode 100644 index 0000000000..d79794e98d --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/FieldTable.java @@ -0,0 +1,28 @@ +/* + * 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. + */ +package org.apache.qpid.nclient; + +/** + * Created by Arnaud Simon + * Date: 23-Jul-2007 + * Time: 09:47:32 + */ +public interface FieldTable +{ +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/exception/QpidException.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/exception/QpidException.java new file mode 100644 index 0000000000..cacac98cc0 --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/exception/QpidException.java @@ -0,0 +1,48 @@ +/* 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. + */ +package org.apache.qpid.nclient.exception; + +/** + * Created by Arnaud Simon + * Date: 20-Jul-2007 + * Time: 10:56:55 + */ +public class QpidException extends Exception +{ + /** + * This exception error code. + * <p> This error code is used for internationalisation purpose. + * <p> This error code is set from the AMQP ones. + * <TODO> So we may want to use the AMQP error code directly. + */ + String _errorCode; + + /** + * Constructor for a Qpid Exception. + * <p> This is the only provided constructor and the parameters have to be set to null when + * they are unknown. + * @param message A description of the reason of this exception . + * @param errorCode A string specifyin the error code of this exception. + * @param cause The linked Execption. + */ + public QpidException(String message, String errorCode, Throwable cause) + { + super(message, cause); + _errorCode = errorCode; + } +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/Connection.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/Connection.java new file mode 100644 index 0000000000..fd59b95c0f --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/Connection.java @@ -0,0 +1,81 @@ +/* + * 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. + */ +package org.apache.qpid.nclient.qpidapi; + +import org.apache.qpid.nclient.exception.QpidException; + +import java.net.URL; + +/** + * This represents a physical connection to a broker. + * <p/> + * Created by Arnaud Simon + * Date: 20-Jul-2007 + * Time: 09:34:15 + */ +public interface Connection +{ + /** + * Establish the connection with the broker identified by the provided URL. + * + * @param url The URL of the broker. + * @throws QpidException If the communication layer fails to connect with the broker. + */ + public void connect(URL url) + throws + QpidException; + + /** + * Close this connection. + * + * @throws QpidException if the communication layer fails to close the connection. + */ + public void close() + throws + QpidException; + + + /** + * Create a session for this connection. + * <p> The retuned session is suspended + * (i.e. this session is not attached with an underlying channel) + * + * @param expiryInSeconds Expiry time expressed in seconds, if the value is <= 0 then the session does not expire. + * @return A Newly created (suspended) session. + * @throws QpidException If the connection fails to create a session due to some internal error. + */ + public Session createSession(int expiryInSeconds) + throws + QpidException; + + /** + * Create a DtxSession for this connection. + * <p> A Dtx Session must be used when resources have to be manipulated as + * part of a global transaction. + * <p> The retuned DtxSession is suspended + * (i.e. this session is not attached with an underlying channel) + * + * @param expiryInSeconds Expiry time expressed in seconds, if the value is <= 0 then the session does not expire. + * @return A Newly created (suspended) DtxSession. + * @throws QpidException If the connection fails to create a DtxSession due to some internal error. + */ + public DtxSession createDTXSession(int expiryInSeconds) + throws + QpidException; +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/CreateReceiverOption.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/CreateReceiverOption.java new file mode 100644 index 0000000000..4d8315c33b --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/CreateReceiverOption.java @@ -0,0 +1,16 @@ +package org.apache.qpid.nclient.qpidapi; + +/** + * Enumeration of the options available when creating a receiver + * + * Created by Arnaud Simon + * Date: 20-Jul-2007 + * Time: 09:43:31 + */ +public enum CreateReceiverOption +{ + NO_LOCAL, + EXCLUSIVE, + NO_ACQUIRE, + CONFIRME; +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/DeclareExchangeOption.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/DeclareExchangeOption.java new file mode 100644 index 0000000000..8674792252 --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/DeclareExchangeOption.java @@ -0,0 +1,17 @@ +package org.apache.qpid.nclient.qpidapi; + +/** + * Enumeration of the options available when declaring an exchange + * + * Created by Arnaud Simon + * Date: 20-Jul-2007 + * Time: 09:44:52 + */ +public enum DeclareExchangeOption +{ + AUTO_DELETE, + DURABLE, + INTERNAL, + NOWAIT, + PASSIVE; +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/DeleteExchangeOption.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/DeleteExchangeOption.java new file mode 100644 index 0000000000..188d665c8c --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/DeleteExchangeOption.java @@ -0,0 +1,12 @@ +package org.apache.qpid.nclient.qpidapi; + +/** + * Created by Arnaud Simon + * Date: 23-Jul-2007 + * Time: 12:55:55 + */ +public enum DeleteExchangeOption +{ + IF_UNUSED, + NOWAIT; +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/DeleteQueueOption.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/DeleteQueueOption.java new file mode 100644 index 0000000000..0062218a70 --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/DeleteQueueOption.java @@ -0,0 +1,13 @@ +package org.apache.qpid.nclient.qpidapi; + +/** + * Created by Arnaud Simon + * Date: 23-Jul-2007 + * Time: 12:44:43 + */ +public enum DeleteQueueOption +{ + IF_EMPTY, + IF_UNUSED, + NO_WAIT; +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/DtxSession.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/DtxSession.java new file mode 100644 index 0000000000..c361fdcf82 --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/DtxSession.java @@ -0,0 +1,43 @@ +/* + * 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. + */ +package org.apache.qpid.nclient.qpidapi; + +import org.apache.qpid.nclient.exception.QpidException; + +/** + * This session’s resources are control under the scope of a distributed transaction. + * + * Created by Arnaud Simon + * Date: 20-Jul-2007 + * Time: 09:39:11 + */ +public interface DtxSession extends Session +{ + + /** + * Get the XA resource associated with this session. + * + * @return this session XA resource. + * @throws QpidException If the session fails to retrieve its associated XA resource + * due to some error. + */ + public javax.transaction.xa.XAResource getDTXResource() + throws + QpidException; +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/Message.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/Message.java new file mode 100644 index 0000000000..6974d0cae2 --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/Message.java @@ -0,0 +1,126 @@ +/* + * 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. + */ +package org.apache.qpid.nclient.qpidapi; + + +import org.apache.qpid.nclient.FieldTable; +import org.apache.qpid.nclient.exception.QpidException; + +import java.nio.ByteBuffer; + +/** + * A message is sent and received by resources. It is composed of a set of header and a payload. + * <p/> + * Created by Arnaud Simon + * Date: 20-Jul-2007 + * Time: 09:40:49 + */ +public interface Message +{ + /** + * Get this message auto-allocated messageID. + * + * @return This message ID. + */ + public long getMessageID(); + + /** + * Set this message headers + * <p> Previous headers are reset. + * + * @param headers The message headers as a field table. + * @see FieldTable + */ + public void setHeaders(FieldTable headers); + + /** + * Access to this message headers. + * + * @return This message headers as a field table. + */ + public FieldTable getHeaders(); + + /** + * Set this message payload. + * + * @param buffer This message payload. + */ + public void setBody(ByteBuffer buffer); + + /** + * Access this message body. + * + * @return The payload of this message. + */ + public ByteBuffer getBody(); + + /** + * Acknowledge the receipt of this message. + * <p>The message must have been previously acquired either by receiving it in + * pre-acquire mode or by explicitly acquiring it. + * + * @throws QpidException If the acknowledgement of the message fails due to some error. + * @throws IllegalStateException If this messages is not acquired. + */ + public void acknowledge() + throws + QpidException, + IllegalStateException; + + /** + * Acknowledge the receipt of an acquired messages which IDs are within + * the interval [this.messageID, message.messageID] + * + * @param message The last message to be acknowledged. + * @throws QpidException If the acknowledgement of this set of messages fails due to some error. + * @throws IllegalStateException If some messages are not acquired. + */ + public void acknowledge(Message message) + throws + QpidException, + IllegalStateException; + + /** + * Reject a previously acquired message. + * <p> A rejected message will not be delivered to any receiver + * and may be either discarded or moved to the broker dead letter queue. + * + * @throws QpidException If this message cannot be rejected dus to some error + * @throws IllegalStateException If this message is not acquired. + */ + public void reject() + throws + QpidException, + IllegalStateException; + + /** + * Try to acquire this message hence releasing it form the queue. This means that once acknowledged, + * this message will not be delivered to any other receiver. + * <p> As this message may have been consumed by another receiver, message acquisition can fail. + * The outcome of the acquisition is returned as a Boolean. + * + * @return True if the message is successfully acquired, False otherwise. + * @throws QpidException If this message cannot be acquired dus to some error + * @throws IllegalStateException If this message has already been acquired. + */ + public boolean acquire() + throws + QpidException, + IllegalStateException; +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/MessageListener.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/MessageListener.java new file mode 100644 index 0000000000..d607d0a3c2 --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/MessageListener.java @@ -0,0 +1,36 @@ +/* + * 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. + */ +package org.apache.qpid.nclient.qpidapi; + +/** + * MessageListeners are used to asynchronously receive messages. + * + * Created by Arnaud Simon + * Date: 2o-Jul-2007 + * Time: 09:42:52 + */ +public interface MessageListener +{ + /** + * Deliver a message to the listener. + * + * @param message The message delivered to the listner. + */ + public void onMessage(Message message); +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/MessageReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/MessageReceiver.java new file mode 100644 index 0000000000..6592857b2e --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/MessageReceiver.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.qpid.nclient.qpidapi; + +import org.apache.qpid.nclient.exception.QpidException; + +import java.util.Set; + +/** + * Used to receive messages from a queue + * + * <p/> + * Created by Arnaud Simon + * Date: 20-Jul-2007 + * Time: 09:42:37 + */ +public interface MessageReceiver extends Resource +{ + /** + * Get this receiver options. + * + * @return This receiver set of options. + */ + public Set<CreateReceiverOption> getOptions(); + + /** + * Receive a message form this receiver queue. + * <p> If the timeout is less or equal than 0 then this operation is blocking. + * Otherwise it blocks until a message arrives, the timeout expires, or this receiver is closed. + * <p> To receive messages, a receiver must be started. + * + * @param timeout The timeout value (in milliseconds). + * @return A message or null if timeout expires or this receiver is concurrently closed. + * @throws QpidException If this receiver fails to receive a message due to some error. + * @throws IllegalStateException If this receiver is closed, not started or a MessageListener is set. + */ + public Message receive(long timeout) + throws + QpidException, + IllegalStateException; + + /** + * Stop the delivery of messages to this receiver. + * + * @throws QpidException If this receiver fails to be stopped due to some error. + * @throws IllegalStateException If this receiver is closed or already stopped. + */ + public void stop() + throws + QpidException, + IllegalStateException; + + /** + * Start the delivery of messages to this receiver. + * + * @throws QpidException If this receiver fails to be started due to some error. + * @throws IllegalStateException If this receiver is closed or already started. + */ + public void start() + throws + QpidException, + IllegalStateException; + + /** + * Set the receiver’s MessageListener. + * Setting the message listener to null is the equivalent of un-setting the message + * listener for this receiver. + * <p> Once a message listener is set, a receiver cannot receive messages through its + * receive method. + * + * @param listener The message listner. + * @throws QpidException If this receiver fails to set the message listner due to some error. + * @throws IllegalStateException If this receiver is closed. + */ + public void setAsynchronous(MessageListener listener) + throws + QpidException, + IllegalStateException; +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/MessageSender.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/MessageSender.java new file mode 100644 index 0000000000..cbe1443798 --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/MessageSender.java @@ -0,0 +1,44 @@ +/* + * 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. + */ +package org.apache.qpid.nclient.qpidapi; + +import org.apache.qpid.nclient.exception.QpidException; + +/** + * A sender is used to send message to its queue. + * + * Created by Arnaud Simon + * Date: 22-Jul-2007 + * Time: 09:41:58 + */ +public interface MessageSender extends Resource +{ + + /** + * Sends a message to this sender queue. + * + * @param message The message to be sent + * @param inline //TODO + * @throws QpidException If the sender fails to send the message due to some error. + * @throws IllegalStateException If this sender was closed or its session suspended. + */ + public void send(Message message, boolean inline) throws + QpidException, + IllegalStateException; +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/Resource.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/Resource.java new file mode 100644 index 0000000000..29965e0045 --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/Resource.java @@ -0,0 +1,54 @@ +/* + * 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. + */ +package org.apache.qpid.nclient.qpidapi; + +import org.apache.qpid.nclient.exception.QpidException; + +/** + * A Resource is associated with a session and can be independently closed. + * + * Created by Arnaud Simon + * Date: 21-Jul-2007 + * Time: 09:41:30 + */ +public interface Resource +{ + + /** + * Close this resource. + * + * @throws QpidException If the session fails to close this resource due to some error + */ + public void close() throws + QpidException; + + /** + * Get this resource session. + * + * @return This resource's session. + */ + public Session getSession(); + + /** + * Get the queue name to which this resource is tied. + * + * @return The queue name of this resource. + */ + public String getQueueNAme(); +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/Session.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/Session.java new file mode 100644 index 0000000000..24e47a7657 --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/Session.java @@ -0,0 +1,247 @@ +/* + * 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. + */ +package org.apache.qpid.nclient.qpidapi; + +import org.apache.qpid.nclient.exception.QpidException; + +/** + * A session is associated with a connection. + * <p> When created a Session is not attached with an underlying channel. Unsuspended a Session is + * equivalent to attaching a communication channel that can be used to communicate with the broker. + * <p/> + * Created by Arnaud Simon + * Date: 20-Jul-2007 + * Time: 09:36:24 + */ +public interface Session +{ + /** + * Close this session and any associated resources. + * + * @throws QpidException If the communication layer fails to close this session or if an internal error happens + * when closing this session resources. . + */ + public void close() + throws + QpidException; + + /** + * Suspend this session resulting in interrupting the traffic with the broker. + * When a session is suspend any operation of this session and of the associated resources is unavailable. + * + * @throws QpidException If the communication layer fails to suspend this session + */ + public void suspend() + throws + QpidException; + + /** + * Unsuspended a Session is equivalent to attaching a communication channel that can be used to + * communicate with the broker. All the operations of this session and of the associated resources + * are made available. + * + * @throws QpidException If the communication layer fails to unsuspend this session + */ + public void unsuspend() + throws + QpidException; + + /** + * Create a message sender for sending messages to queue queueName. + * + * @param queueName The queue this sender is sending messages. + * @return A sender for queue queueName + * @throws QpidException If the session fails to create the sended due to some error + */ + public MessageSender createSender(String queueName) + throws + QpidException; + //Todo: Do we need to define more specific exception like queue name not valid? + + /** + * Create a message receiver for receiving messages from queue queueName. + * <p> see available options: {@link CreateReceiverOption} + * <p> When non of the options are set then the receiver is created with: + * <ul> + * <li> no_local = false + * <li> non exclusive + * <li> pre-acquire mode + * <li> no confirmation + * </ul> + * + * @param queueName The queue this receiver is receiving messages from. + * @param options Set of Options. + * @return A receiver for queue queueName. + * @throws QpidException If the session fails to create the receiver due to some error. + * @see CreateReceiverOption + */ + public MessageReceiver createReceiver(String queueName, CreateReceiverOption... options) + throws + QpidException; + //Todo: Do we need to define more specific exceptions like queue name not valid? + + /** + * Commit the receipt and the delivery of all messages exchanged by this session resources. + * + * @throws QpidException If the session fails to commit due to some error. + * @throws IllegalStateException If this session is not transacted. + */ + public void commit() + throws + QpidException, + IllegalStateException; + + /** + * Rollback the receipt and the delivery of all messages exchanged by this session resources. + * + * @throws QpidException If the session fails to rollback due to some error. + * @throws IllegalStateException If this session is not transacted. + */ + public void rollback() + throws + QpidException, + IllegalStateException; + + /** + * Set this session as transacted. + * <p> This operation is irreversible. + * + * @throws QpidException If the session fail to be transacted due to some error. + * @throws IllegalStateException If this session is already transacted. + */ + public void setTransacted() + throws + QpidException, + IllegalStateException; + + /** + * Declare a queue of name queueName + * <p> see available options: {@link declareQueueOption} + * <p> When non of the options are set then the receiver is created with: + * <ul> + * <li> auto_delete = false + * <li> non-durable + * <li> non-exccusive + * <li> nowait = false + * <li> not passive + * </ul> + * + * @param queueName The name of the delcared queue. + * @param options Set of Options. + * @throws QpidException If the session fails to declare the queue due to some error. + * @see declareQueueOption + */ + public void declareQueue(String queueName, declareQueueOption... options) + throws + QpidException; + //Todo: Do we need to define more specific exceptions like queue name already exist? + + /** + * Bind a queue with an exchange. + * + * @param queueName The queue to be bound. + * @param exchangeName The exchange name. + * @param routingKey The routing key. + * @param nowait nowait + * @throws QpidException If the session fails to bind the queue due to some error. + */ + public void bindQueue(String queueName, String exchangeName, String routingKey, boolean nowait) + throws + QpidException; + //Todo: Do we need to define more specific exceptions like exchange does not exist? + + /** + * Unbind a queue from an exchange. + * + * @param queueName The queue to be unbound. + * @param exchangeName The exchange name. + * @param routingKey The routing key. + * @throws QpidException If the session fails to unbind the queue due to some error. + */ + public void unbindQueue(String queueName, String exchangeName, String routingKey) + throws + QpidException; + //Todo: Do we need to define more specific exceptions like exchange does not exist? + + /** + * Purge a queue. i.e. delete all enqueued messages + * TODO: Define the exact semantic i.e. are message sent to a dead letter queue? + * + * @param queueName The queue to be purged + * @param nowait nowait + * @throws QpidException If the session fails to purge the queue due to some error. + */ + public void purgeQueue(String queueName, boolean nowait) + throws + QpidException; + + /** + * Delet a queue. + * <p> see available options: {@link DeleteQueueOption} + * <p> When non of the options are set then The queue is immediately deleted even + * if it still contains messages or if ti is used by another resource. + * + * @param queueName The name of the queue to be deleted + * @param options Set of options + * @throws QpidException If the session fails to delete the queue due to some error. + * @see DeleteQueueOption + */ + public void deleteQueue(String queueName, DeleteQueueOption options) + throws + QpidException; + + /** + * Declare an exchange. + * <p> see available options: {@link DeclareExchangeOption} + * <p> When non of the options are set then the exchange is declared with: + * <ul> + * <li> auto_delete = false + * <li> non-durable + * <li> internal = false + * <li> nowait = false + * <li> not passive + * </ul> + * + * @param exchangeName The exchange name. + * @param exchangeClass The fully qualified name of the exchange class. + * @param options Set of options. + * @throws QpidException If the session fails to declare the exchange due to some error. + * @see DeclareExchangeOption + */ + public void declareExchange(String exchangeName, String exchangeClass, DeclareExchangeOption... options) + throws + QpidException; + //Todo: Do we need to define more specific exceptions like exchange already exist? + + /** + * Delete an exchange. + * <p> see available options: {@link DeclareExchangeOption} + * <p> When non of the options are set then the exchange + * Immediately deleted even if it is used by another resources. + * + * @param exchangeName The name of exchange to be deleted. + * @param options Set of options. + * @throws QpidException If the session fails to delete the exchange due to some error. + * @see DeleteExchangeOption + */ + public void deleteExchange(String exchangeName, DeleteExchangeOption... options) + throws + QpidException; + //Todo: Do we need to define more specific exceptions like exchange does not exist? +} diff --git a/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/declareQueueOption.java b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/declareQueueOption.java new file mode 100644 index 0000000000..5eb3b7927a --- /dev/null +++ b/qpid/java/common/src/main/java/org/apache/qpid/nclient/qpidapi/declareQueueOption.java @@ -0,0 +1,17 @@ +package org.apache.qpid.nclient.qpidapi; + +/** + * Enumeration of the options available when declaring a queue + * + * Created by Arnaud Simon + * Date: 23-Jul-2007 + * Time: 09:44:36 + */ +public enum declareQueueOption +{ + AUTO_DELETE, + DURABLE, + EXCLUSIVE, + NOWAIT, + PASSIVE; +} |