ActiveMQSessionExecutor(ActiveMQSession session) { this.session = session; if (this.session.connection != null && this.session.connection.isMessagePrioritySupported()) { this.messageQueue = new SimplePriorityMessageDispatchChannel(); }else { this.messageQueue = new FifoMessageDispatchChannel(); } }
synchronized void start() { if (!messageQueue.isRunning()) { messageQueue.start(); if (hasUncomsumedMessages()) { wakeup(); } } }
/** * @return Returns the QueueConnection. */ @Override public QueueConnection createQueueConnection(String userName, String password) throws JMSException { return createActiveMQConnection(userName, password).enforceQueueOnlyConnection(); }
private void immediateIndividualTransactedAck(MessageDispatch md) throws JMSException { // acks accumulate on the broker pending transaction completion to indicate // delivery status registerSync(); MessageAck ack = new MessageAck(md, MessageAck.INDIVIDUAL_ACK_TYPE, 1); ack.setTransactionId(session.getTransactionContext().getTransactionId()); session.sendAck(ack); }
public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException { checkClosedOrFailed(); ensureConnectionInfoSent(); return new ActiveMQXASession(this, getNextSessionId(), getAckMode(), isDispatchAsync()); }
protected void sendAck(MessageAck ack, boolean lazy) throws JMSException { if (lazy || connection.isSendAcksAsync() || getTransacted()) { asyncSendPacket(ack); } else { syncSendPacket(ack); } }
/** * Send TransactionInfo to indicate transaction has started * * @throws JMSException if some internal error occurs */ protected void doStartTransaction() throws JMSException { if (getTransacted() && !transactionContext.isInXATransaction()) { transactionContext.begin(); } }
protected ActiveMQConnection createActiveMQConnection(Transport transport, JMSStatsImpl stats) throws Exception { ActiveMQXAConnection connection = new ActiveMQXAConnection(transport, getClientIdGenerator(), getConnectionIdGenerator(), stats); configureXAConnection(connection); return connection; }
@Override protected ActiveMQConnection createActiveMQConnection(Transport transport, JMSStatsImpl stats) throws Exception { ActiveMQXAConnection connection = new ActiveMQXAConnection(transport, getClientIdGenerator(), getConnectionIdGenerator(), stats); configureXAConnection(connection); return connection; }
@Override public void execute() throws Exception { checkClosed(); session.checkClosed(); acknowledge(md); } });
/** * send a Packet through the Connection - for internal use only * * @param command * @throws JMSException */ public void asyncSendPacket(Command command) throws JMSException { if (isClosed()) { throw new ConnectionClosedException(); } else { doAsyncSendPacket(command); } }
@Override public void run() { try { if (!unconsumedMessages.isClosed()) { for(MessageDispatch dispatch : pendingRedeliveries) { session.dispatch(dispatch); } } } catch (Exception e) { session.connection.onAsyncException(e); } } }, redeliveryDelay);
@Override public void execute() throws Exception { checkClosed(); session.checkClosed(); session.acknowledge(); } });
/** * Sets the prefeftch policy to one. */ protected void setPrefetchToOne() { ActiveMQPrefetchPolicy prefetchPolicy = getPrefetchPolicy(); prefetchPolicy.setQueuePrefetch(1); prefetchPolicy.setTopicPrefetch(1); prefetchPolicy.setDurableTopicPrefetch(1); prefetchPolicy.setOptimizeDurableTopicPrefetch(1); }
protected ActiveMQConnection createActiveMQConnection(Transport transport, JMSStatsImpl stats) throws Exception { ActiveMQConnection connection = new ActiveMQConnection(transport, getClientIdGenerator(), getConnectionIdGenerator(), stats); return connection; }
private ConsumerId redeliveryPendingInCompetingTransaction(MessageDispatch md) { for (ActiveMQSession activeMQSession: session.connection.getSessions()) { for (ActiveMQMessageConsumer activeMQMessageConsumer : activeMQSession.consumers) { if (activeMQMessageConsumer.redeliveryExpectedInCurrentTransaction(md, false)) { return activeMQMessageConsumer.getConsumerId(); } } } return null; }
/** * Gets the <CODE>Topic</CODE> associated with this subscriber. * * @return this subscriber's <CODE>Topic</CODE> * @throws JMSException if the JMS provider fails to get the topic for this topic * subscriber due to some internal error. */ public Topic getTopic() throws JMSException { checkClosed(); return (Topic) super.getDestination(); }
/** * Gets the <CODE>Queue</CODE> associated with this queue receiver. * * @return this receiver's <CODE>Queue</CODE> * @throws JMSException if the JMS provider fails to get the queue for this * queue receiver due to some internal error. */ @Override public Queue getQueue() throws JMSException { checkClosed(); return (Queue)super.getDestination(); } }
void executeFirst(MessageDispatch message) { messageQueue.enqueueFirst(message); wakeup(); }
/** * @return Returns the QueueConnection. * @throws JMSException */ @Override public QueueConnection createQueueConnection() throws JMSException { return createActiveMQConnection().enforceQueueOnlyConnection(); }