@Override public String getConnectionId() { return connection.getId(); }
@Override public String getConnectionId() { return connection.getId(); }
private ConnectionCreated(final Connection connection, @Nullable final Instant timestamp, final DittoHeaders dittoHeaders) { super(TYPE, connection.getId(), timestamp, dittoHeaders); this.connection = connection; }
private ConnectionModified(final Connection connection, @Nullable final Instant timestamp, final DittoHeaders dittoHeaders) { super(TYPE, connection.getId(), timestamp, dittoHeaders); this.connection = connection; }
/** * Obtain a supplier of a description of a target of a connection. * * @param target the target. * @param connection the connection. * @return supplier of the description. */ private static Supplier<String> targetDescription(final Target target, final Connection connection) { return () -> MessageFormat.format("Target of address ''{0}'' of connection ''{1}''", target.getAddress(), connection.getId()); }
private Context createContext(final Connection connection) throws NamingException { final String connectionUri = buildAmqpConnectionUriFromConnection(connection); @SuppressWarnings("squid:S1149") final Hashtable<Object, Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory"); env.put("connectionfactory." + connection.getId(), connectionUri); return new InitialContext(env); }
/** * Obtain a supplier of a description of a source of a connection. * * @param source the source. * @param connection the connection. * @return supplier of the description. */ private static Supplier<String> sourceDescription(final Source source, final Connection connection) { return () -> MessageFormat.format("Source of index {0} of connection ''{1}''", source.getIndex(), connection.getId()); }
/** * Obtain a supplier of a description of a target of a connection. * * @param target the target. * @param connection the connection. * @return supplier of the description. */ private static Supplier<String> targetDescription(final Target target, final Connection connection) { return () -> MessageFormat.format("Target of address ''{0}'' of connection ''{1}''", target.getAddress(), connection.getId()); }
/** * Obtain a supplier of a description of a source of a connection. * * @param source the source. * @param connection the connection. * @return supplier of the description. */ private static Supplier<String> sourceDescription(final Source source, final Connection connection) { return () -> MessageFormat.format("Source of index {0} of connection ''{1}''", source.getIndex(), connection.getId()); }
private Context createContext(final Connection connection) throws NamingException { final String connectionUri = buildAmqpConnectionUriFromConnection(connection); @SuppressWarnings("squid:S1149") final Hashtable<Object, Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.qpid.jms.jndi.JmsInitialContextFactory"); env.put("connectionfactory." + connection.getId(), connectionUri); return new InitialContext(env); }
@SuppressWarnings("unused") private AmqpClientActor(final Connection connection, final ConnectionStatus connectionStatus, final JmsConnectionFactory jmsConnectionFactory, final ActorRef conciergeForwarder) { super(connection, connectionStatus, conciergeForwarder); this.jmsConnectionFactory = jmsConnectionFactory; connectionListener = new StatusReportingListener(getSelf(), connection.getId(), log); consumers = new LinkedList<>(); consumerByNamePrefix = new HashMap<>(); }
private ConnectionFailedException buildConnectionFailedException(final Map<String, Exception> failedSources) { return ConnectionFailedException .newBuilder(connection.getId()) .message("Failed to consume sources: " + failedSources.keySet()) .description(() -> failedSources.entrySet() .stream() .map(e -> e.getKey() + ": " + e.getValue().getMessage()) .collect(Collectors.joining(", "))) .build(); }
private ConnectionFailedException buildConnectionFailedException(final Map<String, Exception> failedSources) { return ConnectionFailedException .newBuilder(connection.getId()) .message("Failed to consume sources: " + failedSources.keySet()) .description(() -> failedSources.entrySet() .stream() .map(e -> e.getKey() + ": " + e.getValue().getMessage()) .collect(Collectors.joining(", "))) .build(); }
@SuppressWarnings("unused") private AmqpClientActor(final Connection connection, final ConnectionStatus connectionStatus, final JmsConnectionFactory jmsConnectionFactory, final ActorRef conciergeForwarder) { super(connection, connectionStatus, conciergeForwarder); this.jmsConnectionFactory = jmsConnectionFactory; connectionListener = new StatusReportingListener(getSelf(), connection.getId(), log); consumers = new LinkedList<>(); consumerByNamePrefix = new HashMap<>(); }
private void disconnectAndTell(final javax.jms.Connection connection, @Nullable final ActorRef origin) { log.debug("Closing JMS connection {}", this.connection.getId()); terminateConnection(connection); log.info("Connection <{}> closed.", this.connection.getId()); getSender().tell(new AmqpClientActor.JmsDisconnected(origin), getSelf()); }
private void disconnectAndTell(final javax.jms.Connection connection, @Nullable final ActorRef origin) { log.debug("Closing JMS connection {}", this.connection.getId()); terminateConnection(connection); log.info("Connection <{}> closed.", this.connection.getId()); getSender().tell(new AmqpClientActor.JmsDisconnected(origin), getSelf()); }
/** * @return The JmsConnection */ private JmsConnection createJmsConnection() { try { return jmsConnectionFactory.createConnection(connection, exceptionListener); } catch (final JMSException | NamingException e) { throw ConnectionFailedException.newBuilder(connection.getId()) .message("Failed to connect JMS client:" + e.getMessage()) .cause(e) .build(); } }
private static ConnectionFailedException newConnectionFailedException(final Connection connection, final DittoHeaders dittoHeaders) { return ConnectionFailedException .newBuilder(connection.getId()) .dittoHeaders(dittoHeaders) .description("Could not establish a connection on '" + connection.getHostname() + ":" + connection.getPort() + "'. Make sure the " + "endpoint is reachable and that no firewall prevents the connection.") .build(); }
private static ConnectionFailedException newConnectionFailedException(final Connection connection, final DittoHeaders dittoHeaders) { return ConnectionFailedException .newBuilder(connection.getId()) .dittoHeaders(dittoHeaders) .description("Could not establish a connection on '" + connection.getHostname() + ":" + connection.getPort() + "'. Make sure the " + "endpoint is reachable and that no firewall prevents the connection.") .build(); }
@Test public void createMinimalConnectionConfigurationInstance() { final Connection connection = ConnectivityModelFactory.newConnectionBuilder(ID, TYPE, STATUS, URI) .sources(SOURCES) .targets(TARGETS) .build(); assertThat(connection.getId()).isEqualTo(ID); assertThat((Object) connection.getConnectionType()).isEqualTo(TYPE); assertThat(connection.getUri()).isEqualTo(URI); assertThat(connection.getSources()).isEqualTo(SOURCES); }