public abstract class AMQSession<C extends BasicMessageConsumer,P extends BasicMessageProducer> extends Closeable implements Session, javax.jms.QueueSession, javax.jms.TopicSession
Modifier and Type | Class and Description |
---|---|
static interface |
AMQSession.Dispatchable |
Modifier and Type | Field and Description |
---|---|
protected boolean |
DAEMON_DISPATCHER_THREAD
Flag indicating to start dispatcher as a daemon thread
|
static String |
DISPATCHER_SHUTDOWN_TIMEOUT_MS
System property to configure dispatcher shutdown timeout in milliseconds.
|
static String |
DISPATCHER_SHUTDOWN_TIMEOUT_MS_DEFAULT
Dispatcher shutdown timeout default setting.
|
static String |
IMMEDIATE_PREFETCH
System property to enable immediate message prefetching.
|
static String |
IMMEDIATE_PREFETCH_DEFAULT
Immediate message prefetch default.
|
static String |
STRICT_AMQP
System property to enable strict AMQP compliance.
|
static String |
STRICT_AMQP_DEFAULT
Strict AMQP default setting.
|
static String |
STRICT_AMQP_FATAL
System property to enable failure if strict AMQP compliance is violated.
|
static String |
STRICT_AMQP_FATAL_DEFAULT
Strict AMQP failure default.
|
NO_ACKNOWLEDGE, PRE_ACKNOWLEDGE
Modifier | Constructor and Description |
---|---|
protected |
AMQSession(AMQConnection con,
int channelId,
boolean transacted,
int acknowledgeMode,
int defaultPrefetchHighMark,
int defaultPrefetchLowMark)
Creates a new session on a connection.
|
Modifier and Type | Method and Description |
---|---|
void |
acknowledge()
Acknowledges all unacknowledged messages on the session, for all message consumers on the session.
|
protected abstract void |
acknowledgeImpl() |
abstract void |
acknowledgeMessage(long deliveryTag,
boolean multiple)
Acknowledge one or many messages.
|
void |
addBindingKey(C consumer,
AMQDestination amqd,
String routingKey) |
protected void |
addDeliveredMessage(long id) |
protected void |
addUnacknowledgedMessage(long id) |
void |
bindQueue(String queueName,
String routingKey,
Map<String,Object> arguments,
String exchangeName,
AMQDestination destination)
Binds the named queue, with the specified routing key, to the named exchange.
|
void |
bindQueue(String queueName,
String routingKey,
Map<String,Object> arguments,
String exchangeName,
AMQDestination destination,
boolean nowait) |
void |
checkNotClosed()
Checks if this is closed, and raises a JMSException if it is.
|
protected void |
checkTransacted() |
protected javax.jms.Topic |
checkValidTopic(javax.jms.Topic topic) |
protected javax.jms.Topic |
checkValidTopic(javax.jms.Topic topic,
boolean durable) |
protected void |
clearDispatchQueue() |
void |
close()
Closes the session with no timeout.
|
void |
close(long timeout)
Closes the session.
|
void |
closed(Throwable e)
Called when the server initiates the closure of the session unilaterally.
|
void |
commit()
Commits all messages done in this transaction and releases any locks currently held.
|
protected abstract void |
commitImpl() |
void |
confirmConsumerCancelled(int consumerTag) |
javax.jms.QueueBrowser |
createBrowser(javax.jms.Queue queue) |
javax.jms.QueueBrowser |
createBrowser(javax.jms.Queue queue,
String messageSelector)
Create a queue browser if the destination is a valid queue.
|
protected javax.jms.MessageConsumer |
createBrowserConsumer(javax.jms.Destination destination,
String messageSelector,
boolean noLocal) |
javax.jms.BytesMessage |
createBytesMessage() |
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination) |
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination,
int prefetch,
boolean noLocal,
boolean exclusive,
String selector) |
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination,
int prefetchHigh,
int prefetchLow,
boolean noLocal,
boolean exclusive,
String selector) |
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination,
int prefetchHigh,
int prefetchLow,
boolean noLocal,
boolean exclusive,
String selector,
Map<String,Object> rawSelector) |
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination,
String messageSelector) |
javax.jms.MessageConsumer |
createConsumer(javax.jms.Destination destination,
String messageSelector,
boolean noLocal) |
protected C |
createConsumerImpl(javax.jms.Destination destination,
int prefetchHigh,
int prefetchLow,
boolean noLocal,
boolean exclusive,
String selector,
Map<String,Object> rawSelector,
boolean noConsume,
boolean autoClose) |
javax.jms.TopicSubscriber |
createDurableSubscriber(javax.jms.Topic topic,
String name) |
javax.jms.TopicSubscriber |
createDurableSubscriber(javax.jms.Topic topic,
String name,
String selector,
boolean noLocal) |
ListMessage |
createListMessage() |
javax.jms.MapMessage |
createMapMessage() |
javax.jms.Message |
createMessage() |
abstract C |
createMessageConsumer(AMQDestination destination,
int prefetchHigh,
int prefetchLow,
boolean noLocal,
boolean exclusive,
String selector,
Map<String,Object> arguments,
boolean noConsume,
boolean autoClose) |
abstract P |
createMessageProducer(javax.jms.Destination destination,
Boolean mandatory,
Boolean immediate,
long producerId) |
javax.jms.ObjectMessage |
createObjectMessage() |
javax.jms.ObjectMessage |
createObjectMessage(Serializable object) |
P |
createProducer(javax.jms.Destination destination) |
P |
createProducer(javax.jms.Destination destination,
boolean immediate)
Create a producer
|
P |
createProducer(javax.jms.Destination destination,
boolean mandatory,
boolean immediate)
Create a producer
|
javax.jms.TopicPublisher |
createPublisher(javax.jms.Topic topic) |
javax.jms.Queue |
createQueue(String queueName) |
void |
createQueue(String name,
boolean autoDelete,
boolean durable,
boolean exclusive)
Declares the named queue.
|
void |
createQueue(String name,
boolean autoDelete,
boolean durable,
boolean exclusive,
Map<String,Object> arguments)
Declares the named queue.
|
javax.jms.QueueReceiver |
createQueueReceiver(javax.jms.Destination destination)
Creates a QueueReceiver
|
javax.jms.QueueReceiver |
createQueueReceiver(javax.jms.Destination destination,
String messageSelector)
Creates a QueueReceiver using a message selector
|
javax.jms.QueueReceiver |
createReceiver(javax.jms.Queue queue)
Creates a QueueReceiver wrapping a MessageConsumer
|
javax.jms.QueueReceiver |
createReceiver(javax.jms.Queue queue,
String messageSelector)
Creates a QueueReceiver wrapping a MessageConsumer using a message selector
|
javax.jms.QueueSender |
createSender(javax.jms.Queue queue) |
javax.jms.StreamMessage |
createStreamMessage() |
javax.jms.TopicSubscriber |
createSubscriber(javax.jms.Topic topic)
Creates a non-durable subscriber
|
javax.jms.TopicSubscriber |
createSubscriber(javax.jms.Topic topic,
String messageSelector,
boolean noLocal)
Creates a non-durable subscriber with a message selector
|
javax.jms.TemporaryQueue |
createTemporaryQueue() |
String |
createTemporaryQueueName() |
javax.jms.TemporaryTopic |
createTemporaryTopic() |
javax.jms.TextMessage |
createTextMessage() |
javax.jms.TextMessage |
createTextMessage(String text) |
javax.jms.Topic |
createTopic(String topicName) |
void |
declareAndBind(AMQDestination amqd) |
void |
declareAndBind(AMQDestination amqd,
Map<String,Object> arguments) |
void |
declareExchange(String name,
String type,
boolean nowait) |
protected String |
declareQueue(AMQDestination amqd,
boolean noLocal)
Declares a queue for a JMS destination.
|
protected String |
declareQueue(AMQDestination amqd,
boolean noLocal,
boolean nowait) |
protected abstract String |
declareQueue(AMQDestination amqd,
boolean noLocal,
boolean nowait,
boolean passive) |
void |
deleteExchange(String exchangeName)
Deletes the exchange identified by the given name.
|
void |
deleteQueue(String queueName)
Undeclares the specified queue.
|
protected void |
deleteTemporaryDestination(org.apache.qpid.client.TemporaryDestination amqQueue)
Undeclares the specified temporary queue/topic.
|
void |
dispatch(UnprocessedMessage message) |
protected abstract void |
doBind(AMQDestination dest,
AMQDestination.Binding binding,
String queue,
String exchange) |
protected void |
drainDispatchQueueWithDispatcher() |
protected abstract void |
flushAcknowledgments() |
int |
getAcknowledgeMode() |
AMQConnection |
getAMQConnection() |
int |
getChannelId() |
protected Collection<C> |
getConsumers()
Consumers associated with this session
|
int |
getDefaultPrefetch() |
int |
getDefaultPrefetchHigh() |
int |
getDefaultPrefetchLow() |
String |
getDefaultQueueExchangeName() |
String |
getDefaultTopicExchangeName() |
protected ConcurrentLinkedQueue<Long> |
getDeliveredMessageTags()
All the delivered message tags
|
protected org.apache.qpid.client.AMQSession.Dispatcher |
getDispatcher()
Holds the dispatcher thread for this session.
|
protected Thread |
getDispatcherThread() |
protected Object |
getFailoverMutex() |
protected AtomicLong |
getHighestDeliveryTag()
Holds the highest received delivery tag.
|
abstract QpidException |
getLastException() |
abstract AMQMessageDelegateFactory |
getMessageDelegateFactory() |
MessageEncryptionHelper |
getMessageEncryptionHelper() |
protected MessageFactoryRegistry |
getMessageFactoryRegistry()
Holds the message factory factory for this session.
|
javax.jms.MessageListener |
getMessageListener() |
int |
getPrefetch() |
protected ConcurrentLinkedQueue<Long> |
getPrefetchedMessageTags()
Pre-fetched message tags
|
long |
getQueueDepth(AMQDestination amqd)
Returns the number of messages currently queued for the given destination.
|
long |
getQueueDepth(AMQDestination amqd,
boolean sync)
Returns the number of messages currently queued by the given
destination.
|
String |
getTemporaryQueueExchangeName() |
String |
getTemporaryTopicExchangeName() |
int |
getTicket() |
boolean |
getTransacted()
Indicates whether the session is in transacted mode.
|
protected ConcurrentLinkedQueue<Long> |
getUnacknowledgedMessageTags()
All the not yet acknowledged message tags
|
protected abstract void |
handleQueueNodeCreation(AMQDestination dest,
boolean noLocal) |
boolean |
hasConsumer(javax.jms.Destination destination) |
boolean |
hasFailedOverDirty()
Check to see if failover has occured since the last call to markClean(commit or rollback).
|
protected boolean |
hasMessageListeners() |
protected abstract boolean |
isBound(String exchangeName,
String amqQueueName,
String routingKey) |
boolean |
isClosed()
Checks if the Session and its parent connection are closed
|
boolean |
isClosing()
Checks if the Session and its parent connection are capable of performing
closing operations
|
boolean |
isDeclareExchanges() |
abstract boolean |
isExchangeExist(AMQDestination dest,
boolean assertNode) |
abstract boolean |
isFlowBlocked()
Tests whether flow to this session is blocked.
|
protected boolean |
isImmediatePrefetch()
Used to indicate that the session should start pre-fetching messages as soon as it is started.
|
abstract boolean |
isQueueBound(AMQDestination destination) |
abstract boolean |
isQueueBound(String exchangeName,
String queueName,
String routingKey)
Tests whether or not the specified queue is bound to the specified exchange under a particular routing key.
|
abstract boolean |
isQueueBound(String exchangeName,
String queueName,
String bindingKey,
Map<String,Object> args) |
abstract boolean |
isQueueExist(AMQDestination dest,
boolean assertNode) |
boolean |
isStrictAMQP()
Indicates that warnings should be generated on violations of the strict AMQP.
|
boolean |
isSuspended() |
boolean |
isTransacted()
Indicates whether the session is in transacted mode.
|
void |
markClean()
Signifies that the session has no pending sends to commit.
|
void |
markDirty()
Signifies that the session has pending sends to commit.
|
void |
messageReceived(UnprocessedMessage message)
Invoked by the MINA IO thread (indirectly) when a message is received from the transport.
|
boolean |
prefetch()
Indicates whether this session consumers pre-fetche messages
|
protected String |
preprocessAddressTopic(C consumer,
String queueName) |
void |
recover()
Stops message delivery in this session, and restarts message delivery with the oldest unacknowledged message.
|
void |
rejectMessage(AbstractJMSMessage message,
boolean requeue) |
abstract void |
rejectMessage(long deliveryTag,
boolean requeue) |
void |
rejectMessage(UnprocessedMessage message,
boolean requeue) |
abstract void |
releaseForRollback() |
protected abstract Long |
requestQueueDepth(AMQDestination amqd,
boolean sync) |
void |
resolveAddress(AMQDestination dest,
boolean isConsumer,
boolean noLocal)
1.
|
abstract int |
resolveAddressType(AMQDestination dest) |
void |
rollback()
Commits all messages done in this transaction and releases any locks currently held.
|
void |
run() |
abstract void |
sendClose(long timeout) |
abstract void |
sendConsume(C consumer,
String queueName,
boolean nowait,
int tag) |
abstract void |
sendCreateQueue(String name,
boolean autoDelete,
boolean durable,
boolean exclusive,
Map<String,Object> arguments) |
abstract void |
sendExchangeDeclare(String name,
String type,
boolean nowait,
boolean durable,
boolean autoDelete,
boolean internal) |
abstract void |
sendExchangeDeclare(String name,
String type,
boolean nowait,
boolean durable,
boolean autoDelete,
Map<String,Object> arguments,
boolean passive) |
abstract void |
sendQueueBind(String queueName,
String routingKey,
Map<String,Object> arguments,
String exchangeName,
AMQDestination destination,
boolean nowait) |
abstract void |
sendQueueDelete(String queueName) |
protected abstract void |
sendRecover() |
abstract void |
sendRollback() |
abstract void |
sendSuspendChannel(boolean suspend) |
abstract void |
setFlowControl(boolean active) |
void |
setLegacyFieldsForQueueType(AMQDestination dest) |
void |
setLegacyFieldsForTopicType(AMQDestination dest) |
void |
setMessageListener(javax.jms.MessageListener listener) |
void |
setTicket(int ticket) |
protected void |
setUsingDispatcherForCleanup(boolean usingDispatcherForCleanup) |
protected void |
stopDispatcherThread() |
protected void |
stopExistingDispatcher() |
protected void |
suspendChannel(boolean suspend)
Suspends or unsuspends this session.
|
protected void |
suspendChannelIfNotClosing() |
abstract void |
sync() |
protected abstract boolean |
tagLE(long tag1,
long tag2) |
void |
unsubscribe(String name) |
protected abstract boolean |
updateRollbackMark(long current,
long deliveryTag) |
protected void |
verifySubject(AMQDestination dest) |
setClosed, setClosing
public static final String DISPATCHER_SHUTDOWN_TIMEOUT_MS
public static final String DISPATCHER_SHUTDOWN_TIMEOUT_MS_DEFAULT
public static final String STRICT_AMQP
public static final String STRICT_AMQP_DEFAULT
public static final String STRICT_AMQP_FATAL
public static final String STRICT_AMQP_FATAL_DEFAULT
public static final String IMMEDIATE_PREFETCH
public static final String IMMEDIATE_PREFETCH_DEFAULT
protected final boolean DAEMON_DISPATCHER_THREAD
protected AMQSession(AMQConnection con, int channelId, boolean transacted, int acknowledgeMode, int defaultPrefetchHighMark, int defaultPrefetchLowMark)
con
- The connection on which to create the session.channelId
- The unique identifier for the session.transacted
- Indicates whether or not the session is transactional.acknowledgeMode
- The acknowledgement mode for the session.defaultPrefetchHighMark
- The maximum number of messages to prefetched before suspending the session.defaultPrefetchLowMark
- The number of prefetched messages at which to resume the session.protected AtomicLong getHighestDeliveryTag()
protected ConcurrentLinkedQueue<Long> getPrefetchedMessageTags()
protected ConcurrentLinkedQueue<Long> getUnacknowledgedMessageTags()
protected ConcurrentLinkedQueue<Long> getDeliveredMessageTags()
protected org.apache.qpid.client.AMQSession.Dispatcher getDispatcher()
protected Thread getDispatcherThread()
protected MessageFactoryRegistry getMessageFactoryRegistry()
protected Collection<C> getConsumers()
protected void setUsingDispatcherForCleanup(boolean usingDispatcherForCleanup)
protected boolean isImmediatePrefetch()
public void close() throws javax.jms.JMSException
public abstract QpidException getLastException()
public void checkNotClosed() throws javax.jms.JMSException
Closeable
checkNotClosed
in class Closeable
javax.jms.JMSException
- If this is closed.public javax.jms.BytesMessage createBytesMessage() throws javax.jms.JMSException
createBytesMessage
in interface javax.jms.Session
javax.jms.JMSException
public void acknowledge() throws javax.jms.IllegalStateException, javax.jms.JMSException
javax.jms.IllegalStateException
- If the session is closed.javax.jms.JMSException
- if there is a problem during acknowledge process.public void setLegacyFieldsForQueueType(AMQDestination dest)
public void setLegacyFieldsForTopicType(AMQDestination dest)
protected void verifySubject(AMQDestination dest) throws QpidException
QpidException
public abstract boolean isExchangeExist(AMQDestination dest, boolean assertNode) throws QpidException
QpidException
public abstract boolean isQueueExist(AMQDestination dest, boolean assertNode) throws QpidException
QpidException
public void resolveAddress(AMQDestination dest, boolean isConsumer, boolean noLocal) throws QpidException
QpidException
public abstract int resolveAddressType(AMQDestination dest) throws QpidException
QpidException
protected abstract void acknowledgeImpl() throws javax.jms.JMSException
javax.jms.JMSException
public abstract void acknowledgeMessage(long deliveryTag, boolean multiple)
deliveryTag
- The tag of the last message to be acknowledged.multiple
- true to acknowledge all messages up to and including the one specified by the
delivery tag, false to just acknowledge that message.
TODO Be aware of possible changes to parameter order as versions change.public void bindQueue(String queueName, String routingKey, Map<String,Object> arguments, String exchangeName, AMQDestination destination) throws QpidException
Note that this operation automatically retries in the event of fail-over.
queueName
- The name of the queue to bind.routingKey
- The routing key to bind the queue with.arguments
- Additional arguments.exchangeName
- The exchange to bind the queue on.QpidException
- If the queue cannot be bound for any reason.
TODO Be aware of possible changes to parameter order as versions change.
TODO Document the additional arguments that may be passed in the field table. Are these for headers exchanges?public void bindQueue(String queueName, String routingKey, Map<String,Object> arguments, String exchangeName, AMQDestination destination, boolean nowait) throws QpidException
QpidException
public void addBindingKey(C consumer, AMQDestination amqd, String routingKey) throws QpidException
QpidException
public abstract void sendQueueBind(String queueName, String routingKey, Map<String,Object> arguments, String exchangeName, AMQDestination destination, boolean nowait) throws QpidException, FailoverException
QpidException
FailoverException
public void close(long timeout) throws javax.jms.JMSException
Note that this operation succeeds automatically if a fail-over interrupts the synchronous request to close the channel. This is because the channel is marked as closed before the request to close it is made, so the fail-over should not re-open it.
timeout
- The timeout in milliseconds to wait for the session close acknowledgement from the broker.javax.jms.JMSException
- If the JMS provider fails to close the session due to some internal error.
TODO Be aware of possible changes to parameter order as versions change.
TODO Not certain about the logic of ignoring the failover exception, because the channel won't be
re-opened. May need to examine this more carefully.
TODO Note that taking the failover mutex doesn't prevent this operation being interrupted by a failover,
because the failover process sends the failover event before acquiring the mutex itself.public abstract void sendClose(long timeout) throws QpidException, FailoverException
QpidException
FailoverException
public void closed(Throwable e) throws javax.jms.JMSException
e
- the exception that caused this session to be closed. Null causes thejavax.jms.JMSException
protected void stopDispatcherThread()
public void commit() throws javax.jms.JMSException
If the commit fails, because the commit itself is interrupted by a fail-over between requesting that the commit be done, and receiving an acknowledgement that it has been done, then a JMSException will be thrown. The client will be unable to determine whether or not the commit actually happened on the broker in this case.
commit
in interface javax.jms.Session
javax.jms.JMSException
- If the JMS provider fails to commit the transaction due to some internal error. This does
not mean that the commit is known to have failed, merely that it is not known whether it
failed or not.protected abstract void commitImpl() throws QpidException, FailoverException, TransportException
public void confirmConsumerCancelled(int consumerTag)
public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue) throws javax.jms.JMSException
createBrowser
in interface javax.jms.QueueSession
createBrowser
in interface javax.jms.Session
javax.jms.JMSException
public javax.jms.QueueBrowser createBrowser(javax.jms.Queue queue, String messageSelector) throws javax.jms.JMSException
createBrowser
in interface javax.jms.QueueSession
createBrowser
in interface javax.jms.Session
javax.jms.JMSException
protected javax.jms.MessageConsumer createBrowserConsumer(javax.jms.Destination destination, String messageSelector, boolean noLocal) throws javax.jms.JMSException
javax.jms.JMSException
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination) throws javax.jms.JMSException
createConsumer
in interface javax.jms.Session
javax.jms.JMSException
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, String messageSelector) throws javax.jms.JMSException
createConsumer
in interface javax.jms.Session
javax.jms.JMSException
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, String messageSelector, boolean noLocal) throws javax.jms.JMSException
createConsumer
in interface javax.jms.Session
javax.jms.JMSException
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, int prefetch, boolean noLocal, boolean exclusive, String selector) throws javax.jms.JMSException
javax.jms.JMSException
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, int prefetchHigh, int prefetchLow, boolean noLocal, boolean exclusive, String selector) throws javax.jms.JMSException
javax.jms.JMSException
public javax.jms.MessageConsumer createConsumer(javax.jms.Destination destination, int prefetchHigh, int prefetchLow, boolean noLocal, boolean exclusive, String selector, Map<String,Object> rawSelector) throws javax.jms.JMSException
javax.jms.JMSException
public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, String name) throws javax.jms.JMSException
createDurableSubscriber
in interface javax.jms.Session
createDurableSubscriber
in interface javax.jms.TopicSession
javax.jms.JMSException
public javax.jms.TopicSubscriber createDurableSubscriber(javax.jms.Topic topic, String name, String selector, boolean noLocal) throws javax.jms.JMSException
createDurableSubscriber
in interface javax.jms.Session
createDurableSubscriber
in interface javax.jms.TopicSession
javax.jms.JMSException
public ListMessage createListMessage() throws javax.jms.JMSException
javax.jms.JMSException
public javax.jms.MapMessage createMapMessage() throws javax.jms.JMSException
createMapMessage
in interface javax.jms.Session
javax.jms.JMSException
public javax.jms.Message createMessage() throws javax.jms.JMSException
createMessage
in interface javax.jms.Session
javax.jms.JMSException
public javax.jms.ObjectMessage createObjectMessage() throws javax.jms.JMSException
createObjectMessage
in interface javax.jms.Session
javax.jms.JMSException
public javax.jms.ObjectMessage createObjectMessage(Serializable object) throws javax.jms.JMSException
createObjectMessage
in interface javax.jms.Session
javax.jms.JMSException
public P createProducer(javax.jms.Destination destination) throws javax.jms.JMSException
createProducer
in interface javax.jms.Session
javax.jms.JMSException
public P createProducer(javax.jms.Destination destination, boolean immediate) throws javax.jms.JMSException
Session
immediate
- the value of the immediate flag used by default on the producerjavax.jms.JMSException
public P createProducer(javax.jms.Destination destination, boolean mandatory, boolean immediate) throws javax.jms.JMSException
Session
mandatory
- the value of the mandatory flag used by default on the producerimmediate
- the value of the immediate flag used by default on the producerjavax.jms.JMSException
public javax.jms.TopicPublisher createPublisher(javax.jms.Topic topic) throws javax.jms.JMSException
createPublisher
in interface javax.jms.TopicSession
javax.jms.JMSException
public javax.jms.Queue createQueue(String queueName) throws javax.jms.JMSException
createQueue
in interface javax.jms.QueueSession
createQueue
in interface javax.jms.Session
javax.jms.JMSException
public void createQueue(String name, boolean autoDelete, boolean durable, boolean exclusive) throws QpidException
Note that this operation automatically retries in the event of fail-over.
name
- The name of the queue to declare.autoDelete
- durable
- Flag to indicate that the queue is durable.exclusive
- Flag to indicate that the queue is exclusive to this client.QpidException
- If the queue cannot be declared for any reason.
TODO Be aware of possible changes to parameter order as versions change.public void createQueue(String name, boolean autoDelete, boolean durable, boolean exclusive, Map<String,Object> arguments) throws QpidException
Note that this operation automatically retries in the event of fail-over.
name
- The name of the queue to declare.autoDelete
- durable
- Flag to indicate that the queue is durable.exclusive
- Flag to indicate that the queue is exclusive to this client.arguments
- Arguments used to set special properties of the queueQpidException
- If the queue cannot be declared for any reason.
TODO Be aware of possible changes to parameter order as versions change.public abstract void sendCreateQueue(String name, boolean autoDelete, boolean durable, boolean exclusive, Map<String,Object> arguments) throws QpidException, FailoverException
QpidException
FailoverException
public javax.jms.QueueReceiver createQueueReceiver(javax.jms.Destination destination) throws javax.jms.JMSException
destination
- javax.jms.JMSException
public javax.jms.QueueReceiver createQueueReceiver(javax.jms.Destination destination, String messageSelector) throws javax.jms.JMSException
destination
- messageSelector
- javax.jms.JMSException
public javax.jms.QueueReceiver createReceiver(javax.jms.Queue queue) throws javax.jms.JMSException
createReceiver
in interface javax.jms.QueueSession
queue
- javax.jms.JMSException
public javax.jms.QueueReceiver createReceiver(javax.jms.Queue queue, String messageSelector) throws javax.jms.JMSException
createReceiver
in interface javax.jms.QueueSession
queue
- messageSelector
- javax.jms.JMSException
public javax.jms.QueueSender createSender(javax.jms.Queue queue) throws javax.jms.JMSException
createSender
in interface javax.jms.QueueSession
javax.jms.JMSException
public javax.jms.StreamMessage createStreamMessage() throws javax.jms.JMSException
createStreamMessage
in interface javax.jms.Session
javax.jms.JMSException
public javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic) throws javax.jms.JMSException
createSubscriber
in interface javax.jms.TopicSession
topic
- javax.jms.JMSException
public javax.jms.TopicSubscriber createSubscriber(javax.jms.Topic topic, String messageSelector, boolean noLocal) throws javax.jms.JMSException
createSubscriber
in interface javax.jms.TopicSession
topic
- messageSelector
- noLocal
- javax.jms.JMSException
public javax.jms.TemporaryQueue createTemporaryQueue() throws javax.jms.JMSException
createTemporaryQueue
in interface javax.jms.QueueSession
createTemporaryQueue
in interface javax.jms.Session
javax.jms.JMSException
public javax.jms.TemporaryTopic createTemporaryTopic() throws javax.jms.JMSException
createTemporaryTopic
in interface javax.jms.Session
createTemporaryTopic
in interface javax.jms.TopicSession
javax.jms.JMSException
public javax.jms.TextMessage createTextMessage() throws javax.jms.JMSException
createTextMessage
in interface javax.jms.Session
javax.jms.JMSException
protected Object getFailoverMutex()
public javax.jms.TextMessage createTextMessage(String text) throws javax.jms.JMSException
createTextMessage
in interface javax.jms.Session
javax.jms.JMSException
public javax.jms.Topic createTopic(String topicName) throws javax.jms.JMSException
createTopic
in interface javax.jms.Session
createTopic
in interface javax.jms.TopicSession
javax.jms.JMSException
public void declareExchange(String name, String type, boolean nowait) throws QpidException
QpidException
public void deleteExchange(String exchangeName) throws javax.jms.JMSException
Session
exchangeName
- name of the exchangejavax.jms.JMSException
public abstract void sync() throws QpidException
QpidException
public int getAcknowledgeMode()
getAcknowledgeMode
in interface javax.jms.Session
public AMQConnection getAMQConnection()
public int getChannelId()
public int getDefaultPrefetch()
public int getDefaultPrefetchHigh()
public int getDefaultPrefetchLow()
public int getPrefetch()
public String getDefaultQueueExchangeName()
public String getDefaultTopicExchangeName()
public javax.jms.MessageListener getMessageListener() throws javax.jms.JMSException
getMessageListener
in interface javax.jms.Session
javax.jms.JMSException
public String getTemporaryQueueExchangeName()
public String getTemporaryTopicExchangeName()
public int getTicket()
public boolean getTransacted() throws javax.jms.JMSException
getTransacted
in interface javax.jms.Session
javax.jms.IllegalStateException
- - if session is closed.javax.jms.JMSException
public boolean isTransacted()
public boolean hasConsumer(javax.jms.Destination destination)
public boolean isStrictAMQP()
public boolean isSuspended()
protected void addUnacknowledgedMessage(long id)
protected void addDeliveredMessage(long id)
public void messageReceived(UnprocessedMessage message)
message
- the message that has been receivedpublic void declareAndBind(AMQDestination amqd) throws QpidException
QpidException
public void declareAndBind(AMQDestination amqd, Map<String,Object> arguments) throws QpidException
QpidException
public void recover() throws javax.jms.JMSException
All consumers deliver messages in a serial order. Acknowledging a received message automatically acknowledges all messages that have been delivered to the client.
Restarting a session causes it to take the following actions:
If the recover operation is interrupted by a fail-over, between asking that the broker begin recovery and receiving acknowledgment that it has then a JMSException will be thrown. In this case it will not be possible for the client to determine whether the broker is going to recover the session or not.
recover
in interface javax.jms.Session
javax.jms.JMSException
- If the JMS provider fails to stop and restart message delivery due to some internal error.
Not that this does not necessarily mean that the recovery has failed, but simply that it is
not possible to tell if it has or not.
TODO Be aware of possible changes to parameter order as versions change.
Strategy for handling recover.
Flush any acks not yet sent.
Stop the message flow.
Clear the dispatch queue and the consumer queues.
Release/Reject all messages received but not yet acknowledged.
Start the message flow.protected abstract void sendRecover() throws QpidException, FailoverException
QpidException
FailoverException
protected abstract void flushAcknowledgments()
public void rejectMessage(UnprocessedMessage message, boolean requeue)
public void rejectMessage(AbstractJMSMessage message, boolean requeue)
public abstract void rejectMessage(long deliveryTag, boolean requeue)
public void rollback() throws javax.jms.JMSException
If the rollback fails, because the rollback itself is interrupted by a fail-over between requesting that the rollback be done, and receiving an acknowledgement that it has been done, then a JMSException will be thrown. The client will be unable to determine whether or not the rollback actually happened on the broker in this case.
rollback
in interface javax.jms.Session
javax.jms.JMSException
- If the JMS provider fails to rollback the transaction due to some internal error. This does
not mean that the rollback is known to have failed, merely that it is not known whether it
failed or not.
TODO Be aware of possible changes to parameter order as versions change.public abstract void releaseForRollback()
public abstract void sendRollback() throws QpidException, FailoverException
QpidException
FailoverException
public void run()
public void setMessageListener(javax.jms.MessageListener listener) throws javax.jms.JMSException
setMessageListener
in interface javax.jms.Session
javax.jms.JMSException
public void unsubscribe(String name) throws javax.jms.JMSException
unsubscribe
in interface javax.jms.Session
unsubscribe
in interface javax.jms.TopicSession
javax.jms.JMSException
unsubscribe(String, boolean)
protected C createConsumerImpl(javax.jms.Destination destination, int prefetchHigh, int prefetchLow, boolean noLocal, boolean exclusive, String selector, Map<String,Object> rawSelector, boolean noConsume, boolean autoClose) throws javax.jms.JMSException
javax.jms.JMSException
public abstract C createMessageConsumer(AMQDestination destination, int prefetchHigh, int prefetchLow, boolean noLocal, boolean exclusive, String selector, Map<String,Object> arguments, boolean noConsume, boolean autoClose) throws javax.jms.JMSException
javax.jms.JMSException
public abstract boolean isQueueBound(String exchangeName, String queueName, String routingKey) throws javax.jms.JMSException
Note that this operation automatically retries in the event of fail-over.
exchangeName
- The exchange name to test for binding against.queueName
- The queue name to check if bound.routingKey
- The routing key to check if the queue is bound under.javax.jms.JMSException
- If the query fails for any reason.
TODO Be aware of possible changes to parameter order as versions change.public abstract boolean isQueueBound(AMQDestination destination) throws javax.jms.JMSException
javax.jms.JMSException
public abstract boolean isQueueBound(String exchangeName, String queueName, String bindingKey, Map<String,Object> args) throws javax.jms.JMSException
javax.jms.JMSException
protected void checkTransacted() throws javax.jms.JMSException
javax.jms.JMSException
protected javax.jms.Topic checkValidTopic(javax.jms.Topic topic, boolean durable) throws javax.jms.JMSException
javax.jms.JMSException
protected javax.jms.Topic checkValidTopic(javax.jms.Topic topic) throws javax.jms.JMSException
javax.jms.JMSException
protected abstract void handleQueueNodeCreation(AMQDestination dest, boolean noLocal) throws QpidException
QpidException
protected abstract void doBind(AMQDestination dest, AMQDestination.Binding binding, String queue, String exchange) throws QpidException
QpidException
public abstract void sendConsume(C consumer, String queueName, boolean nowait, int tag) throws QpidException, FailoverException
QpidException
FailoverException
public abstract P createMessageProducer(javax.jms.Destination destination, Boolean mandatory, Boolean immediate, long producerId) throws javax.jms.JMSException
javax.jms.JMSException
public long getQueueDepth(AMQDestination amqd) throws QpidException
Note that this operation automatically retries in the event of fail-over.
amqd
- The destination to be checkedQpidException
- If the queue cannot be declared for any reason.public long getQueueDepth(AMQDestination amqd, boolean sync) throws QpidException
amqd
- AMQ destination to get the depth valuesync
- flag to sync session before receiving the queue depthQpidException
protected abstract Long requestQueueDepth(AMQDestination amqd, boolean sync) throws QpidException, FailoverException
QpidException
FailoverException
protected String preprocessAddressTopic(C consumer, String queueName) throws QpidException
QpidException
public abstract void sendExchangeDeclare(String name, String type, boolean nowait, boolean durable, boolean autoDelete, boolean internal) throws QpidException, FailoverException
QpidException
FailoverException
public abstract void sendExchangeDeclare(String name, String type, boolean nowait, boolean durable, boolean autoDelete, Map<String,Object> arguments, boolean passive) throws QpidException, FailoverException
QpidException
FailoverException
protected String declareQueue(AMQDestination amqd, boolean noLocal) throws QpidException
Note that for queues but not topics the name is generated in the client rather than the server. This allows the name to be reused on failover if required. In general, the destination indicates whether it wants a name generated or not.
Note that this operation automatically retries in the event of fail-over.
amqd
- The destination to declare as a queue.QpidException
- If the queue cannot be declared for any reason.
TODO Verify the destiation is valid or throw an exception.
TODO Be aware of possible changes to parameter order as versions change.protected String declareQueue(AMQDestination amqd, boolean noLocal, boolean nowait) throws QpidException
QpidException
protected abstract String declareQueue(AMQDestination amqd, boolean noLocal, boolean nowait, boolean passive) throws QpidException
QpidException
public void deleteQueue(String queueName) throws javax.jms.JMSException
Note that this operation automatically retries in the event of fail-over.
queueName
- The name of the queue to delete.javax.jms.JMSException
- If the queue could not be deleted for any reason.protected void deleteTemporaryDestination(org.apache.qpid.client.TemporaryDestination amqQueue) throws javax.jms.JMSException
Note that this operation automatically retries in the event of fail-over.
amqQueue
- The name of the temporary destination to delete.javax.jms.JMSException
- If the queue could not be deleted for any reason.
TODO Be aware of possible changes to parameter order as versions change.public abstract void sendQueueDelete(String queueName) throws QpidException, FailoverException
QpidException
FailoverException
protected boolean hasMessageListeners()
protected abstract boolean isBound(String exchangeName, String amqQueueName, String routingKey) throws QpidException
QpidException
protected void suspendChannel(boolean suspend) throws QpidException
suspend
- true indicates that the session should be suspended, false indicates that it
should be unsuspended.QpidException
- If the session cannot be suspended for any reason.
TODO Be aware of possible changes to parameter order as versions change.public abstract void sendSuspendChannel(boolean suspend) throws QpidException, FailoverException
QpidException
FailoverException
public boolean prefetch()
public void markDirty()
public void markClean()
public boolean hasFailedOverDirty()
public void setTicket(int ticket)
public abstract boolean isFlowBlocked()
public abstract void setFlowControl(boolean active)
public String createTemporaryQueueName()
public void dispatch(UnprocessedMessage message)
protected abstract boolean tagLE(long tag1, long tag2)
protected abstract boolean updateRollbackMark(long current, long deliveryTag)
public abstract AMQMessageDelegateFactory getMessageDelegateFactory()
public boolean isClosed()
public boolean isClosing()
public boolean isDeclareExchanges()
public MessageEncryptionHelper getMessageEncryptionHelper()
protected void drainDispatchQueueWithDispatcher()
protected void stopExistingDispatcher()
protected void suspendChannelIfNotClosing() throws QpidException
QpidException
protected void clearDispatchQueue()
Copyright © 2006–2016 The Apache Software Foundation. All rights reserved.