public JDKEventHandler(ChannelConnection connection) { this.stream = connection.getEventStream(); this.closeable = connection.getCloseable(); }
public JDKEventHandler(ChannelConnection connection) { this.stream = connection.getEventStream(); this.closeable = connection.getCloseable(); }
public void attach(PhysicalConnectionSource source, NonManagedConnectionTarget target, ChannelConnection connection) { if (target.isDirectConnection()) { target.setCloseable(connection.getCloseable()); target.setProxy(connection.getDirectConnection().get().get()); } else { Consumer<Object> consumer = Cast.cast(target.getConsumer()); EventStream stream = connection.getEventStream(); Class<?> type = stream.getEventType(); if (!Object.class.equals(type)) { // add a filter if the event type is not Object stream.addHandler(new FilterHandler(type)); } stream.addHandler((event, endOfBatch) -> consumer.accept(event)); } }
public void attach(PhysicalConnectionSource source, NonManagedConnectionTarget target, ChannelConnection connection) { if (target.isDirectConnection()) { target.setCloseable(connection.getCloseable()); target.setProxy(connection.getDirectConnection().get().get()); } else { Consumer<Object> consumer = Cast.cast(target.getConsumer()); EventStream stream = connection.getEventStream(); Class<?> type = stream.getEventType(); if (!Object.class.equals(type)) { // add a filter if the event type is not Object stream.addHandler(new FilterHandler(type)); } stream.addHandler((event, endOfBatch) -> consumer.accept(event)); } }
public Object subscribe(Class<?> type, String name, String id, String topic, java.util.function.Consumer<?> consumer) { LogicalChannel logicalChannel = getChannel(name); LogicalConsumer logicalConsumer = createConsumer(type, logicalChannel.getUri()); PhysicalChannel physicalChannel = channelGenerator.generate(logicalChannel, SYNTHETIC_CONTRIBUTION, CONSUMER); channelBuilderRegistry.build(physicalChannel); Map<LogicalChannel, DeliveryType> channels = Collections.singletonMap(logicalChannel, DeliveryType.DEFAULT); List<PhysicalChannelConnection> connections = connectionGenerator.generateConsumer(logicalConsumer, channels); // Two connections will be created: one from the binding to the channel, the other from the channel to the component // the closeable will be set on the connection from the binding to the channel; it must be passed to the component Closeable closeable = null; for (PhysicalChannelConnection connection : connections) { connection.setTopic(topic); connection.getSource().setTopic(topic); connection.getTarget().setTopic(topic); connection.getTarget().setConsumer(consumer); ChannelConnection channelConnection = channelConnector.connect(connection); if (channelConnection.getCloseable() != null) { closeable = channelConnection.getCloseable(); } } return closeable; }
public Object subscribe(Class<?> type, String name, String id, String topic, java.util.function.Consumer<?> consumer) { LogicalChannel logicalChannel = getChannel(name); LogicalConsumer logicalConsumer = createConsumer(type, logicalChannel.getUri()); PhysicalChannel physicalChannel = channelGenerator.generate(logicalChannel, SYNTHETIC_CONTRIBUTION, CONSUMER); channelBuilderRegistry.build(physicalChannel); Map<LogicalChannel, DeliveryType> channels = Collections.singletonMap(logicalChannel, DeliveryType.DEFAULT); List<PhysicalChannelConnection> connections = connectionGenerator.generateConsumer(logicalConsumer, channels); // Two connections will be created: one from the binding to the channel, the other from the channel to the component // the closeable will be set on the connection from the binding to the channel; it must be passed to the component Closeable closeable = null; for (PhysicalChannelConnection connection : connections) { connection.setTopic(topic); connection.getSource().setTopic(topic); connection.getTarget().setTopic(topic); connection.getTarget().setConsumer(consumer); ChannelConnection channelConnection = channelConnector.connect(connection); if (channelConnection.getCloseable() != null) { closeable = channelConnection.getCloseable(); } } return closeable; }