test_class.declarator: actorSystem
test_class.modifier: @SuppressWarnings("NullableProblems") private static
test_class.original_string: @SuppressWarnings("NullableProblems") private static ActorSystem actorSystem;
test_class.type: ActorSystem
test_class.var_name: actorSystem
test_class.declarator: connectionId = TestConstants.createRandomConnectionId()
test_class.modifier: private static final
test_class.original_string: private static final ConnectionId connectionId = TestConstants.createRandomConnectionId();
test_class.type: ConnectionId
test_class.var_name: connectionId
test_class.declarator: connection
test_class.modifier: private static
test_class.original_string: private static Connection connection;
test_class.type: Connection
test_class.var_name: connection
test_class.declarator: mockSession = Mockito.mock(Session.class)
test_class.modifier: @Mock private final
test_class.original_string: @Mock private final Session mockSession = Mockito.mock(Session.class);
test_class.type: Session
test_class.var_name: mockSession
test_class.declarator: mockConnection = Mockito.mock(JmsConnection.class)
test_class.modifier: @Mock private final
test_class.original_string: @Mock private final JmsConnection mockConnection = Mockito.mock(JmsConnection.class);
test_class.type: JmsConnection
test_class.var_name: mockConnection
test_class.declarator: jmsConnectionFactory = (connection1, exceptionListener) -> mockConnection
test_class.modifier: private final
test_class.original_string: private final JmsConnectionFactory jmsConnectionFactory = (connection1, exceptionListener) -> mockConnection;
test_class.type: JmsConnectionFactory
test_class.var_name: jmsConnectionFactory
test_class.file: services/connectivity/messaging/src/test/java/org/eclipse/ditto/services/connectivity/messaging/amqp/JmsConnectionHandlingActorTest.java
test_class.identifier: JmsConnectionHandlingActorTest
test_class.superclass: extends WithMockServers
test_case.body: @Test
      public void handleRecoverSession() throws JMSException {
          new TestKit(actorSystem) {{
  
              final Props props = JMSConnectionHandlingActor.props(connection, e -> {}, jmsConnectionFactory);
              final ActorRef connectionHandlingActor = watch(actorSystem.actorOf(props));
  
              final TestProbe origin = TestProbe.apply(actorSystem);
  
              final JmsSession existingSession = Mockito.mock(JmsSession.class);
              connectionHandlingActor.tell(
                      new AmqpClientActor.JmsRecoverSession(origin.ref(), mockConnection, existingSession),
                      getRef());
  
              final AmqpClientActor.JmsSessionRecovered recovered =
                      expectMsgClass(AmqpClientActor.JmsSessionRecovered.class);
              assertThat(recovered.getOrigin()).contains(origin.ref());
              assertThat(recovered.getSession()).isSameAs(mockSession);
  
              verify(existingSession).close();
              verify(mockConnection).createSession(anyInt());
              verify(mockSession, times(connection.getSources()
                      .stream()
                      .mapToInt(s -> s.getAddresses().size() * s.getConsumerCount())
                      .sum())).createConsumer(any());
          }};
      }
test_case.class_method_signature: JmsConnectionHandlingActorTest.handleRecoverSession()
test_case.full_signature: @Test public void handleRecoverSession()
test_case.identifier: handleRecoverSession
test_case.invocations: props watch actorOf apply mock tell ref getRef expectMsgClass contains assertThat getOrigin ref isSameAs assertThat getSession close verify createSession verify anyInt createConsumer verify times sum mapToInt stream getSources size getAddresses getConsumerCount any
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void handleRecoverSession()
focal_class.declarator: JMS_INDIVIDUAL_ACKNOWLEDGE_MODE_MAGIC_NUMBER = 101
focal_class.modifier: private static final
focal_class.original_string: private static final int JMS_INDIVIDUAL_ACKNOWLEDGE_MODE_MAGIC_NUMBER = 101;
focal_class.type: int
focal_class.var_name: JMS_INDIVIDUAL_ACKNOWLEDGE_MODE_MAGIC_NUMBER
focal_class.declarator: ACTOR_NAME_PREFIX = "jmsConnectionHandling-"
focal_class.modifier: static final
focal_class.original_string: static final String ACTOR_NAME_PREFIX = "jmsConnectionHandling-";
focal_class.type: String
focal_class.var_name: ACTOR_NAME_PREFIX
focal_class.declarator: DISPATCHER_NAME = "jms-connection-handling-dispatcher"
focal_class.modifier: private static final
focal_class.original_string: private static final String DISPATCHER_NAME = "jms-connection-handling-dispatcher";
focal_class.type: String
focal_class.var_name: DISPATCHER_NAME
focal_class.declarator: log = LogUtil.obtain(this)
focal_class.modifier: private final
focal_class.original_string: private final DiagnosticLoggingAdapter log = LogUtil.obtain(this);
focal_class.type: DiagnosticLoggingAdapter
focal_class.var_name: log
focal_class.declarator: connection
focal_class.modifier: private final
focal_class.original_string: private final Connection connection;
focal_class.type: Connection
focal_class.var_name: connection
focal_class.declarator: exceptionListener
focal_class.modifier: private final
focal_class.original_string: private final ExceptionListener exceptionListener;
focal_class.type: ExceptionListener
focal_class.var_name: exceptionListener
focal_class.declarator: jmsConnectionFactory
focal_class.modifier: private final
focal_class.original_string: private final JmsConnectionFactory jmsConnectionFactory;
focal_class.type: JmsConnectionFactory
focal_class.var_name: jmsConnectionFactory
focal_class.declarator: currentSession = null
focal_class.modifier: @Nullable private
focal_class.original_string: @Nullable private Session currentSession = null;
focal_class.type: Session
focal_class.var_name: currentSession
focal_class.file: services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/amqp/JMSConnectionHandlingActor.java
focal_class.identifier: JMSConnectionHandlingActor
focal_class.class_method_signature: JMSConnectionHandlingActor.JMSConnectionHandlingActor(final Connection connection, final ExceptionListener exceptionListener,
              final JmsConnectionFactory jmsConnectionFactory)
focal_class.full_signature: @SuppressWarnings("unused") private  JMSConnectionHandlingActor(final Connection connection, final ExceptionListener exceptionListener,
              final JmsConnectionFactory jmsConnectionFactory)
focal_class.identifier: JMSConnectionHandlingActor
focal_class.modifiers: @SuppressWarnings("unused") private
focal_class.parameters: (final Connection connection, final ExceptionListener exceptionListener,
              final JmsConnectionFactory jmsConnectionFactory)
focal_class.signature:  JMSConnectionHandlingActor(final Connection connection, final ExceptionListener exceptionListener,
              final JmsConnectionFactory jmsConnectionFactory)
focal_class.class_method_signature: JMSConnectionHandlingActor.props(final Connection connection, final ExceptionListener exceptionListener,
              final JmsConnectionFactory jmsConnectionFactory)
focal_class.full_signature: static Props props(final Connection connection, final ExceptionListener exceptionListener,
              final JmsConnectionFactory jmsConnectionFactory)
focal_class.identifier: props
focal_class.modifiers: static
focal_class.parameters: (final Connection connection, final ExceptionListener exceptionListener,
              final JmsConnectionFactory jmsConnectionFactory)
focal_class.return: Props
focal_class.signature: Props props(final Connection connection, final ExceptionListener exceptionListener,
              final JmsConnectionFactory jmsConnectionFactory)
focal_class.class_method_signature: JMSConnectionHandlingActor.propsWithOwnDispatcher(final Connection connection, final ExceptionListener exceptionListener,
              final JmsConnectionFactory jmsConnectionFactory)
focal_class.full_signature: static Props propsWithOwnDispatcher(final Connection connection, final ExceptionListener exceptionListener,
              final JmsConnectionFactory jmsConnectionFactory)
focal_class.identifier: propsWithOwnDispatcher
focal_class.modifiers: static
focal_class.parameters: (final Connection connection, final ExceptionListener exceptionListener,
              final JmsConnectionFactory jmsConnectionFactory)
focal_class.return: Props
focal_class.signature: Props propsWithOwnDispatcher(final Connection connection, final ExceptionListener exceptionListener,
              final JmsConnectionFactory jmsConnectionFactory)
focal_class.class_method_signature: JMSConnectionHandlingActor.getOwnDispatcher(final ActorSystem actorSystem)
focal_class.full_signature: static MessageDispatcher getOwnDispatcher(final ActorSystem actorSystem)
focal_class.identifier: getOwnDispatcher
focal_class.modifiers: static
focal_class.parameters: (final ActorSystem actorSystem)
focal_class.return: MessageDispatcher
focal_class.signature: MessageDispatcher getOwnDispatcher(final ActorSystem actorSystem)
focal_class.class_method_signature: JMSConnectionHandlingActor.createReceive()
focal_class.full_signature: @Override public Receive createReceive()
focal_class.identifier: createReceive
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Receive
focal_class.signature: Receive createReceive()
focal_class.class_method_signature: JMSConnectionHandlingActor.createMessageConsumer(final AmqpConsumerActor.CreateMessageConsumer command)
focal_class.full_signature: private void createMessageConsumer(final AmqpConsumerActor.CreateMessageConsumer command)
focal_class.identifier: createMessageConsumer
focal_class.modifiers: private
focal_class.parameters: (final AmqpConsumerActor.CreateMessageConsumer command)
focal_class.return: void
focal_class.signature: void createMessageConsumer(final AmqpConsumerActor.CreateMessageConsumer command)
focal_class.class_method_signature: JMSConnectionHandlingActor.handleCloseSession(final AmqpClientActor.JmsCloseSession closeSession)
focal_class.full_signature: private void handleCloseSession(final AmqpClientActor.JmsCloseSession closeSession)
focal_class.identifier: handleCloseSession
focal_class.modifiers: private
focal_class.parameters: (final AmqpClientActor.JmsCloseSession closeSession)
focal_class.return: void
focal_class.signature: void handleCloseSession(final AmqpClientActor.JmsCloseSession closeSession)
focal_class.class_method_signature: JMSConnectionHandlingActor.handleRecoverSession(final AmqpClientActor.JmsRecoverSession recoverSession)
focal_class.full_signature: private void handleRecoverSession(final AmqpClientActor.JmsRecoverSession recoverSession)
focal_class.identifier: handleRecoverSession
focal_class.modifiers: private
focal_class.parameters: (final AmqpClientActor.JmsRecoverSession recoverSession)
focal_class.return: void
focal_class.signature: void handleRecoverSession(final AmqpClientActor.JmsRecoverSession recoverSession)
focal_class.class_method_signature: JMSConnectionHandlingActor.handleConnect(final AmqpClientActor.JmsConnect connect)
focal_class.full_signature: private void handleConnect(final AmqpClientActor.JmsConnect connect)
focal_class.identifier: handleConnect
focal_class.modifiers: private
focal_class.parameters: (final AmqpClientActor.JmsConnect connect)
focal_class.return: void
focal_class.signature: void handleConnect(final AmqpClientActor.JmsConnect connect)
focal_class.class_method_signature: JMSConnectionHandlingActor.handleDisconnect(final AmqpClientActor.JmsDisconnect disconnect)
focal_class.full_signature: private void handleDisconnect(final AmqpClientActor.JmsDisconnect disconnect)
focal_class.identifier: handleDisconnect
focal_class.modifiers: private
focal_class.parameters: (final AmqpClientActor.JmsDisconnect disconnect)
focal_class.return: void
focal_class.signature: void handleDisconnect(final AmqpClientActor.JmsDisconnect disconnect)
focal_class.class_method_signature: JMSConnectionHandlingActor.maybeConnectAndTell(final ActorRef sender, @Nullable final ActorRef origin)
focal_class.full_signature: private void maybeConnectAndTell(final ActorRef sender, @Nullable final ActorRef origin)
focal_class.identifier: maybeConnectAndTell
focal_class.modifiers: private
focal_class.parameters: (final ActorRef sender, @Nullable final ActorRef origin)
focal_class.return: void
focal_class.signature: void maybeConnectAndTell(final ActorRef sender, @Nullable final ActorRef origin)
focal_class.class_method_signature: JMSConnectionHandlingActor.tryConnect(@Nullable final ActorRef origin)
focal_class.full_signature: private AmqpClientActor.JmsConnected tryConnect(@Nullable final ActorRef origin)
focal_class.identifier: tryConnect
focal_class.modifiers: private
focal_class.parameters: (@Nullable final ActorRef origin)
focal_class.return: AmqpClientActor.JmsConnected
focal_class.signature: AmqpClientActor.JmsConnected tryConnect(@Nullable final ActorRef origin)
focal_class.class_method_signature: JMSConnectionHandlingActor.startConnection(final JmsConnection jmsConnection)
focal_class.full_signature: private void startConnection(final JmsConnection jmsConnection)
focal_class.identifier: startConnection
focal_class.modifiers: private
focal_class.parameters: (final JmsConnection jmsConnection)
focal_class.return: void
focal_class.signature: void startConnection(final JmsConnection jmsConnection)
focal_class.class_method_signature: JMSConnectionHandlingActor.createSession(final JmsConnection jmsConnection)
focal_class.full_signature: private Session createSession(final JmsConnection jmsConnection)
focal_class.identifier: createSession
focal_class.modifiers: private
focal_class.parameters: (final JmsConnection jmsConnection)
focal_class.return: Session
focal_class.signature: Session createSession(final JmsConnection jmsConnection)
focal_class.class_method_signature: JMSConnectionHandlingActor.safelyExecuteJmsOperation(@Nullable final JmsConnection jmsConnection,
              final String task, final ThrowingSupplier<T> jmsOperation)
focal_class.full_signature: private T safelyExecuteJmsOperation(@Nullable final JmsConnection jmsConnection,
              final String task, final ThrowingSupplier<T> jmsOperation)
focal_class.identifier: safelyExecuteJmsOperation
focal_class.modifiers: private
focal_class.parameters: (@Nullable final JmsConnection jmsConnection,
              final String task, final ThrowingSupplier<T> jmsOperation)
focal_class.return: T
focal_class.signature: T safelyExecuteJmsOperation(@Nullable final JmsConnection jmsConnection,
              final String task, final ThrowingSupplier<T> jmsOperation)
focal_class.class_method_signature: JMSConnectionHandlingActor.createConsumers(final Session session)
focal_class.full_signature: private List<ConsumerData> createConsumers(final Session session)
focal_class.identifier: createConsumers
focal_class.modifiers: private
focal_class.parameters: (final Session session)
focal_class.return: List<ConsumerData>
focal_class.signature: List<ConsumerData> createConsumers(final Session session)
focal_class.class_method_signature: JMSConnectionHandlingActor.createJmsConsumer(final Session session,
              final Map<String, Exception> failedSources,
              final Source source,
              final String sourceAddress,
              final String addressWithIndex)
focal_class.full_signature: @Nullable private ConsumerData createJmsConsumer(final Session session,
              final Map<String, Exception> failedSources,
              final Source source,
              final String sourceAddress,
              final String addressWithIndex)
focal_class.identifier: createJmsConsumer
focal_class.modifiers: @Nullable private
focal_class.parameters: (final Session session,
              final Map<String, Exception> failedSources,
              final Source source,
              final String sourceAddress,
              final String addressWithIndex)
focal_class.return: ConsumerData
focal_class.signature: ConsumerData createJmsConsumer(final Session session,
              final Map<String, Exception> failedSources,
              final Source source,
              final String sourceAddress,
              final String addressWithIndex)
focal_class.class_method_signature: JMSConnectionHandlingActor.createJmsConnection()
focal_class.full_signature: private JmsConnection createJmsConnection()
focal_class.identifier: createJmsConnection
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: JmsConnection
focal_class.signature: JmsConnection createJmsConnection()
focal_class.class_method_signature: JMSConnectionHandlingActor.buildConnectionFailedException(final Map<String, Exception> failedSources)
focal_class.full_signature: private ConnectionFailedException buildConnectionFailedException(final Map<String, Exception> failedSources)
focal_class.identifier: buildConnectionFailedException
focal_class.modifiers: private
focal_class.parameters: (final Map<String, Exception> failedSources)
focal_class.return: ConnectionFailedException
focal_class.signature: ConnectionFailedException buildConnectionFailedException(final Map<String, Exception> failedSources)
focal_class.class_method_signature: JMSConnectionHandlingActor.terminateConnection(@Nullable final javax.jms.Connection jmsConnection)
focal_class.full_signature: private void terminateConnection(@Nullable final javax.jms.Connection jmsConnection)
focal_class.identifier: terminateConnection
focal_class.modifiers: private
focal_class.parameters: (@Nullable final javax.jms.Connection jmsConnection)
focal_class.return: void
focal_class.signature: void terminateConnection(@Nullable final javax.jms.Connection jmsConnection)
focal_class.class_method_signature: JMSConnectionHandlingActor.disconnectAndTell(final javax.jms.Connection connection, @Nullable final ActorRef origin)
focal_class.full_signature: private void disconnectAndTell(final javax.jms.Connection connection, @Nullable final ActorRef origin)
focal_class.identifier: disconnectAndTell
focal_class.modifiers: private
focal_class.parameters: (final javax.jms.Connection connection, @Nullable final ActorRef origin)
focal_class.return: void
focal_class.signature: void disconnectAndTell(final javax.jms.Connection connection, @Nullable final ActorRef origin)
focal_class.superclass: extends AbstractActor
focal_method.body: private void handleRecoverSession(final AmqpClientActor.JmsRecoverSession recoverSession) {
  
          log.debug("Processing JmsRecoverSession message.");
          final ActorRef sender = getSender();
          final ActorRef origin = recoverSession.getOrigin().orElse(null);
          final ActorRef self = getSelf();
  
          // try to close an existing session first
          recoverSession.getSession().ifPresent(session -> {
              try {
                  session.close();
              } catch (final JMSException e) {
                  log.debug("Failed to close previous session, ignore.");
              }
          });
  
          final Optional<javax.jms.Connection> connectionOptional = recoverSession.getConnection();
  
          if (connectionOptional.isPresent()) {
              final JmsConnection jmsConnection = (JmsConnection) connectionOptional.get();
              try {
                  log.debug("Creating new JMS session.");
                  final Session session = createSession(jmsConnection);
                  log.debug("Creating consumers for new session.");
                  final List<ConsumerData> consumers = createConsumers(session);
                  final AmqpClientActor.JmsSessionRecovered r =
                          new AmqpClientActor.JmsSessionRecovered(origin, session, consumers);
                  sender.tell(r, self);
                  log.debug("Session of connection <{}> recovered successfully.", connection.getId());
              } catch (final ConnectionFailedException e) {
                  sender.tell(new ImmutableConnectionFailure(origin, e, e.getMessage()), self);
                  log.warning(e.getMessage());
              } catch (final Exception e) {
                  sender.tell(new ImmutableConnectionFailure(origin, e, e.getMessage()), self);
                  log.error("Unexpected error: {}", e.getMessage());
              }
          } else {
              log.info("Recovering session failed, no connection available.");
              sender.tell(new ImmutableConnectionFailure(origin, null,
                      "Session recovery failed, no connection available."), self);
          }
      }
focal_method.class_method_signature: JMSConnectionHandlingActor.handleRecoverSession(final AmqpClientActor.JmsRecoverSession recoverSession)
focal_method.full_signature: private void handleRecoverSession(final AmqpClientActor.JmsRecoverSession recoverSession)
focal_method.identifier: handleRecoverSession
focal_method.invocations: debug getSender orElse getOrigin getSelf ifPresent getSession close debug getConnection isPresent get debug createSession debug createConsumers tell debug getId tell getMessage warning getMessage tell getMessage error getMessage info tell
focal_method.modifiers: private
focal_method.parameters: (final AmqpClientActor.JmsRecoverSession recoverSession)
focal_method.return: void
focal_method.signature: void handleRecoverSession(final AmqpClientActor.JmsRecoverSession recoverSession)