public class SolConnectionConsumer extends Object implements SolConnectionConsumerIF
+---------------------------------------------------------------------------------+
|ackMode Destination ConnectionConsumerTransactionStrategy |
+---------------------------------------------------------------------------------+
|AUTO_ACKNOWLEDGE |
|CLIENT_ACKNOWLEDGE * ConnectionConsumerNoTransactionStrategy |
|DUPS_OK_ACKNOWLEDGE |
+---------------------------------------------------------------------------------+
|SESSION_TRANSACTED Durable ConnectionConsumerFakeTransactionStrategy |
| Non-Durable ConnectionConsumerLocalTxStrategy |
+---------------------------------------------------------------------------------+
In non-transacted acknowledgement modes, the 'NoTransactionStrategy' is used, which lets the app or container simply control calling Message.acknowledge() normally.
In transacted mode, for durable endpoints, we fake transactions for higher performance. We leave messages unacked to the appliance, and ack the batch of messages associated with a session when that session's commit() is called. When a rollback() is requested, we stop polling new messages, and wait (up to 5s) for any outstanding messages already given to the ServerSessionPool to be acked or rolledback. Then, we destroy the flow and recreate it, causing redelivery of every unacked message.
In transacted mode, for non-durable endpoints, the above approach doesn't work because the endpoint would be deleted when closing the first flow, and they are exclusive so we cannot open a second flow before closing the first. We therefore use an actual transacted-session with the appliance, within which the consumer flow is contained. This is much slower because to demarcate transactions, we must have only ONE active at a time. In this mode, a single message batch is read from the flow, handed off to a ServerSession, and we block until its commit() or rollback() is called. Once the commit/rollback occurs, we unblock and call commit/rollback on the underlying JCSMP transaction, then return to polling for more messages.
| Constructor and Description |
|---|
SolConnectionConsumer(SolConnectionIF conn,
SolDestinationInfo destInfo,
String messageSelector,
ServerSessionPool serverPool,
int maxMessages,
JMSState state) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the connection consumer.
|
void |
commitBatch(Collection<Message> msgs) |
ServerSessionPool |
getServerSessionPool()
Gets the server session pool associated with this connection consumer.
|
void |
rollbackBatch(Collection<Message> msgs) |
void |
start() |
void |
stop() |
String |
toString() |
public SolConnectionConsumer(SolConnectionIF conn, SolDestinationInfo destInfo, String messageSelector, ServerSessionPool serverPool, int maxMessages, JMSState state) throws JMSException
JMSExceptionpublic ServerSessionPool getServerSessionPool() throws JMSException
ConnectionConsumergetServerSessionPool in interface ConnectionConsumerJMSException - if the JMS provider fails to get the server
session pool associated with this consumer due
to some internal error.public void start()
throws JMSException
start in interface SolStartableIFJMSExceptionpublic void stop()
throws JMSException
stop in interface SolStartableIFJMSExceptionpublic void close()
throws JMSException
ConnectionConsumerSince a provider may allocate some resources on behalf of a connection consumer outside the Java virtual machine, clients should close these resources when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.
close in interface SolCloseableIFclose in interface ConnectionConsumerJMSException - if the JMS provider fails to release resources
on behalf of the connection consumer or fails
to close the connection consumer.public void commitBatch(Collection<Message> msgs) throws JMSException
commitBatch in interface SolConnectionConsumerIFJMSExceptionpublic void rollbackBatch(Collection<Message> msgs) throws JMSException
rollbackBatch in interface SolConnectionConsumerIFJMSExceptionCopyright 2004-2019 Solace Corporation. All rights reserved.