1818import java .util .Set ;
1919import java .util .concurrent .ConcurrentHashMap ;
2020
21- import javax .jms .IllegalStateException ;
22- import javax .jms .Connection ;
23- import javax .jms .ConnectionConsumer ;
24- import javax .jms .ConnectionMetaData ;
25- import javax .jms .Destination ;
26- import javax .jms .ExceptionListener ;
27- import javax .jms .InvalidClientIDException ;
28- import javax .jms .JMSException ;
29- import javax .jms .Queue ;
30- import javax .jms .QueueConnection ;
31- import javax .jms .QueueSession ;
32- import javax .jms .ServerSessionPool ;
33- import javax .jms .Session ;
34- import javax .jms .Topic ;
21+ import jakarta .jms .IllegalStateException ;
22+ import jakarta .jms .Connection ;
23+ import jakarta .jms .ConnectionConsumer ;
24+ import jakarta .jms .ConnectionMetaData ;
25+ import jakarta .jms .Destination ;
26+ import jakarta .jms .ExceptionListener ;
27+ import jakarta .jms .InvalidClientIDException ;
28+ import jakarta .jms .JMSException ;
29+ import jakarta .jms .Queue ;
30+ import jakarta .jms .QueueConnection ;
31+ import jakarta .jms .QueueSession ;
32+ import jakarta .jms .ServerSessionPool ;
33+ import jakarta .jms .Session ;
34+ import jakarta .jms .Topic ;
3535
3636import org .slf4j .Logger ;
3737import org .slf4j .LoggerFactory ;
@@ -107,7 +107,7 @@ public class SQSConnection implements Connection, QueueConnection {
107107 */
108108 private volatile boolean actionOnConnectionTaken = false ;
109109
110- private final Set <Session > sessions = Collections .newSetFromMap (new ConcurrentHashMap <Session , Boolean >());
110+ private final Set <Session > sessions = Collections .newSetFromMap (new ConcurrentHashMap <>());
111111
112112 SQSConnection (AmazonSQSMessagingClientWrapper amazonSQSClientJMSWrapper , int numberOfMessagesToPrefetch ) {
113113 amazonSQSClient = amazonSQSClientJMSWrapper ;
@@ -167,7 +167,7 @@ public QueueSession createQueueSession(boolean transacted, int acknowledgeMode)
167167 *
168168 * @param transacted
169169 * Only false is supported.
170- * @param acknowledgeMode
170+ * @param sessionMode
171171 * Legal values are <code>Session.AUTO_ACKNOWLEDGE</code>,
172172 * <code>Session.CLIENT_ACKNOWLEDGE</code>,
173173 * <code>Session.DUPS_OK_ACKNOWLEDGE</code>, and
@@ -179,26 +179,26 @@ public QueueSession createQueueSession(boolean transacted, int acknowledgeMode)
179179 * transaction and acknowledge mode.
180180 */
181181 @ Override
182- public Session createSession (boolean transacted , int acknowledgeMode ) throws JMSException {
182+ public Session createSession (boolean transacted , int sessionMode ) throws JMSException {
183183 checkClosed ();
184184 actionOnConnectionTaken = true ;
185- if (transacted || acknowledgeMode == Session .SESSION_TRANSACTED )
185+ if (transacted || sessionMode == Session .SESSION_TRANSACTED )
186186 throw new JMSException ("SQSSession does not support transacted" );
187187
188188 SQSSession sqsSession ;
189- if (acknowledgeMode == Session .AUTO_ACKNOWLEDGE ) {
190- sqsSession = new SQSSession (this , AcknowledgeMode .ACK_AUTO .withOriginalAcknowledgeMode (acknowledgeMode ));
191- } else if (acknowledgeMode == Session .CLIENT_ACKNOWLEDGE || acknowledgeMode == Session .DUPS_OK_ACKNOWLEDGE ) {
192- sqsSession = new SQSSession (this , AcknowledgeMode .ACK_RANGE .withOriginalAcknowledgeMode (acknowledgeMode ));
193- } else if (acknowledgeMode == SQSSession .UNORDERED_ACKNOWLEDGE ) {
194- sqsSession = new SQSSession (this , AcknowledgeMode .ACK_UNORDERED .withOriginalAcknowledgeMode (acknowledgeMode ));
189+ if (sessionMode == Session .AUTO_ACKNOWLEDGE ) {
190+ sqsSession = new SQSSession (this , AcknowledgeMode .ACK_AUTO .withOriginalAcknowledgeMode (sessionMode ));
191+ } else if (sessionMode == Session .CLIENT_ACKNOWLEDGE || sessionMode == Session .DUPS_OK_ACKNOWLEDGE ) {
192+ sqsSession = new SQSSession (this , AcknowledgeMode .ACK_RANGE .withOriginalAcknowledgeMode (sessionMode ));
193+ } else if (sessionMode == SQSSession .UNORDERED_ACKNOWLEDGE ) {
194+ sqsSession = new SQSSession (this , AcknowledgeMode .ACK_UNORDERED .withOriginalAcknowledgeMode (sessionMode ));
195195 } else {
196196 LOG .error ("Unrecognized acknowledgeMode. Cannot create Session." );
197197 throw new JMSException ("Unrecognized acknowledgeMode. Cannot create Session." );
198198 }
199199 synchronized (stateLock ) {
200200 if (closing ) {
201- /**
201+ /*
202202 * SQSSession's constructor has already started a SQSSessionCallbackScheduler which should be closed
203203 * before leaving sqsSession object.
204204 */
@@ -207,18 +207,27 @@ public Session createSession(boolean transacted, int acknowledgeMode) throws JMS
207207 }
208208 sessions .add (sqsSession );
209209
210- /**
210+ /*
211211 * Any new sessions created on a started connection should be
212212 * started on creation
213213 */
214214 if (running ) {
215215 sqsSession .start ();
216216 }
217217 }
218-
219218 return sqsSession ;
220219 }
221220
221+ @ Override
222+ public Session createSession (int sessionMode ) throws JMSException {
223+ return createSession (false , sessionMode );
224+ }
225+
226+ @ Override
227+ public Session createSession () throws JMSException {
228+ throw new JMSException (SQSMessagingClientConstants .UNSUPPORTED_METHOD );
229+ }
230+
222231 @ Override
223232 public ExceptionListener getExceptionListener () throws JMSException {
224233 checkClosing ();
@@ -303,7 +312,7 @@ public void start() throws JMSException {
303312 * This means that a client can rely on the fact that none of its message
304313 * listeners will be called and that all threads of control waiting for
305314 * receive calls to return will not return with a message until the
306- * connection is restarted. The receive timers for a stopped connection
315+ * connection is restarted. The received timers for a stopped connection
307316 * continue to advance, so receives may time out while the connection is
308317 * stopped.
309318 * <P>
@@ -336,7 +345,7 @@ public void stop() throws JMSException {
336345 try {
337346 for (Session session : sessions ) {
338347 SQSSession sqsSession = (SQSSession ) session ;
339- /**
348+ /*
340349 * Session stop call blocks until receives and/or
341350 * message listeners in progress have completed.
342351 */
@@ -375,12 +384,11 @@ public void stop() throws JMSException {
375384 */
376385 @ Override
377386 public void close () throws JMSException {
378-
379387 if (closed ) {
380388 return ;
381389 }
382390
383- /**
391+ /*
384392 * A message listener must not attempt to close its own connection as
385393 * this would lead to deadlock.
386394 */
@@ -411,7 +419,7 @@ public void close() throws JMSException {
411419
412420 }
413421 }
414- }/** Blocks until closing of the connection completes */
422+ }/* Blocks until closing of the connection completes */
415423 else {
416424 synchronized (stateLock ) {
417425 while (!closed ) {
@@ -432,7 +440,7 @@ public void close() throws JMSException {
432440 * from list of Sessions.
433441 */
434442 void removeSession (Session session ) throws JMSException {
435- /**
443+ /*
436444 * No need to synchronize on stateLock assuming this can be only called
437445 * by session.close(), on which point connection will not be worried
438446 * about missing closing this session.
@@ -505,9 +513,22 @@ public ConnectionConsumer createConnectionConsumer(Destination destination, Stri
505513 throw new JMSException (SQSMessagingClientConstants .UNSUPPORTED_METHOD );
506514 }
507515
516+ @ Override
517+ public ConnectionConsumer createSharedConnectionConsumer (Topic topic , String subscriptionName , String messageSelector , ServerSessionPool sessionPool , int maxMessages ) throws JMSException {
518+ throw new JMSException (SQSMessagingClientConstants .UNSUPPORTED_METHOD );
519+ }
520+
508521 /** This method is not supported. */
509522 @ Override
510- public ConnectionConsumer createDurableConnectionConsumer (Topic topic , String subscriptionName , String messageSelector ,
523+ public ConnectionConsumer createDurableConnectionConsumer (
524+ Topic topic , String subscriptionName , String messageSelector ,
525+ ServerSessionPool sessionPool , int maxMessages ) throws JMSException {
526+ throw new JMSException (SQSMessagingClientConstants .UNSUPPORTED_METHOD );
527+ }
528+
529+ @ Override
530+ public ConnectionConsumer createSharedDurableConnectionConsumer (
531+ Topic topic , String subscriptionName , String messageSelector ,
511532 ServerSessionPool sessionPool , int maxMessages ) throws JMSException {
512533 throw new JMSException (SQSMessagingClientConstants .UNSUPPORTED_METHOD );
513534 }
0 commit comments