use of com.rabbitmq.client.ConnectionFactory in project tech by ffyyhh995511.
the class NewTask method main.
public static void main(String[] argv) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.queueDeclare(TASK_QUEUE_NAME, true, false, false, null);
String message = getMessage(argv);
channel.basicPublish("", TASK_QUEUE_NAME, MessageProperties.PERSISTENT_TEXT_PLAIN, message.getBytes("UTF-8"));
System.out.println(" [x] Sent '" + message + "'");
channel.close();
connection.close();
}
use of com.rabbitmq.client.ConnectionFactory in project tech by ffyyhh995511.
the class Send1 method main.
public static void main(String[] argv) throws Exception {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
Connection connection = factory.newConnection();
Channel channel = connection.createChannel();
channel.queueDeclare(QUEUE_NAME, false, false, false, null);
String message = "Hello World!";
channel.basicPublish("", QUEUE_NAME, null, message.getBytes("UTF-8"));
System.out.println(" [x] Sent '" + message + "'");
channel.close();
connection.close();
}
use of com.rabbitmq.client.ConnectionFactory in project metrics by dropwizard.
the class GraphiteRabbitMQTest method shouldFailWhenGraphiteHostUnavailable.
@Test
public void shouldFailWhenGraphiteHostUnavailable() {
ConnectionFactory connectionFactory = new ConnectionFactory();
connectionFactory.setHost("some-unknown-host");
try (GraphiteRabbitMQ unavailableGraphite = new GraphiteRabbitMQ(connectionFactory, "graphite")) {
unavailableGraphite.connect();
failBecauseExceptionWasNotThrown(UnknownHostException.class);
} catch (Exception e) {
assertThat(e.getMessage()).contains("some-unknown-host");
}
}
use of com.rabbitmq.client.ConnectionFactory in project rabbitmq-java-client by rabbitmq.
the class HostnameVerification method hostnameVerificationSucceeds.
@Test
public void hostnameVerificationSucceeds() throws Exception {
ConnectionFactory connectionFactory = TestUtils.connectionFactory();
connectionFactory.useSslProtocol(sslContext);
customizer.accept(connectionFactory);
try (Connection conn = connectionFactory.newConnection(() -> singletonList(new Address("localhost", ConnectionFactory.DEFAULT_AMQP_OVER_SSL_PORT)))) {
assertTrue(conn.isOpen());
}
}
use of com.rabbitmq.client.ConnectionFactory in project rabbitmq-java-client by rabbitmq.
the class HostnameVerification method hostnameVerificationFailsBecauseCertificateNotIssuedForLoopbackInterface.
@Test(expected = SSLHandshakeException.class)
public void hostnameVerificationFailsBecauseCertificateNotIssuedForLoopbackInterface() throws Exception {
ConnectionFactory connectionFactory = TestUtils.connectionFactory();
connectionFactory.useSslProtocol(sslContext);
customizer.accept(connectionFactory);
connectionFactory.newConnection(() -> singletonList(new Address("127.0.0.1", ConnectionFactory.DEFAULT_AMQP_OVER_SSL_PORT)));
fail("The server certificate isn't issued for 127.0.0.1, the TLS handshake should have failed");
}
Aggregations