English 中文(简体)
Bridge JMS Message to SSE Endpoint in Quarkus
原标题:

In Spring project, I used Sinks to emit events into a SSE endpoint, it worked well, check:

https://github.com/hantsy/spring-graphql-sample/blob/master/dgs-subscription-sse/src/main/kotlin/com/example/demo/DataFetchers.kt#L33

But when I tried to Smallrye Mutiny MultiEmitterProcessor to archive the same purpose, it failed.

The example project is https://github.com/hantsy/quarkus-sandbox/tree/master/jms

    MultiEmitterProcessor<Message> emitterProcessor = MultiEmitterProcessor.create();

    void receive() {
        var consumer = jmsContext.createConsumer(helloQueue);
        consumer.setMessageListener(
                msg -> {
                    try {
                        var received = jsonb.fromJson(msg.getBody(String.class), Message.class);
                        LOGGER.log(Level.INFO, "consuming message: {0}", received);
                        emitterProcessor.emit(received);
                    } catch (JMSException e) {
                        throw new RuntimeException(e);
                    }
                }
        );
    }

And in the Resource class,

    @GET
    @Produces(MediaType.SERVER_SENT_EVENTS)
    @RestStreamElementType(MediaType.APPLICATION_JSON)
    public Multi<Message> stream() {
        // see: https://github.com/quarkusio/quarkus/issues/35220
        return handler.emitterProcessor.toMulti().toHotStream();
    }
  1. I am not sure MultiEmitterProcessor is good to work as a hot stream?

  2. or there are something like Reactor ConnectableFlux to connect to a hot stream manually?

问题回答

暂无回答




相关问题
How to optimize activemq

I m using ActiveMQ on a simulation of overloading servers in Java. And mainly it goes ok, but when I get over 600 requests the thing just go WTF! I think the bottleneck is my Master Server which is ...

Does Pentaho Kettle have a way to accept JMS messages?

Does Pentaho s ETL system, Kettle (http://kettle.pentaho.org/) have a plugin to accept information from JMS messages? I d like to set up a job that can read messages each containing a hash, extract ...

post message to a remote JMS provider

I want to be able to send messages to a remote JBoss server (JBoss MQ). I can do it for a local one but i m stuck when trying with a remote one. can anyone explain to me how to do it ? are there any ...

PostgreSQL and JMS (Or other Pub-Sub/Callback Mechanism)

I want to have my PostgreSQL server send out notifications when a piece of data changes, preferably over JMS, but also considering any other Pub-Sub mechanism or Callback. Any ideas if this is ...

ActiveMQ Consumer / Producer Connection Listener

I can t seem to find a way to listen for new producer and consumer connections (or connection interrupts) in ActiveMQ (Java Version). I want to be able to tell the consumers (or they can find out ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

热门标签