/** * Send message * * @param message The message * @throws JMSException Thrown if an error occurs */ @Override public void send(final Message message) throws JMSException { session.lock(); try { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("send " + this + " message=" + message); } checkState(); producer.send(message); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } } finally { session.unlock(); } }
/** * Send message * * @param destination The destination * @param message The message * @throws JMSException Thrown if an error occurs */ @Override public void send(final Destination destination, final Message message) throws JMSException { session.lock(); try { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("send " + this + " destination=" + destination + " message=" + message); } checkState(); producer.send(destination, message); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } } finally { session.unlock(); } }
/** * Send message * * @param message The message * @throws JMSException Thrown if an error occurs */ @Override public void send(final Message message) throws JMSException { session.lock(); try { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("send " + this + " message=" + message); } checkState(); producer.send(message); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } } finally { session.unlock(); } }
/** * Set message listener * * @param listener The listener * @throws JMSException Thrown if an error occurs */ @Override public void setMessageListener(final MessageListener listener) throws JMSException { session.lock(); try { checkState(); session.checkStrict(); if (listener == null) { consumer.setMessageListener(null); } else { consumer.setMessageListener(wrapMessageListener(listener)); } } finally { session.unlock(); } }
/** * Recover * * @throws JMSException Failed to close session. */ @Override public void recover() throws JMSException { lock(); try { Session session = getSessionInternal(); if (cri.isTransacted()) { throw new IllegalStateException("Session is transacted"); } if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Recover session " + this); } session.recover(); } finally { unlock(); } }
/** * Get the XA resource */ @Override public XAResource getXAResource() { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getXAResource()"); } if (cri.getType() == ActiveMQRAConnectionFactory.CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION) { return null; } try { lock(); return getXAResourceInternal(); } catch (Throwable t) { return null; } finally { unlock(); } }
/** * Recover * * @throws JMSException Failed to close session. */ @Override public void recover() throws JMSException { lock(); try { Session session = getSessionInternal(); if (cri.isTransacted()) { throw new IllegalStateException("Session is transacted"); } if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Recover session " + this); } session.recover(); } finally { unlock(); } }
/** * Publish message * * @param message The message * @throws JMSException Thrown if an error occurs */ @Override public void publish(final Message message) throws JMSException { session.lock(); try { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("send " + this + " message=" + message); } checkState(); ((TopicPublisher) producer).publish(message); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("sent " + this + " result=" + message); } } finally { session.unlock(); } }
/** * Get the queue session * * @return The queue session * @throws JMSException Thrown if an error occurs */ @Override public QueueSession getQueueSession() throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getQueueSession()"); } if (cri.getType() == ActiveMQRAConnectionFactory.CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION) { throw new IllegalStateException("Non XA connection"); } lock(); try { return this; } finally { unlock(); } }
/** * Get the XA resource */ @Override public XAResource getXAResource() { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getXAResource()"); } if (cri.getType() == ActiveMQRAConnectionFactory.CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION) { return null; } try { lock(); return getXAResourceInternal(); } catch (Throwable t) { return null; } finally { unlock(); } }
/** * Get the queue session * * @return The queue session * @throws JMSException Thrown if an error occurs */ @Override public QueueSession getQueueSession() throws JMSException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getQueueSession()"); } if (cri.getType() == ActiveMQRAConnectionFactory.CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.QUEUE_CONNECTION || cri.getType() == ActiveMQRAConnectionFactory.TOPIC_CONNECTION) { throw new IllegalStateException("Non XA connection"); } lock(); try { return this; } finally { unlock(); } }
@Override public MessageConsumer createDurableConsumer(final Topic topic, final String name) throws JMSException { lock(); try { Session session = getSessionInternal(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createSharedConsumer " + session + " topic=" + topic + ", name=" + name); } MessageConsumer result = session.createDurableConsumer(topic, name); result = new ActiveMQRAMessageConsumer(result, this); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createdConsumer " + session + " consumer=" + result); } addConsumer(result); return result; } finally { unlock(); } }
@Override public MessageConsumer createSharedConsumer(final Topic topic, final String sharedSubscriptionName) throws JMSException { lock(); try { Session session = getSessionInternal(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createSharedConsumer " + session + " topic=" + topic + ", sharedSubscriptionName=" + sharedSubscriptionName); } MessageConsumer result = session.createSharedConsumer(topic, sharedSubscriptionName); result = new ActiveMQRAMessageConsumer(result, this); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createdConsumer " + session + " consumer=" + result); } addConsumer(result); return result; } finally { unlock(); } }
@Override public MessageConsumer createSharedDurableConsumer(Topic topic, String name) throws JMSException { lock(); try { Session session = getSessionInternal(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createSharedDurableConsumer " + session + " topic=" + topic + ", name=" + name); } MessageConsumer result = session.createSharedDurableConsumer(topic, name); result = new ActiveMQRAMessageConsumer(result, this); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createdConsumer " + session + " consumer=" + result); } addConsumer(result); return result; } finally { unlock(); } }
@Override public MessageConsumer createSharedConsumer(final Topic topic, final String sharedSubscriptionName) throws JMSException { lock(); try { Session session = getSessionInternal(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createSharedConsumer " + session + " topic=" + topic + ", sharedSubscriptionName=" + sharedSubscriptionName); } MessageConsumer result = session.createSharedConsumer(topic, sharedSubscriptionName); result = new ActiveMQRAMessageConsumer(result, this); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createdConsumer " + session + " consumer=" + result); } addConsumer(result); return result; } finally { unlock(); } }
@Override public MessageConsumer createSharedDurableConsumer(Topic topic, String name, String messageSelector) throws JMSException { lock(); try { Session session = getSessionInternal(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createSharedDurableConsumer " + session + " topic=" + topic + ", name=" + name + ", messageSelector=" + messageSelector); } MessageConsumer result = session.createSharedDurableConsumer(topic, name, messageSelector); result = new ActiveMQRAMessageConsumer(result, this); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createdConsumer " + session + " consumer=" + result); } addConsumer(result); return result; } finally { unlock(); } }
@Override public MessageConsumer createDurableConsumer(final Topic topic, final String name) throws JMSException { lock(); try { Session session = getSessionInternal(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createSharedConsumer " + session + " topic=" + topic + ", name=" + name); } MessageConsumer result = session.createDurableConsumer(topic, name); result = new ActiveMQRAMessageConsumer(result, this); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createdConsumer " + session + " consumer=" + result); } addConsumer(result); return result; } finally { unlock(); } }
@Override public MessageConsumer createDurableConsumer(Topic topic, String name, String messageSelector, boolean noLocal) throws JMSException { lock(); try { Session session = getSessionInternal(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createDurableConsumer " + session + " topic=" + topic + ", name=" + name + ", messageSelector=" + messageSelector + ", noLocal=" + noLocal); } MessageConsumer result = session.createDurableConsumer(topic, name, messageSelector, noLocal); result = new ActiveMQRAMessageConsumer(result, this); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createdConsumer " + session + " consumer=" + result); } addConsumer(result); return result; } finally { unlock(); } }
@Override public MessageConsumer createSharedDurableConsumer(Topic topic, String name) throws JMSException { lock(); try { Session session = getSessionInternal(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createSharedDurableConsumer " + session + " topic=" + topic + ", name=" + name); } MessageConsumer result = session.createSharedDurableConsumer(topic, name); result = new ActiveMQRAMessageConsumer(result, this); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createdConsumer " + session + " consumer=" + result); } addConsumer(result); return result; } finally { unlock(); } }
@Override public MessageConsumer createSharedDurableConsumer(Topic topic, String name, String messageSelector) throws JMSException { lock(); try { Session session = getSessionInternal(); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createSharedDurableConsumer " + session + " topic=" + topic + ", name=" + name + ", messageSelector=" + messageSelector); } MessageConsumer result = session.createSharedDurableConsumer(topic, name, messageSelector); result = new ActiveMQRAMessageConsumer(result, this); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createdConsumer " + session + " consumer=" + result); } addConsumer(result); return result; } finally { unlock(); } }