簡體   English   中英

是否可以與javax.jms建立rabbitMQ連接(不使用rabbitMQ jms client / java client)? 如果是,怎么辦?

[英]is it possible to establish rabbitMQ connection with javax.jms (not using rabbitMQ jms client/ java client )? if yes how?

是否可以與javax.jms建立rabbitMQ連接(不使用rabbitMQ jms client / java client)? 如果是,如何(不使用springboot)。

您需要使用驅動程序或編寫自己的驅動程序。 您不應該期望有人在這里為您編寫它。 你嘗試了什么?

是的,有可能。 RabbitMQ提供了一個實現JMS連接工廠com.rabbitmq.client.ConnectionFactory的類

    ConnectionFactory connectionFactory = new Connection().newConnection();

    // create a Connection
    connection = connectionFactory.createConnection();
    connection.setClientID(clientId);

    // create a Session
    Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

    // create the Topic from which messages will be received
    Topic topic = session.createTopic(topicName);

    // create a MessageConsumer for receiving messages
    messageConsumer = session.createConsumer(topic);

    // start the connection in order to receive messages
    connection.start();

除了第一行(工廠創建)外,這是純JMS代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM