if (physicalConnection.isBound()) { Class<?> type = source.isDirectConnection() ? source.getServiceInterface() : target.getServiceInterface(); DirectConnectionFactory factory = connectionFactories.get(type); if (factory == null) {
if (physicalConnection.isBound()) { Class<?> type = source.isDirectConnection() ? source.getServiceInterface() : target.getServiceInterface(); DirectConnectionFactory factory = connectionFactories.get(type); if (factory == null) {
public void attach(NATSConnectionSource source, PhysicalConnectionTarget target, ChannelConnection connection) { String topic = source.getTopic() != null ? source.getTopic() : source.getDefaultTopic(); connection.setCloseable(() -> connectionManager.release(source.getChannelUri(), topic)); if (target.isDirectConnection()) { Class<?> type = target.getServiceInterface(); connectionManager.createDirectConsumer(type, source); // create consumer, which will be returned by the direct connection factory } else { String deserializerName = source.getData().getDeserializer(); Function deserializer = deserializerName != null ? InstanceResolver.getInstance(deserializerName, info, cm) : null; connection.getEventStream().addHandler(0, new EventStreamHandler() { private EventStreamHandler next; @SuppressWarnings("unchecked") public void handle(Object message, boolean batch) { Object body = deserializer != null ? deserializer.apply(message) : message; next.handle(body, batch); } public void setNext(EventStreamHandler next) { this.next = next; } public EventStreamHandler getNext() { return next; } }); connectionManager.subscribe(source, connection); } }