/** * Convenience for {@link #jmsTopicBuilder(DistributedSupplier)}. Creates a * connection without any authentication parameters and uses non-transacted * sessions with {@code Session.AUTO_ACKNOWLEDGE} mode. If a received item * is not an instance of {@code javax.jms.Message}, the sink wraps {@code * item.toString()} into a {@link javax.jms.TextMessage}. * * @param factorySupplier supplier to obtain JMS connection factory * @param name the name of the queue */ @Nonnull public static <T> Sink<T> jmsTopic( @Nonnull DistributedSupplier<ConnectionFactory> factorySupplier, @Nonnull String name ) { return Sinks.<T>jmsTopicBuilder(factorySupplier) .destinationName(name) .build(); }
/** * Convenience for {@link #jmsQueueBuilder(DistributedSupplier)}. Creates a * connection without any authentication parameters and uses non-transacted * sessions with {@code Session.AUTO_ACKNOWLEDGE} mode. If a received item * is not an instance of {@code javax.jms.Message}, the sink wraps {@code * item.toString()} into a {@link javax.jms.TextMessage}. * * @param factorySupplier supplier to obtain JMS connection factory * @param name the name of the queue */ @Nonnull public static <T> Sink<T> jmsQueue( @Nonnull DistributedSupplier<ConnectionFactory> factorySupplier, @Nonnull String name ) { return Sinks.<T>jmsQueueBuilder(factorySupplier) .destinationName(name) .build(); }
private static Pipeline buildPipeline() { Pipeline p = Pipeline.create(); p.drawFrom(Sources.jmsTopic(() -> new ActiveMQConnectionFactory(ActiveMQBroker.BROKER_URL), INPUT_TOPIC)) .filter(message -> message.getJMSPriority() > 3) .map(message -> (TextMessage) message) // print the message text to the log .peek(TextMessage::getText) .drainTo(Sinks.<TextMessage>jmsTopicBuilder(() -> new ActiveMQConnectionFactory(ActiveMQBroker.BROKER_URL)) .destinationName(OUTPUT_TOPIC) .messageFn((session, message) -> { TextMessage textMessage = session.createTextMessage(message.getText()); textMessage.setBooleanProperty("isActive", true); textMessage.setJMSPriority(8); return textMessage; }) .build()); return p; }
private static Pipeline buildPipeline() { Pipeline p = Pipeline.create(); p.drawFrom(Sources.jmsQueue(() -> new ActiveMQConnectionFactory(ActiveMQBroker.BROKER_URL), INPUT_QUEUE)) .filter(message -> message.getJMSPriority() > 3) .map(message -> (TextMessage) message) // print the message text to the log .peek(TextMessage::getText) .drainTo(Sinks.<TextMessage>jmsQueueBuilder(() -> new ActiveMQConnectionFactory(ActiveMQBroker.BROKER_URL)) .destinationName(OUTPUT_QUEUE) .messageFn((session, message) -> { // create new text message with the same text and few additional properties TextMessage textMessage = session.createTextMessage(message.getText()); textMessage.setBooleanProperty("isActive", true); textMessage.setJMSPriority(8); return textMessage; } ) .build()); return p; }