Search in sources :

Example 1 with RMQConnectionFactory

use of com.rabbitmq.jms.admin.RMQConnectionFactory in project rocketmq-externals by apache.

the class RabbitMQPatternProcessor method connectionFactory.

public ConnectionFactory connectionFactory() {
    RMQConnectionFactory connectionFactory = new RMQConnectionFactory();
    try {
        List<String> urlList = new ArrayList<>();
        urlList.add(config.getBrokerUrl());
        connectionFactory.setUris(urlList);
    } catch (JMSException e) {
        throw new DataConnectException(ErrorCode.START_ERROR_CODE, e.getMessage(), e);
    }
    return connectionFactory;
}
Also used : DataConnectException(io.openmessaging.connector.api.exception.DataConnectException) ArrayList(java.util.ArrayList) JMSException(javax.jms.JMSException) RMQConnectionFactory(com.rabbitmq.jms.admin.RMQConnectionFactory)

Example 2 with RMQConnectionFactory

use of com.rabbitmq.jms.admin.RMQConnectionFactory in project rocketmq-externals by apache.

the class RabbitmqSourceTaskTest method befores.

// @Before
public void befores() throws JMSException, InterruptedException {
    RMQConnectionFactory connectionFactory = new RMQConnectionFactory();
    connectionFactory.setUri("amqp://112.74.48.251:5672");
    Connection connection = connectionFactory.createConnection("admin", "admin");
    connection.start();
    Session session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
    Destination destination = session.createQueue("test-queue");
    MessageProducer producer = session.createProducer(destination);
    producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
    for (int i = 0; i < 20; i++) {
        TextMessage message = session.createTextMessage("hello 我是消息:" + i);
        producer.send(message);
    }
    session.commit();
    session.close();
    connection.close();
}
Also used : Destination(javax.jms.Destination) Connection(javax.jms.Connection) RMQConnectionFactory(com.rabbitmq.jms.admin.RMQConnectionFactory) MessageProducer(javax.jms.MessageProducer) TextMessage(javax.jms.TextMessage) RMQTextMessage(com.rabbitmq.jms.client.message.RMQTextMessage) Session(javax.jms.Session)

Example 3 with RMQConnectionFactory

use of com.rabbitmq.jms.admin.RMQConnectionFactory in project rabbitmq-jms-client by rabbitmq.

the class PublisherConfirmsIT method init.

@BeforeEach
public void init() throws Exception {
    ackedMessages.clear();
    RMQConnectionFactory connectionFactory = (RMQConnectionFactory) AbstractTestConnectionFactory.getTestConnectionFactory().getConnectionFactory();
    connectionFactory.setConfirmListener(context -> {
        TextMessage textMessage = (TextMessage) context.getMessage();
        try {
            ackedMessages.put(textMessage.getText(), textMessage);
        } catch (JMSException e) {
            throw new RuntimeException(e);
        }
    });
    connection = connectionFactory.createConnection();
    connection.start();
}
Also used : RMQConnectionFactory(com.rabbitmq.jms.admin.RMQConnectionFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with RMQConnectionFactory

use of com.rabbitmq.jms.admin.RMQConnectionFactory in project rabbitmq-jms-client by rabbitmq.

the class RpcSpringJmsIT method setupRpcServer.

void setupRpcServer() throws Exception {
    RMQConnectionFactory connectionFactory = (RMQConnectionFactory) AbstractTestConnectionFactory.getTestConnectionFactory().getConnectionFactory();
    connectionFactory.setDeclareReplyToDestination(false);
    serverConnection = connectionFactory.createConnection();
    serverConnection.start();
    Session session = serverConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue queue = session.createQueue(QUEUE_NAME);
    drainQueue(session, queue);
    session.close();
    rpcServer = new RpcServer(serverConnection);
}
Also used : RMQConnectionFactory(com.rabbitmq.jms.admin.RMQConnectionFactory) BlockingQueue(java.util.concurrent.BlockingQueue) Queue(javax.jms.Queue) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Session(javax.jms.Session)

Example 5 with RMQConnectionFactory

use of com.rabbitmq.jms.admin.RMQConnectionFactory in project rabbitmq-jms-client by rabbitmq.

the class SSLHostnameVerificationIT method init.

@BeforeEach
public void init() {
    cf = new RMQConnectionFactory();
    cf.useSslProtocol(sslContext);
    cf.setHostnameVerification(true);
}
Also used : RMQConnectionFactory(com.rabbitmq.jms.admin.RMQConnectionFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

RMQConnectionFactory (com.rabbitmq.jms.admin.RMQConnectionFactory)16 BeforeEach (org.junit.jupiter.api.BeforeEach)4 Session (javax.jms.Session)3 SSLContext (javax.net.ssl.SSLContext)3 Test (org.junit.jupiter.api.Test)3 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)2 BlockingQueue (java.util.concurrent.BlockingQueue)2 Queue (javax.jms.Queue)2 RMQTextMessage (com.rabbitmq.jms.client.message.RMQTextMessage)1 DataConnectException (io.openmessaging.connector.api.exception.DataConnectException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 Connection (javax.jms.Connection)1 Destination (javax.jms.Destination)1 JMSException (javax.jms.JMSException)1 MessageProducer (javax.jms.MessageProducer)1 QueueConnection (javax.jms.QueueConnection)1 TextMessage (javax.jms.TextMessage)1